Re: [INTERFACES] firewall crashes backend - Mailing list pgsql-interfaces

From Tom Lane
Subject Re: [INTERFACES] firewall crashes backend
Date
Msg-id 1503.936831957@sss.pgh.pa.us
Whole thread Raw
In response to firewall crashes backend  ("Ken J. Wright" <ken@ori-ind.com>)
Responses Re: [INTERFACES] firewall crashes backend
Re: [INTERFACES] firewall crashes backend
List pgsql-interfaces
"Ken J. Wright" <ken@ori-ind.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;         }     }


pgsql-interfaces by date:

Previous
From: "Ken J. Wright"
Date:
Subject: Re: [INTERFACES] firewall crashes backend
Next
From: Mark Gaschermann
Date:
Subject: Re: [INTERFACES] PGACCESS formdemo.sql