Re: [HACKERS] Re: [ODBC] RE: Fix for ODBC close - Mailing list pgsql-patches

From Tom Lane
Subject Re: [HACKERS] Re: [ODBC] RE: Fix for ODBC close
Date
Msg-id 6348.981915557@sss.pgh.pa.us
Whole thread Raw
In response to Re: [ODBC] RE: Fix for ODBC close  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-patches
+               SOCK_put_char(self, 'X');
+               SOCK_flush_output(self);
+               if (!shutdown(self->socket, 2)) /* no sends or receives */
                        closesocket(self->socket);

I think you should issue the close() whether the shutdown() succeeds or
not.  Otherwise you have a file descriptor leak.  In fact, given that
you're going to close the socket, the separate shutdown call is a
complete waste of cycles.  Take it out.

> Hiroshi, should I be concerned that a send() that does not send the full
> packet just returns an error and does not retry?  Is libpq() so complex
> because of async connections?

Right, libpq only needs to loop because it runs the socket in nonblock
mode.  SOCK_flush_output looks OK to me.  (SOCK_get_next_byte, on the
other hand, goes wacko on error or close... probably should make it
return a null character instead of random data.)

            regards, tom lane

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [ODBC] RE: Fix for ODBC close
Next
From: Dave Page
Date:
Subject: RE: [ODBC] RE: Fix for ODBC close