Re: [PATCH] Allow breaking out of hung connection attempts

From: Ryan Kelly <rpkelly22(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Allow breaking out of hung connection attempts
Date: 2012-01-09 13:49:25
Message-ID: 20120109134925.GA32189@llserver.lakeliving.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jan 09, 2012 at 10:35:50AM +0200, Heikki Linnakangas wrote:
> On 08.01.2012 22:18, Ryan Kelly wrote:
> >@@ -1570,7 +1570,13 @@ do_connect(char *dbname, char *user, char *host, char *port)
> > keywords[7] = NULL;
> > values[7] = NULL;
> >
> >- n_conn = PQconnectdbParams(keywords, values, true);
> >+ if (sigsetjmp(sigint_interrupt_jmp, 1) != 0) {
> >+ /* got here with longjmp */
> >+ } else {
> >+ sigint_interrupt_enabled = true;
> >+ n_conn = PQconnectdbParams(keywords, values, true);
> >+ sigint_interrupt_enabled = false;
> >+ }
> >
> > free(keywords);
> > free(values);
>
> That assumes that it's safe to longjmp out of PQconnectdbParams at
> any instant. It's not.
I'm guessing because it could result in a resource leak?

> I think you'd need to use the asynchronous connection functions
> PQconnectStartParams() and PQconnectPoll(), and select().
New patch attached.

>
> --
> Heikki Linnakangas
> EnterpriseDB http://www.enterprisedb.com

-Ryan Kelly

Attachment Content-Type Size
async.patch text/x-diff 3.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2012-01-09 14:29:27 Re: Moving more work outside WALInsertLock
Previous Message Simon Riggs 2012-01-09 13:44:52 Re: Moving more work outside WALInsertLock