Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: statistics process shutting down


  • From: "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com>
  • To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • Cc: "Win 32 hackers PGSQL" <pgsql-hackers-win32(at)postgresql(dot)org>
  • Subject: Re: statistics process shutting down
  • Date: Tue, 30 Nov 2004 13:26:05 -0500
  • Message-id: <6EE64EF3AB31D5448D0007DD34EEB3412A7545(at)Herge(dot)rcsinc(dot)local>

> Evidently coming from here:
> 
>         len = piperead(readPipe, ((char *) &msg) + nread,
>                        targetlen - nread);
>         if (len < 0)
>         {
>             if (errno == EINTR)
>                 continue;
>             ereport(ERROR,
>                     (errcode_for_socket_access(),
>                      errmsg("could not read from statistics collector
> pipe: %m")));
>         }
> 
> So why is piperead() failing, and why doesn't it set errno to
something
> useful?

Well, the win32 piperead() is really just a call to recv() (vs unix
read()).  Here is the win32 implemenation:
int
piperead(int s, char *buf, int len)
{
	int			ret = recv(s, buf, len, 0);

	if (ret < 0 && WSAGetLastError() == WSAECONNRESET)
		/* EOF on the pipe! (win32 socket based implementation)
*/
		ret = 0;
	return ret;
}

I think the key to this puzzle is the return code from
WSAGetLastError().  Also, the WSA call *might* be masking the value of
errno.  I did a quick search and came up with this:
http://archives.postgresql.org/pgsql-patches/2001-10/msg00160.php

I think maybe errno needs to get set to WSAGetLastError().  In pipe.c:

if (ret < 0)
{
   int  wsa_errno;
   wsa_errno = WSAGetLastError();

   if (WSAECONNRESET == wsa_errno)
   {   /* EOF on the pipe! (win32 socket based implementation) */
      ret = 0;
   }
   else
   {
      errno = wsa_errno;  /* this *might* be ok */
   }
}

return ret;

Maybe Magnus might comment here.  This doesn't explain why the read call
is failing but I'm pretty sure the error code is not being properly
returned.

Merlin



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group