Hi all,
I am trying to open a fifo on disk with the O_NONBLOCK flag set, and I
notice that apr's apr_file_open() cannot do this.
As a result, if nobody else is already reading from the fifo,
apr_file_open blocks, and this is the behaviour I want to avoid.
Does anyone know of any reason why this wouldn't work?
Index: include/apr_file_io.h
===================================================================
--- include/apr_file_io.h (revision 916953)
+++ include/apr_file_io.h (working copy)
@@ -81,6 +81,8 @@
#define APR_FOPEN_SPARSE 0x08000 /**< Platform dependent flag
to enable
* sparse file support, see
WARNING below
*/
+#define APR_FOPEN_NONBLOCK 0x10000 /**< Platform dependent flag to
enable
+ * non blocking file io */
#define APR_FOPEN_ROTATING 0x10000 /**< Do file file rotation
checking */
@@ -102,6 +104,7 @@
#define APR_FILE_NOCLEANUP APR_FOPEN_NOCLEANUP /**< @deprecated
@see APR_FOPEN_NOCLEANUP */
#define APR_SENDFILE_ENABLED APR_FOPEN_SENDFILE_ENABLED /**<
@deprecated @see APR_FOPEN_SENDFILE_ENABLED */
#define APR_LARGEFILE APR_FOPEN_LARGEFILE /**< @deprecated
@see APR_FOPEN_LARGEFILE */
+#define APR_NONBLOCK APR_FOPEN_NONBLOCK /**< @deprecated
@see APR_FOPEN_NONBLOCK */
/** @warning APR_FOPEN_LARGEFILE flag only has effect on some
* platforms where sizeof(apr_off_t) == 4. Where implemented, it
Index: file_io/unix/open.c
===================================================================
--- file_io/unix/open.c (revision 916953)
+++ file_io/unix/open.c (working copy)
@@ -136,6 +136,12 @@
}
#endif
+#ifdef O_NONBLOCK
+ if (flag & APR_NONBLOCK) {
+ oflags |= O_NONBLOCK;
+ }
+#endif
+
#ifdef O_CLOEXEC
/* Introduced in Linux 2.6.23. Silently ignored on earlier Linux
kernels.
*/
Regards,
Graham
--