Re: statistics process shutting down

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: statistics process shutting down
Дата
Msg-id 6EE64EF3AB31D5448D0007DD34EEB3412A7545@Herge.rcsinc.local
обсуждение исходный текст
Ответ на statistics process shutting down  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
Ответы Re: statistics process shutting down  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers-win32
> 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

В списке pgsql-hackers-win32 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: statistics process shutting down
Следующее
От: Tom Lane
Дата:
Сообщение: Re: statistics process shutting down