You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by dr...@locus.apache.org on 2000/06/12 15:39:41 UTC
cvs commit: apache-2.0/src/lib/apr/network_io/unix networkio.h poll.c sockets.c sockopt.c
dreid 00/06/12 06:39:41
Modified: src/lib/apr/network_io/unix networkio.h poll.c sockets.c
sockopt.c
Log:
Tidy up the unix network code in light of the latest network
update on BeOS. This makes things much tidier.
Revision Changes Path
1.27 +1 -8 apache-2.0/src/lib/apr/network_io/unix/networkio.h
Index: networkio.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/networkio.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- networkio.h 2000/05/16 20:35:38 1.26
+++ networkio.h 2000/06/12 13:39:39 1.27
@@ -104,12 +104,9 @@
#if HAVE_SYS_SENDFILE_H
#include <sys/sendfile.h>
#endif
-#if HAVE_BYTEORDER_H
-#include <ByteOrder.h> /* for ntohs on BeOS */
-#endif
/* End System Headers */
-/* The definition of isascii was missed from the PowerPC ctype.h
+/* The definition of isascii was missed from the BeOS PowerPC ctype.h
*
* It will be included in the next release, but until then...
*/
@@ -154,10 +151,6 @@
ap_int16_t *revents;
};
-
-#if BEOS
-int inet_aton(const char *cp, struct in_addr *addr);
-#endif
#endif /* ! NETWORK_IO_H */
1.34 +0 -16 apache-2.0/src/lib/apr/network_io/unix/poll.c
Index: poll.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/poll.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- poll.c 2000/05/24 22:32:41 1.33
+++ poll.c 2000/06/12 13:39:39 1.34
@@ -273,11 +273,7 @@
}
rv = select(aprset->highsock + 1, aprset->read, aprset->write,
-#ifdef BEOS
- NULL, tvptr);
-#else
aprset->except, tvptr);
-#endif
(*nsds) = rv;
if ((*nsds) == 0) {
@@ -301,14 +297,7 @@
if (FD_ISSET(sock->socketdes, aprset->read)) {
revents |= APR_POLLIN;
if (sock->connected
-#ifdef BEOS
- /* XXX I would really like to understand why this difference
- * exists. Can we get rid of it? rbb
- */
- && recv(sock->socketdes, data, 0, 0) == -1) {
-#else
&& recv(sock->socketdes, data, sizeof data, flags) == -1) {
-#endif
switch (errno) {
case ECONNRESET:
case ECONNABORTED:
@@ -328,14 +317,9 @@
}
}
}
-#ifndef BEOS
- /* 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->write)) {
revents |= APR_POLLOUT;
}
-#endif
/* 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.
1.47 +2 -14 apache-2.0/src/lib/apr/network_io/unix/sockets.c
Index: sockets.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sockets.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- sockets.c 2000/06/10 02:02:44 1.46
+++ sockets.c 2000/06/12 13:39:39 1.47
@@ -55,19 +55,10 @@
#include "networkio.h"
#include "apr_portable.h"
-/* BeOS uses closesocket instead of close to close their sockets and they
- * don't provide inet_aton. This small ifndef takes care of both problems.
- */
-#ifndef BEOS
-#define closesocket close
-#else
-#include "inet_aton.c"
-#endif
-
static ap_status_t socket_cleanup(void *sock)
{
ap_socket_t *thesocket = sock;
- if (closesocket(thesocket->socketdes) == 0) {
+ if (close(thesocket->socketdes) == 0) {
thesocket->socketdes = -1;
return APR_SUCCESS;
}
@@ -111,9 +102,6 @@
ap_status_t ap_shutdown(ap_socket_t *thesocket, ap_shutdown_how_e how)
{
- /* BEOS internal documentation indicates that this system call
- * may not work in 5.0, but we don't have any alternatives.
- */
return (shutdown(thesocket->socketdes, how) == -1) ? errno : APR_SUCCESS;
}
@@ -155,7 +143,7 @@
(*new)->connected = 1;
#endif
(*new)->timeout = -1;
-
+
(*new)->socketdes = accept(sock->socketdes, (struct sockaddr *)(*new)->remote_addr,
&(*new)->addr_len);
1.27 +26 -23 apache-2.0/src/lib/apr/network_io/unix/sockopt.c
Index: sockopt.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sockopt.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- sockopt.c 2000/06/10 02:02:45 1.26
+++ sockopt.c 2000/06/12 13:39:39 1.27
@@ -56,6 +56,8 @@
static ap_status_t soblock(int sd)
{
+/* BeOS uses setsockopt at present for non blocking... */
+#ifndef BEOS
int fd_flags;
fd_flags = fcntl(sd, F_GETFL, 0);
@@ -72,11 +74,17 @@
if (fcntl(sd, F_SETFL, fd_flags) == -1) {
return errno;
}
+#else
+ int on = 0;
+ if (setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(int)) < 0)
+ return errno;
+#endif /* BEOS */
return APR_SUCCESS;
}
static ap_status_t sononblock(int sd)
{
+#ifndef BEOS
int fd_flags;
fd_flags = fcntl(sd, F_GETFL, 0);
@@ -93,6 +101,11 @@
if (fcntl(sd, F_SETFL, fd_flags) == -1) {
return errno;
}
+#else
+ int on = 1;
+ if (setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(int)) < 0)
+ return errno;
+#endif /* BEOS */
return APR_SUCCESS;
}
@@ -123,16 +136,11 @@
}
}
if (opt & APR_SO_SNDBUF) {
-#ifdef BEOS
- return APR_ENOTIMPLE;
-#else
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDBUF, (void *)&on, sizeof(int)) == -1) {
return errno;
}
-#endif
}
if (opt & APR_SO_NONBLOCK) {
-#ifndef BEOS
if (on) {
if ((stat = soblock(sock->socketdes)) != APR_SUCCESS)
return stat;
@@ -141,11 +149,6 @@
if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS)
return stat;
}
-#else
- stat = setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(int));
- if (stat != 0)
- return stat;
-#endif
}
if (opt & APR_SO_LINGER) {
li.l_onoff = on;
@@ -153,20 +156,20 @@
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(struct linger)) == -1) {
return errno;
}
- }
- if (opt & APR_SO_TIMEOUT) {
- /* don't do the fcntl foo more than needed */
- if (on >= 0 && sock->timeout < 0
- && (stat = sononblock(sock->socketdes)) != APR_SUCCESS) {
- return stat;
- }
- else if (on < 0 && sock->timeout >= 0
- && (stat = soblock(sock->socketdes)) != APR_SUCCESS) {
- return stat;
- }
- sock->timeout = on;
}
- return APR_SUCCESS;
+ if (opt & APR_SO_TIMEOUT) {
+ /* don't do the fcntl foo more than needed */
+ if (on >= 0 && sock->timeout < 0
+ && (stat = sononblock(sock->socketdes)) != APR_SUCCESS) {
+ return stat;
+ }
+ else if (on < 0 && sock->timeout >= 0
+ && (stat = soblock(sock->socketdes)) != APR_SUCCESS) {
+ return stat;
+ }
+ sock->timeout = on;
+ }
+ return APR_SUCCESS;
}
ap_status_t ap_gethostname(char *buf, ap_int32_t len, ap_pool_t *cont)