dreid 01/12/11 09:08:16
Modified: file_io/unix pipe.c
Log:
Do the right thing when setting pipe timeouts for the latest BONE beta.
Revision Changes Path
1.49 +37 -25 apr/file_io/unix/pipe.c
Index: pipe.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/pipe.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- pipe.c 2001/08/10 21:04:47 1.48
+++ pipe.c 2001/12/11 17:08:16 1.49
@@ -55,9 +55,20 @@
#include "fileio.h"
#include "apr_strings.h"
+/* Figure out how to get pipe block/nonblock on BeOS...
+ * Basically, BONE7 changed things again so that ioctl didn't work,
+ * but now fcntl does, hence we need to do this extra checking.
+ * The joys of beta programs. :-)
+ */
+#if BEOS
+#if !BONE7
+# define BEOS_BLOCKING
+#endif
+#endif
+
static apr_status_t pipeblock(apr_file_t *thepipe)
{
-#if !BEOS /* this code won't work on BeOS */
+#if !BEOS_BLOCKING
int fd_flags;
fd_flags = fcntl(thepipe->filedes, F_GETFL, 0);
@@ -71,21 +82,21 @@
/* XXXX: this breaks things, but an alternative isn't obvious...*/
return APR_ENOTIMPL;
# endif
- if (fcntl(thepipe->filedes, F_SETFL, fd_flags) == -1) {
- return errno;
- }
-
-#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;
-# else /* BEOS_BONE */
- return APR_ENOTIMPL;
-# endif /* BEOS_BONE */
+ if (fcntl(thepipe->filedes, F_SETFL, fd_flags) == -1) {
+ return errno;
+ }
+#else /* BEOS_BLOCKING */
+
+# if BEOS_BONE /* This only works on BONE 0-6 */
+ int on = 0;
+ if (ioctl(thepipe->filedes, FIONBIO, &on, sizeof(on)) < 0) {
+ return errno;
+ }
+# else /* "classic" BeOS doesn't support this at all */
+ return APR_ENOTIMPL;
+# endif
-#endif /* !BEOS_R5 */
+#endif /* !BEOS_BLOCKING */
thepipe->blocking = BLK_ON;
return APR_SUCCESS;
@@ -93,7 +104,7 @@
static apr_status_t pipenonblock(apr_file_t *thepipe)
{
-#if !BEOS /* this code won't work on BeOS */
+#if !BEOS_BLOCKING
int fd_flags = fcntl(thepipe->filedes, F_GETFL, 0);
# if defined(O_NONBLOCK)
@@ -110,17 +121,18 @@
return errno;
}
-#else /* !BEOS */
+#else /* BEOS_BLOCKING */
-# if BEOS_BONE /* This only works on BONE and later...*/
- int on = 1;
- if (ioctl(thepipe->filedes, FIONBIO, &on, sizeof(on)) < 0)
- return errno;
-# else /* BEOS_BONE */
- return APR_ENOTIMPL;
-# endif /* BEOS_BONE */
+# if BEOS_BONE /* This only works on BONE 0-6 */
+ int on = 1;
+ if (ioctl(thepipe->filedes, FIONBIO, &on, sizeof(on)) < 0) {
+ return errno;
+ }
+# else /* "classic" BeOS doesn't support this at all */
+ return APR_ENOTIMPL;
+# endif
-#endif /* !BEOS */
+#endif /* !BEOS_BLOCKING */
thepipe->blocking = BLK_OFF;
return APR_SUCCESS;