140 if (originalHost.
host)
152 if (originalHost.
port)
211 "cancel request is already being sent on this connection");
268 if (n < 0 && errno != 0)
400 conn,
"tcp_user_timeout"))
414 conn,
"keepalives_idle"))
421 conn,
"keepalives_interval"))
428 conn,
"keepalives_count"))
496#if defined(TCP_USER_TIMEOUT) || !defined(WIN32)
502 if (setsockopt(
fd, protoid, optid, (
char *) &
value,
sizeof(
value)) < 0)
540 strlcpy(errbuf,
"PQcancel() -- no cancel object supplied", errbufsize);
552 strlcpy(errbuf,
"PQcancel() -- socket() failed: ", errbufsize);
553 goto cancel_errReturn;
566 if (cancel->
raddr.
addr.ss_family != AF_UNIX &&
572 strlcpy(errbuf,
"PQcancel() -- setsockopt(SO_KEEPALIVE) failed: ", errbufsize);
573 goto cancel_errReturn;
576#ifdef PG_TCP_KEEPALIVE_IDLE
580 strlcpy(errbuf,
"PQcancel() -- setsockopt(" PG_TCP_KEEPALIVE_IDLE_STR
") failed: ", errbufsize);
581 goto cancel_errReturn;
589 strlcpy(errbuf,
"PQcancel() -- setsockopt(TCP_KEEPINTVL) failed: ", errbufsize);
590 goto cancel_errReturn;
598 strlcpy(errbuf,
"PQcancel() -- setsockopt(TCP_KEEPCNT) failed: ", errbufsize);
599 goto cancel_errReturn;
605#ifdef SIO_KEEPALIVE_VALS
606 if (!pqSetKeepalivesWin32(tmpsock,
610 strlcpy(errbuf,
"PQcancel() -- WSAIoctl(SIO_KEEPALIVE_VALS) failed: ", errbufsize);
611 goto cancel_errReturn;
617#ifdef TCP_USER_TIMEOUT
621 strlcpy(errbuf,
"PQcancel() -- setsockopt(TCP_USER_TIMEOUT) failed: ", errbufsize);
622 goto cancel_errReturn;
634 strlcpy(errbuf,
"PQcancel() -- connect() failed: ", errbufsize);
635 goto cancel_errReturn;
646 if (
send(tmpsock, (
char *) &cancel->
cancel_pkt_len, cancel_pkt_len, 0) != cancel_pkt_len)
651 strlcpy(errbuf,
"PQcancel() -- send() failed: ", errbufsize);
652 goto cancel_errReturn;
663 if (
recv(tmpsock, &recvbuf, 1, 0) < 0)
682 maxlen = errbufsize - strlen(errbuf) - 2;
694 bufp =
buf +
sizeof(
buf) - 1;
698 *(--bufp) = (
val % 10) +
'0';
702 memcpy(bufp,
"error ", 6);
703 strncat(errbuf, bufp, maxlen);
704 strcat(errbuf,
"\n");
737 "PQrequestCancel() -- connection is not open\n",
#define FLEXIBLE_ARRAY_MEMBER
static PGcancel *volatile cancelConn
PGcancel * PQgetCancel(PGconn *conn)
void PQcancelReset(PGcancelConn *cancelConn)
int PQsendCancelRequest(PGconn *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)
PostgresPollingStatusType PQcancelPoll(PGcancelConn *cancelConn)
void PQcancelFinish(PGcancelConn *cancelConn)
int PQrequestCancel(PGconn *conn)
void PQfreeCancel(PGcancel *cancel)
int PQcancelSocket(const PGcancelConn *cancelConn)
char * PQcancelErrorMessage(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)
ConnStatusType PQstatus(const PGconn *conn)
void PQfinish(PGconn *conn)
PGconn * pqMakeEmptyPGconn(void)
int pqConnectDBStart(PGconn *conn)
bool pqCopyPGconn(PGconn *srcConn, PGconn *dstConn)
char * PQerrorMessage(const PGconn *conn)
int PQsocket(const PGconn *conn)
int pqConnectDBComplete(PGconn *conn)
int pqReadData(PGconn *conn)
int pqFlush(PGconn *conn)
int pqPutMsgStart(char msg_type, PGconn *conn)
int pqPutnchar(const char *s, size_t len, PGconn *conn)
void libpq_append_conn_error(PGconn *conn, const char *fmt,...)
int pqPutMsgEnd(PGconn *conn)
@ 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)
MsgType cancelRequestCode
char cancelAuthCode[FLEXIBLE_ARRAY_MEMBER]
struct sockaddr_storage addr
char cancel_req[FLEXIBLE_ARRAY_MEMBER]
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)