122 if (originalHost.
host)
134 if (originalHost.
port)
193 "cancel request is already being sent on this connection");
250 if (n < 0 && errno != 0)
376 conn,
"tcp_user_timeout"))
390 conn,
"keepalives_idle"))
397 conn,
"keepalives_interval"))
404 conn,
"keepalives_count"))
429 #if defined(TCP_USER_TIMEOUT) || !defined(WIN32)
435 if (setsockopt(
fd, protoid, optid, (
char *) &
value,
sizeof(
value)) < 0)
476 strlcpy(errbuf,
"PQcancel() -- no cancel object supplied", errbufsize);
488 strlcpy(errbuf,
"PQcancel() -- socket() failed: ", errbufsize);
489 goto cancel_errReturn;
502 if (cancel->
raddr.
addr.ss_family != AF_UNIX &&
508 strlcpy(errbuf,
"PQcancel() -- setsockopt(SO_KEEPALIVE) failed: ", errbufsize);
509 goto cancel_errReturn;
512 #ifdef PG_TCP_KEEPALIVE_IDLE
516 strlcpy(errbuf,
"PQcancel() -- setsockopt(" PG_TCP_KEEPALIVE_IDLE_STR
") failed: ", errbufsize);
517 goto cancel_errReturn;
525 strlcpy(errbuf,
"PQcancel() -- setsockopt(TCP_KEEPINTVL) failed: ", errbufsize);
526 goto cancel_errReturn;
534 strlcpy(errbuf,
"PQcancel() -- setsockopt(TCP_KEEPCNT) failed: ", errbufsize);
535 goto cancel_errReturn;
541 #ifdef SIO_KEEPALIVE_VALS
542 if (!pqSetKeepalivesWin32(tmpsock,
546 strlcpy(errbuf,
"PQcancel() -- WSAIoctl(SIO_KEEPALIVE_VALS) failed: ", errbufsize);
547 goto cancel_errReturn;
553 #ifdef TCP_USER_TIMEOUT
557 strlcpy(errbuf,
"PQcancel() -- setsockopt(TCP_USER_TIMEOUT) failed: ", errbufsize);
558 goto cancel_errReturn;
570 strlcpy(errbuf,
"PQcancel() -- connect() failed: ", errbufsize);
571 goto cancel_errReturn;
582 if (
send(tmpsock, (
char *) &crp,
sizeof(crp), 0) != (
int)
sizeof(crp))
587 strlcpy(errbuf,
"PQcancel() -- send() failed: ", errbufsize);
588 goto cancel_errReturn;
599 if (
recv(tmpsock, (
char *) &crp, 1, 0) < 0)
618 maxlen = errbufsize - strlen(errbuf) - 2;
630 bufp =
buf +
sizeof(
buf) - 1;
634 *(--bufp) = (
val % 10) +
'0';
638 memcpy(bufp,
"error ", 6);
639 strncat(errbuf, bufp, maxlen);
640 strcat(errbuf,
"\n");
673 "PQrequestCancel() -- connection is not open\n",
static PGcancel *volatile cancelConn
PGcancel * PQgetCancel(PGconn *conn)
void PQcancelReset(PGcancelConn *cancelConn)
PGcancelConn * PQcancelCreate(PGconn *conn)
ConnStatusType PQcancelStatus(const PGcancelConn *cancelConn)
static bool optional_setsockopt(int fd, int protoid, int optid, int value)
int PQcancelBlocking(PGcancelConn *cancelConn)
int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
char * PQcancelErrorMessage(const PGcancelConn *cancelConn)
PostgresPollingStatusType PQcancelPoll(PGcancelConn *cancelConn)
void PQcancelFinish(PGcancelConn *cancelConn)
int PQrequestCancel(PGconn *conn)
void PQfreeCancel(PGcancel *cancel)
int PQcancelSocket(const PGcancelConn *cancelConn)
int PQcancelStart(PGcancelConn *cancelConn)
bool pqConnectOptions2(PGconn *conn)
void pqClosePGconn(PGconn *conn)
PostgresPollingStatusType PQconnectPoll(PGconn *conn)
bool pqParseIntParam(const char *value, int *result, PGconn *conn, const char *context)
void pqReleaseConnHosts(PGconn *conn)
char * PQerrorMessage(const PGconn *conn)
ConnStatusType PQstatus(const PGconn *conn)
PGconn * pqMakeEmptyPGconn(void)
void PQfinish(PGconn *conn)
int pqConnectDBStart(PGconn *conn)
bool pqCopyPGconn(PGconn *srcConn, PGconn *dstConn)
int PQsocket(const PGconn *conn)
int pqConnectDBComplete(PGconn *conn)
int pqReadData(PGconn *conn)
void libpq_append_conn_error(PGconn *conn, const char *fmt,...)
@ CONNECTION_AWAITING_RESPONSE
PostgresPollingStatusType
#define SOCK_ERRNO_SET(e)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define CANCEL_REQUEST_CODE
void resetPQExpBuffer(PQExpBuffer str)
static int fd(const char *x, int i)
struct sockaddr_storage addr
char * keepalives_interval
char * pgtcp_user_timeout
PQExpBufferData errorMessage
#define recv(s, buf, len, flags)
#define send(s, buf, len, flags)
#define socket(af, type, protocol)
#define connect(s, name, namelen)