summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--file_io/os2/pipe.c2
-rw-r--r--file_io/unix/fileio.h4
-rw-r--r--file_io/unix/pipe.c3
-rw-r--r--file_io/unix/readwrite.c16
-rw-r--r--file_io/win32/fileio.h2
-rw-r--r--include/apr_file_io.h3
-rw-r--r--include/apr_time.h3
-rw-r--r--include/arch/unix/fileio.h4
-rw-r--r--include/arch/win32/fileio.h2
-rw-r--r--test/testpipe.c2
10 files changed, 26 insertions, 15 deletions
diff --git a/file_io/os2/pipe.c b/file_io/os2/pipe.c
index b8b093812..4ddf732d9 100644
--- a/file_io/os2/pipe.c
+++ b/file_io/os2/pipe.c
@@ -100,7 +100,7 @@ ap_status_t ap_create_namedpipe(char *filename, ap_fileperms_t perm, ap_pool_t *
-ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_int32_t timeout)
+ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_interval_time_t timeout)
{
return APR_ENOTIMPL;
}
diff --git a/file_io/unix/fileio.h b/file_io/unix/fileio.h
index 63b9bb085..499fcdfd8 100644
--- a/file_io/unix/fileio.h
+++ b/file_io/unix/fileio.h
@@ -109,7 +109,7 @@ struct ap_file_t {
int oflags;
int eof_hit;
int pipe;
- int timeout;
+ ap_interval_time_t timeout;
int buffered;
int ungetchar; /* Last char provided by an unget op. (-1 = no char)*/
@@ -120,7 +120,7 @@ struct ap_file_t {
int direction; /* buffer being used for 0 = read, 1 = write */
unsigned long filePtr; /* position in file of handle */
#if APR_HAS_THREADS
- ap_lock_t *thlock;
+ struct ap_lock_t *thlock;
#endif
};
diff --git a/file_io/unix/pipe.c b/file_io/unix/pipe.c
index 4d2bb9a18..d21aac78b 100644
--- a/file_io/unix/pipe.c
+++ b/file_io/unix/pipe.c
@@ -76,8 +76,7 @@ static ap_status_t pipenonblock(ap_file_t *thefile)
return APR_SUCCESS;
}
-
-ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_int32_t timeout)
+ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_interval_time_t timeout)
{
if(thepipe == NULL)
return APR_EBADARG;
diff --git a/file_io/unix/readwrite.c b/file_io/unix/readwrite.c
index 39ebb78cc..99711e329 100644
--- a/file_io/unix/readwrite.c
+++ b/file_io/unix/readwrite.c
@@ -56,20 +56,28 @@
static ap_status_t wait_for_io_or_timeout(ap_file_t *file, int for_read)
{
- struct timeval tv;
+ struct timeval tv, *tvptr;
fd_set fdset;
int srv;
+ /* TODO - timeout should be less each time through this loop */
+
do {
FD_ZERO(&fdset);
FD_SET(file->filedes, &fdset);
- tv.tv_sec = file->timeout;
- tv.tv_usec = 0;
+ if (file->timeout >= 0) {
+ tv.tv_sec = file->timeout / AP_USEC_PER_SEC;
+ tv.tv_usec = file->timeout % AP_USEC_PER_SEC;
+ tvptr = &tv;
+ }
+ else {
+ tvptr = NULL;
+ }
srv = select(FD_SETSIZE,
for_read ? &fdset : NULL,
for_read ? NULL : &fdset,
NULL,
- file->timeout < 0 ? NULL : &tv);
+ tvptr);
} while (srv == -1 && errno == EINTR);
if (srv == 0) {
diff --git a/file_io/win32/fileio.h b/file_io/win32/fileio.h
index 108c343d4..150d4adfa 100644
--- a/file_io/win32/fileio.h
+++ b/file_io/win32/fileio.h
@@ -110,7 +110,7 @@ struct ap_file_t {
ap_time_t mtime;
ap_time_t ctime;
int pipe;
- int timeout;
+ ap_interval_time_t timeout;
};
struct ap_dir_t {
diff --git a/include/apr_file_io.h b/include/apr_file_io.h
index 267533fca..1dfcabbcb 100644
--- a/include/apr_file_io.h
+++ b/include/apr_file_io.h
@@ -79,6 +79,7 @@ typedef enum {APR_NOFILE, APR_REG, APR_DIR, APR_CHR, APR_BLK, APR_PIPE, APR_LNK,
#define APR_EXCL 64 /* Open should fail if APR_CREATE and file
exists. */
#define APR_DELONCLOSE 256 /* Delete the file after close */
+#define APR_BUFFERED 512 /* Buffered I/O */
/* flags for ap_seek */
#define APR_SET SEEK_SET
@@ -422,7 +423,7 @@ ap_status_t ap_create_namedpipe(char *filename, ap_fileperms_t perm,
* arg 3) The timeout value in seconds. Values < 0 mean wait forever, 0
* means do not wait at all.
*/
-ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_int32_t timeout);
+ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_interval_time_t timeout);
/* ***APRDOC********************************************************
* ap_status_t ap_block_pipe(ap_file_t *thepipe)
diff --git a/include/apr_time.h b/include/apr_time.h
index 271508cea..f81a40718 100644
--- a/include/apr_time.h
+++ b/include/apr_time.h
@@ -68,6 +68,9 @@ API_VAR_IMPORT const char ap_day_snames[7][4];
/* number of microseconds since 00:00:00 january 1, 1970 UTC */
typedef ap_int64_t ap_time_t;
+/* intervals for I/O timeouts, in microseconds */
+typedef ap_int32_t ap_interval_time_t;
+
#ifdef WIN32
#define AP_USEC_PER_SEC ((LONGLONG) 1000000)
#else
diff --git a/include/arch/unix/fileio.h b/include/arch/unix/fileio.h
index 63b9bb085..499fcdfd8 100644
--- a/include/arch/unix/fileio.h
+++ b/include/arch/unix/fileio.h
@@ -109,7 +109,7 @@ struct ap_file_t {
int oflags;
int eof_hit;
int pipe;
- int timeout;
+ ap_interval_time_t timeout;
int buffered;
int ungetchar; /* Last char provided by an unget op. (-1 = no char)*/
@@ -120,7 +120,7 @@ struct ap_file_t {
int direction; /* buffer being used for 0 = read, 1 = write */
unsigned long filePtr; /* position in file of handle */
#if APR_HAS_THREADS
- ap_lock_t *thlock;
+ struct ap_lock_t *thlock;
#endif
};
diff --git a/include/arch/win32/fileio.h b/include/arch/win32/fileio.h
index 108c343d4..150d4adfa 100644
--- a/include/arch/win32/fileio.h
+++ b/include/arch/win32/fileio.h
@@ -110,7 +110,7 @@ struct ap_file_t {
ap_time_t mtime;
ap_time_t ctime;
int pipe;
- int timeout;
+ ap_interval_time_t timeout;
};
struct ap_dir_t {
diff --git a/test/testpipe.c b/test/testpipe.c
index fe85ad746..1c96ac92a 100644
--- a/test/testpipe.c
+++ b/test/testpipe.c
@@ -95,7 +95,7 @@ int main()
}
fprintf(stdout, "\tSetting pipe timeout.......");
- if (ap_set_pipe_timeout(readp, 1) != APR_SUCCESS) {
+ if (ap_set_pipe_timeout(readp, 1 * AP_USEC_PER_SEC) != APR_SUCCESS) {
perror("Couldn't set a timeout");
exit(-1);
} else {