You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by st...@locus.apache.org on 2000/04/13 00:10:17 UTC
cvs commit: apache-2.0/src/lib/apr/file_io/win32 fileio.h pipe.c readwrite.c
stoddard 00/04/12 15:10:17
Modified: src CHANGES
src/lib/apr/file_io/win32 fileio.h pipe.c readwrite.c
Log:
Win32: Get nonblocking CGI pipe I/O working on Windows NT. Still need
to handle timing out the pipes.
PR: 1623 (Apache 1.3 repository)
Revision Changes Path
1.61 +4 -0 apache-2.0/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apache-2.0/src/CHANGES,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- CHANGES 2000/04/12 14:28:34 1.60
+++ CHANGES 2000/04/12 22:10:16 1.61
@@ -1,4 +1,8 @@
Changes with Apache 2.0a3-dev
+ *) Win32: Get non-blocking CGI pipe reads working under Windows NT.
+ This addresses PR 1623. Still need to address timing out runaway
+ CGI scripts. [Bill Stoddard]
+
*) Win32: Make ap_stat Windows 95/98 friendly
[William Rowe <wr...@lnd.com>]
1.15 +2 -0 apache-2.0/src/lib/apr/file_io/win32/fileio.h
Index: fileio.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/fileio.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- fileio.h 2000/04/07 02:33:58 1.14
+++ fileio.h 2000/04/12 22:10:16 1.15
@@ -109,6 +109,8 @@
ap_time_t atime;
ap_time_t mtime;
ap_time_t ctime;
+ int pipe;
+ int timeout;
};
struct ap_dir_t {
1.11 +26 -15 apache-2.0/src/lib/apr/file_io/win32/pipe.c
Index: pipe.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/pipe.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- pipe.c 2000/04/03 19:44:37 1.10
+++ pipe.c 2000/04/12 22:10:16 1.11
@@ -64,8 +64,29 @@
ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_int32_t timeout)
{
- return APR_ENOTIMPL;
+ DWORD dwMode;
+ ap_oslevel_e oslevel;
+
+ /* This code relies on the fact that anonymous pipes (which
+ * do not support nonblocking I/O) are really named pipes
+ * (which support nonblocking I/O) on Windows NT.
+ */
+ if (thepipe->pipe == 1) {
+ thepipe->timeout = timeout;
+ if (ap_get_oslevel(thepipe->cntxt, &oslevel) == APR_SUCCESS &&
+ oslevel >= APR_WIN_NT) {
+ if (timeout == 0) {
+ dwMode = PIPE_NOWAIT;
+ } else {
+ dwMode = PIPE_WAIT;
+ }
+ SetNamedPipeHandleState(thepipe->filehand, &dwMode, NULL, NULL);
+ }
+ return APR_SUCCESS;
+ }
+ return APR_EINVAL;
}
+
ap_status_t ap_create_pipe(ap_file_t **in, ap_file_t **out, ap_context_t *cont)
{
SECURITY_ATTRIBUTES sa;
@@ -77,12 +98,16 @@
(*in) = (ap_file_t *)ap_palloc(cont, sizeof(ap_file_t));
memset(*in, '\0', sizeof(ap_file_t));
(*in)->cntxt = cont;
+ (*in)->pipe = 1;
(*in)->fname = ap_pstrdup(cont, "PIPE");
+ (*in)->timeout = -1;
(*out) = (ap_file_t *)ap_palloc(cont, sizeof(ap_file_t));
memset(*out, '\0', sizeof(ap_file_t));
(*out)->cntxt = cont;
+ (*out)->pipe = 1;
(*out)->fname = ap_pstrdup(cont, "PIPE");
+ (*out)->timeout = -1;
if (!CreatePipe(&(*in)->filehand, &(*out)->filehand, &sa, 0)) {
return GetLastError();
@@ -90,17 +115,3 @@
return APR_SUCCESS;
}
-
-/*
-ap_status_t ap_create_namedpipe(char **new, char *dirpath, ap_fileperms_t perm, ap_context_t *cont)
-{
- mode_t mode = get_fileperms(perm);
-
- *new = tempnam(dirpath, NULL);
- if (mkfifo((*new), mode) == -1) {
- return errno;
- }
- return APR_SUCCESS;
-}
-*/
-
1.22 +5 -13 apache-2.0/src/lib/apr/file_io/win32/readwrite.c
Index: readwrite.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/readwrite.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- readwrite.c 2000/04/07 02:33:58 1.21
+++ readwrite.c 2000/04/12 22:10:16 1.22
@@ -68,23 +68,20 @@
DWORD bread;
int lasterror;
- if (thefile->filehand == INVALID_HANDLE_VALUE) {
- *nbytes = -1;
- return APR_EBADF;
- }
-
if (ReadFile(thefile->filehand, buf, *nbytes, &bread, NULL)) {
*nbytes = bread;
return APR_SUCCESS;
}
+ *nbytes = 0;
lasterror = GetLastError();
if (lasterror == ERROR_BROKEN_PIPE) {
/* Assume ERROR_BROKEN_PIPE signals an EOF reading from a pipe */
- *nbytes = 0;
return APR_SUCCESS;
+ } else if (lasterror == ERROR_NO_DATA) {
+ /* Receive this error on a read to a pipe in nonblocking mode */
+ return APR_EAGAIN;
}
- *nbytes = -1;
return lasterror;
}
@@ -94,11 +91,6 @@
DWORD bwrote;
FILETIME atime, mtime, ctime;
- if (thefile->filehand == INVALID_HANDLE_VALUE) {
- *nbytes = -1;
- return APR_EBADF;
- }
-
if (WriteFile(thefile->filehand, buf, *nbytes, &bwrote, NULL)) {
if (strcmp(thefile->fname, "PIPE")) {
FlushFileBuffers(thefile->filehand);
@@ -111,7 +103,7 @@
*nbytes = bwrote;
return APR_SUCCESS;
}
- (*nbytes) = -1;
+ (*nbytes) = 0;
return GetLastError();
}
/*