Re: Streaming replication and unfit messages - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Streaming replication and unfit messages
Date
Msg-id 3f0b79eb1002180231xcf6ea2bta9b793bb0e1b6627@mail.gmail.com
Whole thread Raw
In response to Re: Streaming replication and unfit messages  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Responses Re: Streaming replication and unfit messages
List pgsql-hackers
On Thu, Feb 18, 2010 at 7:05 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:
> Magnus Hagander wrote:
>> This cannot possibly be correct:
>> +                     if (errno == EAGAIN || EWOULDBLOCK || errno == EINTR)
>>
>>
>> The middle argument is missing the errno== part.
>
> Ahh, rats. Yeah it clearly is. Thanks.

Thanks for the patch! This seems nicer than mine.
  * The received byte is stored in *c. Returns 1 if a byte was read, 0 if
!  * if no data was available, or EOF if trouble.

Typo. 'if' is repeated.


+                 ereport(COMMERROR,
+                         (errcode_for_socket_access(),
+                          errmsg("could not receive data from client: %m")));
+                 return EOF;

We should use "r = EOF" instead of "return EOF" as well as other cases?


In WalSndHandshake(), when pq_getbyte() returns EOF, the COMMERROR message
"unexpected EOF on standby connection" is emitted doubly. How about removing
first COMMERROR message?

     r = pq_getbyte_if_available(&firstchar);     if (r < 0)     {
!         /* unexpected error */         ereport(COMMERROR,
!                 (errcode(ERRCODE_PROTOCOL_VIOLATION),
!                  errmsg("unexpected EOF on standby connection")));
!         proc_exit(0);     }

Since pq_getbyte_if_available() returns EOF if trouble, "r == EOF" should
be used instead of "r < 0"?

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: A thought: should we run pgindent now?
Next
From: Dimitri Fontaine
Date:
Subject: Re: PostgreSQL::PLPerl::Call - Simple interface for calling SQL functions from PostgreSQL PL/Perl