122 if (originalHost.
host)
134 if (originalHost.
port)
193 "cancel request is already being sent on this connection");
250 if (n < 0 && errno != 0)
375 conn,
"tcp_user_timeout"))
389 conn,
"keepalives_idle"))
396 conn,
"keepalives_interval"))
403 conn,
"keepalives_count"))
428 #if defined(TCP_USER_TIMEOUT) || !defined(WIN32)
434 if (setsockopt(
fd, protoid, optid, (
char *) &
value,
sizeof(
value)) < 0)
475 strlcpy(errbuf,
"PQcancel() -- no cancel object supplied", errbufsize);
487 strlcpy(errbuf,
"PQcancel() -- socket() failed: ", errbufsize);
488 goto cancel_errReturn;
501 if (cancel->
raddr.
addr.ss_family != AF_UNIX &&
507 strlcpy(errbuf,
"PQcancel() -- setsockopt(SO_KEEPALIVE) failed: ", errbufsize);
508 goto cancel_errReturn;
511 #ifdef PG_TCP_KEEPALIVE_IDLE
515 strlcpy(errbuf,
"PQcancel() -- setsockopt(" PG_TCP_KEEPALIVE_IDLE_STR
") failed: ", errbufsize);
516 goto cancel_errReturn;
524 strlcpy(errbuf,
"PQcancel() -- setsockopt(TCP_KEEPINTVL) failed: ", errbufsize);
525 goto cancel_errReturn;
533 strlcpy(errbuf,
"PQcancel() -- setsockopt(TCP_KEEPCNT) failed: ", errbufsize);
534 goto cancel_errReturn;
540 #ifdef SIO_KEEPALIVE_VALS
541 if (!pqSetKeepalivesWin32(tmpsock,
545 strlcpy(errbuf,
"PQcancel() -- WSAIoctl(SIO_KEEPALIVE_VALS) failed: ", errbufsize);
546 goto cancel_errReturn;
552 #ifdef TCP_USER_TIMEOUT
556 strlcpy(errbuf,
"PQcancel() -- setsockopt(TCP_USER_TIMEOUT) failed: ", errbufsize);
557 goto cancel_errReturn;
569 strlcpy(errbuf,
"PQcancel() -- connect() failed: ", errbufsize);
570 goto cancel_errReturn;
581 if (
send(tmpsock, (
char *) &crp,
sizeof(crp), 0) != (
int)
sizeof(crp))
586 strlcpy(errbuf,
"PQcancel() -- send() failed: ", errbufsize);
587 goto cancel_errReturn;
598 if (
recv(tmpsock, (
char *) &crp, 1, 0) < 0)
617 maxlen = errbufsize - strlen(errbuf) - 2;
629 bufp =
buf +
sizeof(
buf) - 1;
633 *(--bufp) = (
val % 10) +
'0';
637 memcpy(bufp,
"error ", 6);
638 strncat(errbuf, bufp, maxlen);
639 strcat(errbuf,
"\n");
672 "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)