> -----Original Message-----
> From: Bruce Momjian [mailto:[EMAIL PROTECTED]]
> Sent: 11 February 2001 06:31
> To: PostgreSQL-development
> Cc: Dave Page; PostgreSQL odbc list; PostgreSQL-patches
> Subject: Re: [ODBC] RE: [PATCHES] Fix for ODBC close
> 
> 
> OK, I have a pretty good guess about the cause of the ODBC shutdown
> failure message in the server logs.  Sending 'X' is still causing the
> error message.
> 
> The error you are seeing is from the backend libpq code, the area that
> communicates with clients.
> 
> So, let's assume the problem is not the platform, but the 
> client code. 
> Libpq properly shuts connections without triggering that 
> message.  ODBC
> does trigger the message.
> 
> libpq closes connections with:
> 
>               (void) pqPuts("X", conn);
>               (void) pqFlush(conn);
> 
> while ODBC closes with:
> 
>               SOCK_put_char(self, 'X');
>               SOCK_flush_output(self);
> 
> They then close() the socket.
> 
> It seems the difference is in the flushing.  libpq has elaborate flush
> code:
> 
>       while (len > 0)
>       {
>                       sent = send(conn->sock, ptr, len, 0);
>                       len -= sent;
> 
>                       if (pqWait(FALSE, TRUE, conn))
>       }
> 
> and pqWait does:
> 
>               if (select(conn->sock + 1, &input_mask, 
> &output_mask, (fd_set *) NULL,
> 
> 
> For flush, ODBC does a simple:
> 
>       written = send(self->socket, (char *) self->buffer_out, 
> self->buffer_filled_out, 0);
> 
> 
> It seems we may need to add flush code similar to libpq in ODBC.
> 
> At a minimum, we have to put the send() in a loop and keep going until
> there are no more bytes to send.  Not sure the select() is required.
> 
> Comments?
> 
> After I receive comments, I will prepare a patch people can test.

Sounds reasonable though I must admit this isn't exactly my area of
expertise! I'll certainly test any patches though and make a .dll available
for others to try.

Regards,

Dave.

Reply via email to