141 if (originalHost.
host)
153 if (originalHost.
port)
212 "cancel request is already being sent on this connection");
269 if (n < 0 && errno != 0)
418 conn,
"tcp_user_timeout"))
432 conn,
"keepalives_idle"))
439 conn,
"keepalives_interval"))
446 conn,
"keepalives_count"))
514#if defined(TCP_USER_TIMEOUT) || !defined(WIN32)
520 if (setsockopt(
fd, protoid, optid, (
char *) &
value,
sizeof(
value)) < 0)
558 strlcpy(errbuf,
"PQcancel() -- no cancel object supplied", errbufsize);
567 strlcpy(errbuf,
"PQcancel() -- no cancellation key received", errbufsize);
579 strlcpy(errbuf,
"PQcancel() -- socket() failed: ", errbufsize);
580 goto cancel_errReturn;
593 if (cancel->
raddr.
addr.ss_family != AF_UNIX &&
599 strlcpy(errbuf,
"PQcancel() -- setsockopt(SO_KEEPALIVE) failed: ", errbufsize);
600 goto cancel_errReturn;
603#ifdef PG_TCP_KEEPALIVE_IDLE
607 strlcpy(errbuf,
"PQcancel() -- setsockopt(" PG_TCP_KEEPALIVE_IDLE_STR
") failed: ", errbufsize);
608 goto cancel_errReturn;
616 strlcpy(errbuf,
"PQcancel() -- setsockopt(TCP_KEEPINTVL) failed: ", errbufsize);
617 goto cancel_errReturn;
625 strlcpy(errbuf,
"PQcancel() -- setsockopt(TCP_KEEPCNT) failed: ", errbufsize);
626 goto cancel_errReturn;
632#ifdef SIO_KEEPALIVE_VALS
633 if (!pqSetKeepalivesWin32(tmpsock,
637 strlcpy(errbuf,
"PQcancel() -- WSAIoctl(SIO_KEEPALIVE_VALS) failed: ", errbufsize);
638 goto cancel_errReturn;
644#ifdef TCP_USER_TIMEOUT
648 strlcpy(errbuf,
"PQcancel() -- setsockopt(TCP_USER_TIMEOUT) failed: ", errbufsize);
649 goto cancel_errReturn;
661 strlcpy(errbuf,
"PQcancel() -- connect() failed: ", errbufsize);
662 goto cancel_errReturn;
673 if (
send(tmpsock, (
char *) &cancel->
cancel_pkt_len, cancel_pkt_len, 0) != cancel_pkt_len)
678 strlcpy(errbuf,
"PQcancel() -- send() failed: ", errbufsize);
679 goto cancel_errReturn;
690 if (
recv(tmpsock, &recvbuf, 1, 0) < 0)
709 maxlen = errbufsize - strlen(errbuf) - 2;
721 bufp =
buf +
sizeof(
buf) - 1;
725 *(--bufp) = (
val % 10) +
'0';
729 memcpy(bufp,
"error ", 6);
730 strncat(errbuf, bufp, maxlen);
731 strcat(errbuf,
"\n");
764 "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 void *s, size_t len, PGconn *conn)
int pqPutMsgEnd(PGconn *conn)
@ CONNECTION_AWAITING_RESPONSE
PostgresPollingStatusType
#define SOCK_ERRNO_SET(e)
void libpq_append_conn_error(PGconn *conn, const char *fmt,...)
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
uint8 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)