GetPoolManagerHandle(void)
{
PoolHandle *handle;
- int fdsock;
+ int fdsock = -1;
if (poolHandle)
/* already connected */
}
#endif
- /* Allocate handle */
/*
+ * Actual connection errors should be reported by the block above,
+ * but perhaps we haven't actually executed it - either because
+ * the Unix_socket_directories is not set, or because there's no
+ * support for UNIX_SOCKETS. Just bail out in that case.
+ */
+ if (fdsock < 0)
+ ereport(ERROR,
+ (errmsg("failed to connect to pool manager: %m")));
+
+ /*
+ * Allocate handle
+ *
* XXX we may change malloc here to palloc but first ensure
* the CurrentMemoryContext is properly set.
* The handle allocated just before new session is forked off and
*/
handle = (PoolHandle *) malloc(sizeof(PoolHandle));
if (!handle)
- {
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
- }
handle->port.fdsock = fdsock;
handle->port.RecvLength = 0;