Return-Path: Delivered-To: new-httpd-archive@hyperreal.org Received: (qmail 28885 invoked by uid 6000); 22 Jul 1999 02:14:14 -0000 Received: (qmail 28828 invoked from network); 22 Jul 1999 02:14:12 -0000 Received: from ns1.covalent.net (HELO zuul.interlinksystems.com) (208.214.56.2) by taz.hyperreal.org with SMTP; 22 Jul 1999 02:14:12 -0000 Received: from blanca (98CC3A2C.ipt.aol.com [152.204.58.44]) by zuul.interlinksystems.com (8.9.1/8.9.1) with SMTP id VAA09568 for ; Wed, 21 Jul 1999 21:14:03 -0500 (CDT) (envelope-from randy@covalent.net) From: "Randy Terbush" To: Subject: RE: [PATCH] Allow non-buffered cgi's on NT. Date: Wed, 21 Jul 1999 21:13:56 -0500 Message-ID: <005001bed3e7$da07c140$0502a8c0@covalent.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2377.0 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 In-Reply-To: Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org +1 > -----Original Message----- > From: new-httpd-owner@apache.org > [mailto:new-httpd-owner@apache.org]On > Behalf Of Ryan Bloom > Sent: Sunday, July 11, 1999 8:49 PM > To: new-httpd@apache.org > Subject: [PATCH] Allow non-buffered cgi's on NT. > > > > I am including a patch to allow non-buffered cgi's on NT. > This does not > work on 95/98, and never will. In order to do this, we > have to use named > Pipes, and 9X doesn't support this featuer. I would like > to see this in > 1.3.7. > > Ryan > > ? src/support/Debug > ? src/support/htdigest.pch > ? src/support/htdigest.pdb > ? src/support/vc50.idb > ? src/support/vc50.pdb > Index: src/main/alloc.c > =================================================================== > RCS file: /home/cvs/apache-1.3/src/main/alloc.c,v > retrieving revision 1.113 > diff -u -r1.113 alloc.c > --- alloc.c 1999/05/25 15:32:54 1.113 > +++ alloc.c 1999/07/12 01:55:46 > @@ -68,6 +68,10 @@ > > #include > > +#ifdef WIN32 > +#include > +#endif > + > #ifdef OS2 > #define INCL_DOS > #include > @@ -2380,6 +2384,7 @@ > BUFF **pipe_in, BUFF > **pipe_out, BUFF **pipe_err) > { > #ifdef WIN32 > + OSVERSIONINFO oslev; > SECURITY_ATTRIBUTES sa = {0}; > HANDLE hPipeOutputRead = NULL; > HANDLE hPipeOutputWrite = NULL; > @@ -2393,7 +2398,11 @@ > HANDLE hCurrentProcess; > pid_t pid = 0; > child_info info; > + char *pipename; > + char mytid[6]; > > + oslev.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); > + GetVersionEx(&oslev); > > ap_block_alarms(); > > @@ -2407,28 +2416,29 @@ > > > /* Create pipes for standard input/output/error redirection. */ > - if (pipe_in && !CreatePipe(&hPipeInputRead, > &hPipeInputWrite, &sa, 0)) > - return 0; > - > - if (pipe_out && !CreatePipe(&hPipeOutputRead, > &hPipeOutputWrite, &sa, 0)) { > - if(pipe_in) { > - CloseHandle(hPipeInputRead); > - CloseHandle(hPipeInputWrite); > - } > - return 0; > - } > - > - if (pipe_err && !CreatePipe(&hPipeErrorRead, > &hPipeErrorWrite, &sa, 0)) { > - if(pipe_in) { > - CloseHandle(hPipeInputRead); > - CloseHandle(hPipeInputWrite); > - } > - if(pipe_out) { > - CloseHandle(hPipeOutputRead); > - CloseHandle(hPipeOutputWrite); > - } > - return 0; > - } > + if (oslev.dwPlatformId != VER_PLATFORM_WIN32_NT) { > + /* We are on 95 or 98, must use anonymous pipes */ > + if (pipe_in && !CreatePipe(&hPipeInputRead, > &hPipeInputWrite, &sa, 0)) > + return 0; > + > + if (pipe_out && !CreatePipe(&hPipeOutputRead, > &hPipeOutputWrite, &sa, 0)) { > + if(pipe_in) { > + CloseHandle(hPipeInputRead); > + CloseHandle(hPipeInputWrite); > + } > + return 0; > + } > + if (pipe_err && !CreatePipe(&hPipeErrorRead, > &hPipeErrorWrite, &sa, 0)) { > + if(pipe_in) { > + CloseHandle(hPipeInputRead); > + CloseHandle(hPipeInputWrite); > + } > + if(pipe_out) { > + CloseHandle(hPipeOutputRead); > + CloseHandle(hPipeOutputWrite); > + } > + return 0; > + } > /* > * When the pipe handles are created, the security descriptor > * indicates that the handle can be inherited. > However, we do not > @@ -2440,6 +2450,9 @@ > * sides of the pipes, and no I/O error will occur. Microsoft > * recommends using DuplicateHandle to turn off the inherit bit > * under NT and Win95. > + * No need to do this on NT anymore, because we are > using Named pipes, so we can > + * Just define the server side to be non-inheritable, > and the client side inheritable > + * So, we put this section in the 95/98 statements. > */ > hCurrentProcess = GetCurrentProcess(); > if ((pipe_in && !DuplicateHandle(hCurrentProcess, > hPipeInputWrite, > @@ -2480,6 +2493,79 @@ > hPipeErrorRead = hPipeErrorReadDup; > } > } > + > + } > + else { > + /* We are on NT, we can use Named pipes for > non-blocking I/O. */ > + pipename = ap_palloc(p, 20); > + > + itoa(GetCurrentThreadId(), mytid, 10); > + if (pipe_in) { > + pipename = ap_pstrcat(p, > "\\\\.\\pipe\\INCGIPIPE", mytid, NULL); > + hPipeInputWrite = CreateNamedPipe(pipename, > PIPE_ACCESS_OUTBOUND, > + > PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT, 1, > 8024, 8024, 0, NULL); > + if (hPipeInputWrite == INVALID_HANDLE_VALUE) { > + return 0; > + } > + hPipeInputRead = CreateFile(pipename, > GENERIC_READ, 0, &sa, OPEN_EXISTING, > + 0, NULL); > + if (hPipeInputRead == INVALID_HANDLE_VALUE) { > + return 0; > + } > + } > + > + if (pipe_out) { > + pipename = ap_pstrcat(p, > "\\\\.\\pipe\\OUTCGIPIPE", mytid, NULL); > + hPipeOutputRead = CreateNamedPipe(pipename, > PIPE_ACCESS_INBOUND, > + > PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT, 1, > 8024, 8024, 0, NULL); > + if (hPipeOutputRead == INVALID_HANDLE_VALUE) { > + if(pipe_in) { > + CloseHandle(hPipeInputRead); > + CloseHandle(hPipeInputWrite); > + } > + return 0; > + } > + hPipeOutputWrite = CreateFile(pipename, > GENERIC_WRITE, 0, &sa, OPEN_EXISTING, > + 0, NULL); > + if (hPipeInputRead == INVALID_HANDLE_VALUE) { > + if(pipe_in) { > + CloseHandle(hPipeInputRead); > + CloseHandle(hPipeInputWrite); > + } > + return 0; > + } > + } > + > + if (pipe_err) { > + pipename = ap_pstrcat(p, > "\\\\.\\pipe\\ERRCGIPIPE", mytid, NULL); > + hPipeErrorRead = CreateNamedPipe(pipename, > PIPE_ACCESS_INBOUND, > + > PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT, 1, > 8024, 8024, 0, NULL); > + if (hPipeErrorRead == INVALID_HANDLE_VALUE) { > + if(pipe_in) { > + CloseHandle(hPipeInputRead); > + CloseHandle(hPipeInputWrite); > + } > + if(pipe_out) { > + CloseHandle(hPipeOutputRead); > + CloseHandle(hPipeOutputWrite); > + } > + return 0; > + } > + hPipeErrorWrite = CreateFile(pipename, > GENERIC_WRITE, 0, &sa, OPEN_EXISTING, > + 0, NULL); > + if (hPipeErrorWrite == INVALID_HANDLE_VALUE) { > + if(pipe_in) { > + CloseHandle(hPipeInputRead); > + CloseHandle(hPipeInputWrite); > + } > + if(pipe_out) { > + CloseHandle(hPipeOutputRead); > + CloseHandle(hPipeOutputWrite); > + } > + return 0; > + } > + } > + } /* done creating pipes on NT :) */ > > /* The script writes stdout to this pipe handle */ > info.hPipeOutputWrite = hPipeOutputWrite; > Index: src/main/buff.c > =================================================================== > RCS file: /home/cvs/apache-1.3/src/main/buff.c,v > retrieving revision 1.87 > diff -u -r1.87 buff.c > --- buff.c 1999/04/27 20:36:30 1.87 > +++ buff.c 1999/07/12 01:55:50 > @@ -237,8 +237,14 @@ > > #ifdef WIN32 > if (fb->hFH != INVALID_HANDLE_VALUE) { > - if (!ReadFile(fb->hFH,buf,nbyte,&rv,NULL)) > + if (!ReadFile(fb->hFH,buf,nbyte,&rv,NULL)) { > rv = -1; > + while (rv == -1 && GetLastError() == ERROR_NO_DATA) { > + if (!ReadFile(fb->hFH,buf,nbyte,&rv,NULL)) { > + rv = -1; > + } > + } > + } > } > else > #endif > > ____________________________________________________________ > ___________ > Ryan Bloom rbb@raleigh.ibm.com > 4205 S Miami Blvd > RTP, NC 27709 It's a beautiful sight to see good dancers > doing simple steps. It's a painful sight to > see beginners doing complicated patterns. >