Re: [INTERFACES] firewall crashes backend

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Ken J(dot) Wright" <ken(at)ori-ind(dot)com>
Cc: pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] firewall crashes backend
Date: 1999-09-08 23:05:57
Message-ID: 1503.936831957@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

"Ken J. Wright" <ken(at)ori-ind(dot)com> writes:
> When connecting to postgresql 6.5.1 through a socks5 firewall via ODBC, the
> following error occurs:
> ERROR: postmaster: StreamConnection: accept: No route to host
> Then the backend crashes.

Ken, here is a patch. I can't test it very well since I don't have any
easy way of provoking a failure at this stage of the connection. Would
you check it?

Line numbers are for 6.5, but it should apply against current with a
few lines' offset, if you are using current.

regards, tom lane

*** src/backend/libpq/pqcomm.c.orig Wed Jul 7 13:17:47 1999
--- src/backend/libpq/pqcomm.c Wed Sep 8 19:00:51 1999
***************
*** 339,344 ****
--- 339,348 ----
* the Postmaster uses select() to tell when the server master
* socket is ready for accept().
*
+ * NB: this can NOT call elog() because it is invoked in the postmaster,
+ * not in standard backend context. If we get an error, the best we can do
+ * is log it to stderr.
+ *
* RETURNS: STATUS_OK or STATUS_ERROR
*/
int
***************
*** 352,358 ****
(struct sockaddr *) & port->raddr,
&addrlen)) < 0)
{
! elog(ERROR, "postmaster: StreamConnection: accept: %m");
return STATUS_ERROR;
}

--- 356,362 ----
(struct sockaddr *) & port->raddr,
&addrlen)) < 0)
{
! perror("postmaster: StreamConnection: accept");
return STATUS_ERROR;
}

***************
*** 361,367 ****
if (getsockname(port->sock, (struct sockaddr *) & port->laddr,
&addrlen) < 0)
{
! elog(ERROR, "postmaster: StreamConnection: getsockname: %m");
return STATUS_ERROR;
}

--- 365,371 ----
if (getsockname(port->sock, (struct sockaddr *) & port->laddr,
&addrlen) < 0)
{
! perror("postmaster: StreamConnection: getsockname");
return STATUS_ERROR;
}

***************
*** 374,386 ****
pe = getprotobyname("TCP");
if (pe == NULL)
{
! elog(ERROR, "postmaster: getprotobyname failed");
return STATUS_ERROR;
}
if (setsockopt(port->sock, pe->p_proto, TCP_NODELAY,
&on, sizeof(on)) < 0)
{
! elog(ERROR, "postmaster: setsockopt failed: %m");
return STATUS_ERROR;
}
}
--- 378,390 ----
pe = getprotobyname("TCP");
if (pe == NULL)
{
! perror("postmaster: StreamConnection: getprotobyname");
return STATUS_ERROR;
}
if (setsockopt(port->sock, pe->p_proto, TCP_NODELAY,
&on, sizeof(on)) < 0)
{
! perror("postmaster: StreamConnection: setsockopt");
return STATUS_ERROR;
}
}

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Mark Gaschermann 1999-09-08 23:17:15 Re: [INTERFACES] PGACCESS formdemo.sql
Previous Message Ken J. Wright 1999-09-08 22:39:40 Re: [INTERFACES] firewall crashes backend