help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Postgres and blocked poll


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] Postgres and blocked poll
Date: Thu, 21 Apr 2011 12:47:13 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.9

On 04/21/2011 12:15 PM, Holger Hans Peter Freyther wrote:
Hi Paolo,

I have one more issue with the Postgres DBI driver. In case of the VPN
vanishing (or suspend/resume my laptop) the next database query will call
PQgetResult which will block in poll forever.

According to the Postgres documentation one can get the socket from the
connection, use the PQconsumeInput to make PQ read it and there is something
like PQisbusy.

Now the question is how to integrate this. Whenever executing a query I could
greate a FileDescriptor, wait until it is readable, call PQconsumeInput..

[
    PQisBusy..
] whileFalse: [
    (FileDescriptor on: connection socket) ensureReadable.
    PQConsumeInput..
].

Does this sound okay?

Yes, it does, though it should be a SocketImpl, not a FileDescriptor. Also, you need to make it non-finalized, or alternatively you can store it in an instance variable (preferred, probably). That would be

...
   socket := Sockets.SocketImpl on: connection pqSocket
...
   [
       socket ensureReadable.
       connection consumeInput; isBusy
   ] whileTrue

Nice API! :)

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]