Re: [PERFORM] [pgsql-hackers-win32] scalability issues on win32
"Magnus Hagander" <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.devel.patches,gmane.comp.db.postgresql.devel.win32 |
|---|---|
| Message-ID | <[email protected]> |
Attached patch solves the problem for me.Didn't see anything of the problem you described about hangs in my implementation. Probably because mine exits at the first sign of a linebreak. //Magnus >-----Original Message----- >From: [email protected] >[mailto:[email protected]] On Behalf Of >Claudio Natoli >Sent: den 17 december 2004 01:31 >To: Bruce Momjian >Cc: Merlin Moncure; Tom Lane; Win 32 hackers PGSQL >Subject: Re: [PERFORM] [pgsql-hackers-win32] scalability >issues on win32 > > > >Hi Bruce and all, > >sorry guys, I won't have a chance to get to this until after >the Christmas break. > >If one of the other usual suspects (Dave, Andrew, Magnus, >Merlin) can claim it sooner, please do! > >Cheers, >Claudio > > > >> -----Original Message----- >> From: Bruce Momjian [mailto:[email protected]] >> Sent: Friday, 17 December 2004 11:25 AM >> To: Claudio Natoli >> Cc: 'Merlin Moncure'; Tom Lane; Win 32 hackers PGSQL >> Subject: Re: [PERFORM] [pgsql-hackers-win32] scalability >> issues on win32 >> >> >> >> Claudio, I need this completed so we can get it into CVS. >> Without it a >> 8.0.0 version string will fail to compare. >> >> -------------------------------------------------------------- >> ------------- >> >> Claudio Natoli wrote: >> > >> > Hi Merlin, >> > >> > > On a probably unrelated note: >> > > Can some other win32 hacker try the following? >> > > Download the latest cvs sources from the server and edit >> configure, >> > > replacing all instances of '8.0beta5' with '8.0' etc. as is >> > > will be when released. Following that do a full >> make/make clean. After >> > > that try and start he server with pg_ctl.exe and tell me >> if it succeeds or >> > not. >> > >> > I can confirm this failure. >> > >> > (in my case at least) pg_ctl is not seeing the full version >> string of the >> > postmaster in find_other_exec. This is due to the single >> call to ReadFile in >> > pipe_read_line, which is not returning the entire version >> string (losing all >> > characters beyond the last decimal point in the version string). A >> > subsequent call to ReadFile picks up the remainder of the >> string. I don't >> > see that we can rely on a single call returning the entire >> version string. >> > >> > If someone can run with this, I've attached initial looping >> changes for >> > pipe_read_line. However I'm not sure of the correct >> terminating condition >> > (gets into a call to ReadFile that never returns; the >> WaitForSingleObject >> > appears insufficient as a precondition for ReadFile) and >> just don't have >> > time to complete it right now. >> > >> > Cheers, >> > Claudio >> > ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [email protected] so that your message can get through to the mailing list cleanly
exec_pipe.patch
(application/octet-stream, 2.2 KB)
Index: port/exec.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/port/exec.c,v
retrieving revision 1.33
diff -c -r1.33 exec.c
*** port/exec.c 27 Nov 2004 22:44:15 -0000 1.33
--- port/exec.c 19 Dec 2004 15:42:04 -0000
***************
*** 486,516 ****
&si,
&pi))
{
- DWORD bytesread = 0;
-
/* Successfully started the process */
ZeroMemory(line, maxsize);
! /* Let's see if we can read */
! if (WaitForSingleObject(childstdoutrddup, 10000) != WAIT_OBJECT_0)
{
! /* Got timeout */
! CloseHandle(pi.hProcess);
! CloseHandle(pi.hThread);
! CloseHandle(childstdoutwr);
! CloseHandle(childstdoutrddup);
! return NULL;
}
! /* We try just once */
! if (ReadFile(childstdoutrddup, line, maxsize, &bytesread, NULL) &&
! bytesread > 0)
{
/* So we read some data */
! int len = strlen(line);
retval = line;
/*
* If EOL is \r\n, convert to just \n. Because stdout is a
* text-mode stream, the \n output by the child process is
--- 486,531 ----
&si,
&pi))
{
/* Successfully started the process */
+ char *lineptr;
ZeroMemory(line, maxsize);
! /* Read at least one line from the pipe */
! for (lineptr = line;lineptr < line+maxsize-1;)
{
! DWORD bytesread = 0;
!
! /* Let's see if we can read */
! if (WaitForSingleObject(childstdoutrddup, 10000) != WAIT_OBJECT_0)
! /* Got timeout, but perhaps we got a line already */
! break;
!
! if (!ReadFile(childstdoutrddup, lineptr, maxsize-(lineptr-line), &bytesread, NULL))
! break; /* Error occurred, but perhaps we got a line already */
!
! lineptr += strlen(lineptr);
!
! if (!bytesread)
! break; /* EOF */
!
! if (strchr(line, '\n'))
! break; /* One or more lines read */
}
! if (lineptr != line)
{
/* So we read some data */
! int len;
retval = line;
+ /* If we got more than one line, cut off after the first \n */
+ lineptr = strchr(line,'\n');
+ if (lineptr)
+ *(lineptr+1) = 0;
+
+ len = strlen(line);
+
/*
* If EOL is \r\n, convert to just \n. Because stdout is a
* text-mode stream, the \n output by the child process is