Обсуждение: BUG #4602: child processes inherit database socket

Поиск
Список
Период
Сортировка

BUG #4602: child processes inherit database socket

От
"Jasen Betts"
Дата:
The following bug has been logged online:

Bug reference:      4602
Logged by:          Jasen Betts
Email address:      jasen@treshna.com
PostgreSQL version: 8.3
Operating system:   linux
Description:        child processes inherit database socket
Details:

libpq creates sockets to the server without CLOEXEC.

as a result child processes inherit instances of the database socket

this wastes resources, and in some cases seems to keep the backend around
after the client has expired.

unless there's a reaon why duplicating the sockets is useful it can be
stopped like this:

  {
  int dflags =  fcntl( socket_fd, F_GETFD );
  fcntl( socket_fd, F_SETFD , dflags | CLOEXEC );
  }

Re: BUG #4602: child processes inherit database socket

От
Tom Lane
Дата:
"Jasen Betts" <jasen@treshna.com> writes:
> libpq creates sockets to the server without CLOEXEC.

Only if you have a very broken build; see fe-connect.c around line 1160
(in CVS HEAD, but the fcntl() has been there for many years).

Perhaps what you really meant to say is "for some reason the fcntl
call isn't getting compiled in on my platform", but with no platform
details it's impossible for us to do anything about that.

            regards, tom lane