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/13 18:30:43 UTC
cvs commit: apache-2.0/src/lib/apr/file_io/unix fileio.h pipe.c readwrite.c
dreid 00/06/13 09:30:43
Modified: src/lib/apr/file_io/unix fileio.h pipe.c readwrite.c
Log:
This starts to take the BeOS defines into the source. I've added support
for blocking/non-blocking of pipes as cleanly as I could and have changed the
indentation to try and make it clearer.
Revision Changes Path
1.21 +4 -1 apache-2.0/src/lib/apr/file_io/unix/fileio.h
Index: fileio.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/fileio.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- fileio.h 2000/06/12 13:51:22 1.20
+++ fileio.h 2000/06/13 16:30:39 1.21
@@ -98,7 +98,10 @@
#ifdef BEOS
#include <kernel/OS.h>
#endif
-#if BEOS && HAVE_ARPA_INET_H
+/* BeOS still defines fd_set in sys/socket.h so include it here.
+ * I'm not just including it as most platforms won't need it...
+ */
+#if BEOS_BONE
#include <sys/socket.h> /* for fd_set definitions */
#endif
/* End System headers */
1.32 +50 -30 apache-2.0/src/lib/apr/file_io/unix/pipe.c
Index: pipe.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/pipe.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- pipe.c 2000/04/30 21:17:55 1.31
+++ pipe.c 2000/06/13 16:30:40 1.32
@@ -54,25 +54,36 @@
#include "fileio.h"
-static ap_status_t pipenonblock(ap_file_t *thefile)
+static ap_status_t pipenonblock(ap_file_t *thepipe)
{
-#ifndef BEOS /* this code won't work on BeOS */
- int fd_flags = fcntl(thefile->filedes, F_GETFL, 0);
+#if !BEOS /* this code won't work on BeOS */
+ int fd_flags;
-#if defined(O_NONBLOCK)
- fd_flags |= O_NONBLOCK;
-#elif defined(O_NDELAY)
- fd_flags |= O_NDELAY;
-#elif defined(FNDELAY)
- fd_flags |= O_FNDELAY;
-#else
- /* XXXX: this breaks things, but an alternative isn't obvious...*/
- return -1;
-#endif
- if (fcntl(thefile->filedes, F_SETFL, fd_flags) == -1) {
+ int fd_flags = fcntl(thepipe->filedes, F_GETFL, 0);
+
+ #if defined(O_NONBLOCK)
+ fd_flags |= O_NONBLOCK;
+ #elif defined(O_NDELAY)
+ fd_flags |= O_NDELAY;
+ #elif defined(FNDELAY)
+ fd_flags |= O_FNDELAY;
+ #else
+ /* XXXX: this breaks things, but an alternative isn't obvious...*/
+ return -1;
+ #endif
+ if (fcntl(thepipe->filedes, F_SETFL, fd_flags) == -1) {
+ return errno;
+ }
+
+#else /* !BEOS */
+
+#if BEOS_BONE /* This only works on BONE and later...*/
+ int on = 0;
+ if (ioctl(thepipe->filedes, FIONBIO, &on, sizeof(on)) < 0)
return errno;
- }
-#endif /* !BeOS */
+#endif /* BEOS_BONE */
+
+#endif /* !BEOS */
return APR_SUCCESS;
}
@@ -135,24 +146,33 @@
ap_status_t ap_block_pipe(ap_file_t *thepipe)
{
-#ifndef BEOS /* this code won't work on BeOS */
- int fd_flags;
+#if !BEOS /* this code won't work on BeOS */
+ int fd_flags;
- fd_flags = fcntl(thepipe->filedes, F_GETFL, 0);
-#if defined(O_NONBLOCK)
- fd_flags &= ~O_NONBLOCK;
-#elif defined(~O_NDELAY)
- fd_flags &= ~O_NDELAY;
-#elif defined(FNDELAY)
- fd_flags &= ~O_FNDELAY;
-#else
- /* XXXX: this breaks things, but an alternative isn't obvious...*/
- return -1;
-#endif
+ fd_flags = fcntl(thepipe->filedes, F_GETFL, 0);
+ #if defined(O_NONBLOCK)
+ fd_flags &= ~O_NONBLOCK;
+ #elif defined(~O_NDELAY)
+ fd_flags &= ~O_NDELAY;
+ #elif defined(FNDELAY)
+ fd_flags &= ~O_FNDELAY;
+ #else
+ /* XXXX: this breaks things, but an alternative isn't obvious...*/
+ return -1;
+ #endif
if (fcntl(thepipe->filedes, F_SETFL, fd_flags) == -1) {
return errno;
}
-#endif /* !BeOS */
+
+#else
+
+#if BEOS_BONE /* This only works on BONE or beyond */
+ int on = 0;
+ if (ioctl(thepipe->filedes, FIONBIO, &on, sizeof(on)) < 0)
+ return errno;
+#endif /* BEOS_BONE */
+
+#endif /* !BEOS_R5 */
return APR_SUCCESS;
}
1.53 +3 -1 apache-2.0/src/lib/apr/file_io/unix/readwrite.c
Index: readwrite.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/readwrite.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- readwrite.c 2000/06/12 13:51:22 1.52
+++ readwrite.c 2000/06/13 16:30:40 1.53
@@ -55,7 +55,9 @@
#include "fileio.h"
#include "apr_lock.h"
-#if !BEOS || (BEOS && HAVE_ARPA_INET_H)
+/* The only case where we don't use wait_for_io_or_timeout is on
+ * pre-BONE BeOS, so this check should be sufficient and simpler */
+#if !BEOS_R5
#define USE_WAIT_FOR_IO
#endif