RE: [ODBC] RE: [PATCHES] Fix for ODBC close

From: Dave Page <dpage(at)vale-housing(dot)co(dot)uk>
To: "'Bruce Momjian'" <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Cc: Dave Page <dpage(at)vale-housing(dot)co(dot)uk>, PostgreSQL odbc list <pgsql-odbc(at)postgreSQL(dot)org>, PostgreSQL-patches <pgsql-patches(at)postgreSQL(dot)org>
Subject: RE: [ODBC] RE: [PATCHES] Fix for ODBC close
Date: 2001-02-11 19:17:45
Message-ID: 8568FC767B4AD311AC33006097BCD3D61A297C@woody.vale-housing.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-odbc pgsql-patches

> -----Original Message-----
> From: Bruce Momjian [mailto:pgman(at)candle(dot)pha(dot)pa(dot)us]
> 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.

Browse pgsql-hackers by date

  From Date Subject
Next Message Ryan Kirkpatrick 2001-02-11 22:03:33 Recovery of PGSQL after system crash failing!!!
Previous Message Tom Lane 2001-02-11 18:25:46 Re: ODBC backward versions

Browse pgsql-odbc by date

  From Date Subject
Next Message Dave Page 2001-02-11 19:28:22 RE: RE: [PATCHES] Re: [HACKERS] 6.2 protocol
Previous Message Tom Lane 2001-02-11 18:19:17 Re: Re: [ODBC] RE: [PATCHES] Fix for ODBC close

Browse pgsql-patches by date

  From Date Subject
Next Message Hiroshi Inoue 2001-02-12 00:59:16 Re: [ODBC] RE: [PATCHES] Fix for ODBC close
Previous Message Tom Lane 2001-02-11 18:19:17 Re: Re: [ODBC] RE: [PATCHES] Fix for ODBC close