summaryrefslogtreecommitdiff
path: root/network_io/beos
diff options
context:
space:
mode:
authorDavid Reid <dreid@apache.org>2000-11-18 16:53:18 +0000
committerDavid Reid <dreid@apache.org>2000-11-18 16:53:18 +0000
commit237c9a7a09552b9e57081a0eff0d5e950a588fe1 (patch)
tree5705a70c80e91f82bf85508232a858b39b279ab3 /network_io/beos
parentb44c553c6b228d5b6467986650358dbccd7cdb08 (diff)
downloadapr-237c9a7a09552b9e57081a0eff0d5e950a588fe1.tar.gz
This changes BeOS to use the majority of the Unix socket code.
Once this has been in a day or 2 I'll remove the old files. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@60761 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io/beos')
-rw-r--r--network_io/beos/Makefile.in11
-rw-r--r--network_io/beos/poll.c63
-rw-r--r--network_io/beos/sendrecv.c3
-rw-r--r--network_io/beos/socketcommon.c5
4 files changed, 44 insertions, 38 deletions
diff --git a/network_io/beos/Makefile.in b/network_io/beos/Makefile.in
index 164dbc390..f7477ef66 100644
--- a/network_io/beos/Makefile.in
+++ b/network_io/beos/Makefile.in
@@ -3,18 +3,17 @@ RANLIB=@RANLIB@
CFLAGS=@CFLAGS@ @OPTIM@
LIBS=@LIBS@
LDFLAGS=@LDFLAGS@ $(LIBS)
-INCDIR=../../include -I../../file_io/unix
-INCLUDES=-I$(INCDIR) -I.
+INCDIR=../../include
+OSDIR=$(INCDIR)/arch/@OSDIR@
+DEFOSDIR=$(INCDIR)/arch/@DEFAULT_OSDIR@
+INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR)
MKDEP=../../helpers/mkdep.sh
LIB=libnetwork.a
OBJS=poll.o \
sendrecv.o \
- sockets.o \
- sockopt.o \
- inet_aton.o \
- sockaddr.o
+ socketcommon.o
.c.o:
$(CC) $(CFLAGS) -c $(INCLUDES) $<
diff --git a/network_io/beos/poll.c b/network_io/beos/poll.c
index b6089bee8..a95738185 100644
--- a/network_io/beos/poll.c
+++ b/network_io/beos/poll.c
@@ -58,25 +58,25 @@
#else
#include "networkio.h"
-/* BeOS R4 doesn't have a poll function, but R5 will have */
-/* so for the time being we try our best with an implementaion that */
-/* uses select. However, select on beos isn't that hot either, so */
-/* until R5 we have to live with a less than perfect implementation */
-
-/* Apparently those sneaky people at Be included support for write in */
-/* select for R4.5 of BeOS. So here we use code that uses the write */
-/* bits. */
-
+/* BeOS R4 doesn't have a poll function, but R5 will have
+ * so for the time being we try our best with an implementaion that
+ * uses select. However, select on beos isn't that hot either, so
+ * until R5 we have to live with a less than perfect implementation
+ *
+ * Apparently those sneaky people at Be included support for write in
+ * select for R4.5 of BeOS. So here we use code that uses the write
+ * bits.
+ */
apr_status_t apr_setup_poll(apr_pollfd_t **new, apr_int32_t num, apr_pool_t *cont)
{
- (*new) = (apr_pollfd_t *)apr_palloc(cont, sizeof(apr_pollfd_t) * num);
+ (*new) = (apr_pollfd_t *)apr_pcalloc(cont, sizeof(apr_pollfd_t) * num);
if ((*new) == NULL) {
return APR_ENOMEM;
}
(*new)->cntxt = cont;
- (*new)->read = (fd_set *)apr_palloc(cont, sizeof(fd_set));
- (*new)->write = (fd_set *)apr_palloc(cont, sizeof(fd_set));
- (*new)->except = (fd_set *)apr_palloc(cont, sizeof(fd_set));
+ (*new)->read = (fd_set *)apr_pcalloc(cont, sizeof(fd_set));
+ (*new)->write = (fd_set *)apr_pcalloc(cont, sizeof(fd_set));
+ (*new)->except = (fd_set *)apr_pcalloc(cont, sizeof(fd_set));
FD_ZERO((*new)->read);
FD_ZERO((*new)->write);
FD_ZERO((*new)->except);
@@ -114,12 +114,12 @@ apr_status_t apr_poll(apr_pollfd_t *aprset, apr_int32_t *nsds,
else {
tv.tv_sec = timeout / APR_USEC_PER_SEC;
tv.tv_usec = timeout % APR_USEC_PER_SEC;
- tvptr = &tv;
+ tvptr = &tv;
}
rv = select(aprset->highsock + 1, aprset->read, aprset->write,
- NULL, tvptr);
-
+ aprset->except, tvptr);
+
(*nsds) = rv;
if ((*nsds) == 0) {
return APR_TIMEUP;
@@ -133,43 +133,42 @@ apr_status_t apr_poll(apr_pollfd_t *aprset, apr_int32_t *nsds,
apr_status_t apr_get_revents(apr_int16_t *event, apr_socket_t *sock, apr_pollfd_t *aprset)
{
apr_int16_t revents = 0;
- char data[256];
- int dummy = 256;
+ char data[1];
+ int flags = 0;
if (FD_ISSET(sock->socketdes, aprset->read)) {
revents |= APR_POLLIN;
- if (recv(sock->socketdes, &data, 0, 0) == -1) {
+ if (sock->connected
+ && recv(sock->socketdes, data, 0 /*sizeof data*/, flags) == -1) {
switch (errno) {
case ECONNRESET:
case ECONNABORTED:
case ESHUTDOWN:
- case ENETRESET: {
+ case ENETRESET:
revents ^= APR_POLLIN;
revents |= APR_POLLHUP;
break;
- }
- case ENOTSOCK: {
+ case ENOTSOCK:
revents ^= APR_POLLIN;
revents |= APR_POLLNVAL;
- }
- default: {
+ break;
+ default:
revents ^= APR_POLLIN;
revents |= APR_POLLERR;
- }
+ break;
}
}
}
if (FD_ISSET(sock->socketdes, aprset->write)) {
revents |= APR_POLLOUT;
}
-
- /* Still no support for execpt bits in BeOS R4.5 so for the time being */
- /* we can't check this. Hopefully the error checking above will allow */
- /* sufficient errors to be recognised to cover this. */
-
- /*if (FD_ISSET(sock->socketdes, aprset->except)) {
+ /* I am assuming that the except is for out of band data, not a failed
+ * connection on a non-blocking socket. Might be a bad assumption, but
+ * it works for now. rbb.
+ */
+ if (FD_ISSET(sock->socketdes, aprset->except)) {
revents |= APR_POLLPRI;
- }*/
+ }
(*event) = revents;
return APR_SUCCESS;
diff --git a/network_io/beos/sendrecv.c b/network_io/beos/sendrecv.c
index ec96869fd..a140844b6 100644
--- a/network_io/beos/sendrecv.c
+++ b/network_io/beos/sendrecv.c
@@ -117,6 +117,7 @@ apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
return errno;
}
(*len) = rv;
+
return APR_SUCCESS;
}
@@ -145,6 +146,8 @@ apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
return errno;
}
(*len) = rv;
+ if (rv == 0)
+ return APR_EOF;
return APR_SUCCESS;
}
diff --git a/network_io/beos/socketcommon.c b/network_io/beos/socketcommon.c
new file mode 100644
index 000000000..cdadc8561
--- /dev/null
+++ b/network_io/beos/socketcommon.c
@@ -0,0 +1,5 @@
+#include "../unix/inet_ntop.c"
+#include "../unix/inet_pton.c"
+#include "../unix/sockets.c"
+#include "../unix/sockaddr.c"
+#include "../unix/sockopt.c"