From: | Richi Plana <richip(at)mozcom(dot)com> |
---|---|
To: | M Simms <grim(at)argh(dot)demon(dot)co(dot)uk> |
Cc: | pgsql-general(at)postgreSQL(dot)org |
Subject: | Re: [GENERAL] fork() bad |
Date: | 1999-03-22 15:48:00 |
Message-ID: | Pine.LNX.4.04.9903222343560.418-100000@jaguar.mozcom.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
On Mon, 22 Mar 1999, M Simms wrote:
|o| > My process establishes a connection with a PostgreSQL backen and then
|o| > fork()s (twice, actually). To make things even more complicated (though I
|o| > don't know if it affects things), my connection handle is a global
|o| > variable in a dynamically-loaded shared object.
|o| >
|o| > I tried PQreset()ing the connections after forking and then I'd try a
|o| > begin but I'd get the ff.:
|o| If you fork, you will have two processes pumping data down the
|o| same connection to the database, cos the fork() will simply
|o| duplicate the file descriptor reference, not make you a new
|o| connection. If two forked() processes try and send data or
|o| retrieve data at the same time, everything will break, as the
|o| database obviously will not know what the hell is going on and
|o| will get a mangled transmission
Looks like the general consensus is fork()ing is a bad thing where
PostgreSQL is concerned. So what I did was refrained from opening a
connection to the backend until AFTER the process fork()ed.
As some of you may know, I'm hacking Ascend RADIUS 2.01 to look up a
PostgreSQL database for authentication and log to PG for accounting.
Normally, RADIUS fork()s once for Accounting and fork()s for each
Authentication request. That's a lot of fork()ing and establishing
connections to the backend. It's slow, but it's better than junking
whatever code I've written so far.
If anyone can give a better suggestion, I'm all ears. Also, if anyone
wants the code when it's done, try asking. ;^)
L L Richi Plana 8^) ,-,-. ,-,-. ,-,-. ,-,-. ,-
LL LL Systems Administrator / / \ \ / / \ \ / / \ \ / / \ \ / /
LLLLL Mosaic Communications, Inc. \ \ / / \ \ / / \ \ / / \ \ / /
LLLLL mailto:richip(at)mozcom(dot)com `-'-' `-'-' `-'-' `-'-'
------------------------------------------------------------------------
P G P Key available at http://www2.mozcom.com/~richip/richip.asc
Tired of Spam? Join this CAUCE! http://www.cauce.org/
From | Date | Subject | |
---|---|---|---|
Next Message | Herouth Maoz | 1999-03-22 16:02:34 | Re: [GENERAL] fork() bad |
Previous Message | M Simms | 1999-03-22 14:08:51 | Re: [GENERAL] fork() bad |