From: | "E(dot)E(dot) Mellor" <eem21(at)cam(dot)ac(dot)uk> |
---|---|
To: | Roberto Joao Lopes Garcia <roberto(at)mha(dot)com(dot)br> |
Cc: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: [INTERFACES] libpq + multiple connections ... |
Date: | 1999-11-30 12:08:23 |
Message-ID: | Pine.SOL.4.10a.9911301205550.5846-100000@red.csi.cam.ac.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
On Mon, 29 Nov 1999, Roberto Joao Lopes Garcia wrote:
> >> safely run two PQconnectdb() calls in parallel. But you can open two
> >> connections in sequence and then use them in parallel;
> >
>
> So I could open, for exemple, 5 db connections (with PQconnectdb()) and
> then create 5 threads and use those connections in eache thread. But how
> about use PQreset() or PQfinish() inside the new created threads?
>
> I used to test connection before send a query like bellow:
>
> if(PQstatus(con)==CONNECTION_BAD) {
> PQreset(con);
> if(PQstatus(con)==CONNECTION_BAD) erro_fatal();
> }
>
> Should I protect the calls to those functions by an mutex?? Could it
> work??? Which functions read or alter Qconnectdb()'s static array??
You cannot mix calls to _any_ of PQconnectdb, PQreset, or their
newly-added asynchronous analogues in a thread-safe manner. You need to
use a mutex to protect the calls above.
> I think it is important to mark wich functions in Libpq is thread safe or
> not.
I agree. I'll add a note to that effect to the docs today.
Ewan.
From | Date | Subject | |
---|---|---|---|
Next Message | E.E. Mellor | 1999-11-30 12:12:42 | Re: [INTERFACES] Asynchronous connection functions - patch submitted |
Previous Message | Michael Meskes | 1999-11-30 10:27:58 | Re: [INTERFACES] Asynchronous connection functions - patch submitted |