Go to the source code of this file.
◆ ClientConnectionInfo
◆ ClientSocket
◆ Port
◆ pq_getkeepalivescount()
| int pq_getkeepalivescount |
( |
Port * |
port | ) |
|
Definition at line 1801 of file pqcomm.c.
1802{
1803#ifdef TCP_KEEPCNT
1804 if (
port == NULL ||
port->laddr.addr.ss_family == AF_UNIX)
1805 return 0;
1806
1807 if (
port->keepalives_count != 0)
1808 return port->keepalives_count;
1809
1810 if (
port->default_keepalives_count == 0)
1811 {
1813
1814 if (getsockopt(
port->sock, IPPROTO_TCP, TCP_KEEPCNT,
1815 (
char *) &
port->default_keepalives_count,
1816 &size) < 0)
1817 {
1819 (
errmsg(
"%s(%s) failed: %m",
"getsockopt",
"TCP_KEEPCNT")));
1820 port->default_keepalives_count = -1;
1821 }
1822 }
1823
1824 return port->default_keepalives_count;
1825#else
1826 return 0;
1827#endif
1828}
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
References ereport, errmsg(), LOG, and port.
Referenced by pq_setkeepalivescount(), and show_tcp_keepalives_count().
◆ pq_getkeepalivesidle()
| int pq_getkeepalivesidle |
( |
Port * |
port | ) |
|
Definition at line 1632 of file pqcomm.c.
1633{
1634#if defined(PG_TCP_KEEPALIVE_IDLE) || defined(SIO_KEEPALIVE_VALS)
1635 if (
port == NULL ||
port->laddr.addr.ss_family == AF_UNIX)
1636 return 0;
1637
1638 if (
port->keepalives_idle != 0)
1639 return port->keepalives_idle;
1640
1641 if (
port->default_keepalives_idle == 0)
1642 {
1643#ifndef WIN32
1645
1646 if (getsockopt(
port->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE_IDLE,
1647 (
char *) &
port->default_keepalives_idle,
1648 &size) < 0)
1649 {
1651 (
errmsg(
"%s(%s) failed: %m",
"getsockopt", PG_TCP_KEEPALIVE_IDLE_STR)));
1652 port->default_keepalives_idle = -1;
1653 }
1654#else
1655
1656 port->default_keepalives_idle = -1;
1657#endif
1658 }
1659
1660 return port->default_keepalives_idle;
1661#else
1662 return 0;
1663#endif
1664}
References ereport, errmsg(), LOG, and port.
Referenced by pq_setkeepalivesidle(), and show_tcp_keepalives_idle().
◆ pq_getkeepalivesinterval()
| int pq_getkeepalivesinterval |
( |
Port * |
port | ) |
|
Definition at line 1717 of file pqcomm.c.
1718{
1719#if defined(TCP_KEEPINTVL) || defined(SIO_KEEPALIVE_VALS)
1720 if (
port == NULL ||
port->laddr.addr.ss_family == AF_UNIX)
1721 return 0;
1722
1723 if (
port->keepalives_interval != 0)
1724 return port->keepalives_interval;
1725
1726 if (
port->default_keepalives_interval == 0)
1727 {
1728#ifndef WIN32
1730
1731 if (getsockopt(
port->sock, IPPROTO_TCP, TCP_KEEPINTVL,
1732 (
char *) &
port->default_keepalives_interval,
1733 &size) < 0)
1734 {
1736 (
errmsg(
"%s(%s) failed: %m",
"getsockopt",
"TCP_KEEPINTVL")));
1737 port->default_keepalives_interval = -1;
1738 }
1739#else
1740
1741 port->default_keepalives_interval = -1;
1742#endif
1743 }
1744
1745 return port->default_keepalives_interval;
1746#else
1747 return 0;
1748#endif
1749}
References ereport, errmsg(), LOG, and port.
Referenced by pq_setkeepalivesinterval(), and show_tcp_keepalives_interval().
◆ pq_gettcpusertimeout()
| int pq_gettcpusertimeout |
( |
Port * |
port | ) |
|
Definition at line 1876 of file pqcomm.c.
1877{
1878#ifdef TCP_USER_TIMEOUT
1879 if (
port == NULL ||
port->laddr.addr.ss_family == AF_UNIX)
1880 return 0;
1881
1882 if (
port->tcp_user_timeout != 0)
1883 return port->tcp_user_timeout;
1884
1885 if (
port->default_tcp_user_timeout == 0)
1886 {
1888
1889 if (getsockopt(
port->sock, IPPROTO_TCP, TCP_USER_TIMEOUT,
1890 (
char *) &
port->default_tcp_user_timeout,
1891 &size) < 0)
1892 {
1894 (
errmsg(
"%s(%s) failed: %m",
"getsockopt",
"TCP_USER_TIMEOUT")));
1895 port->default_tcp_user_timeout = -1;
1896 }
1897 }
1898
1899 return port->default_tcp_user_timeout;
1900#else
1901 return 0;
1902#endif
1903}
References ereport, errmsg(), LOG, and port.
Referenced by pq_settcpusertimeout(), and show_tcp_user_timeout().
◆ pq_setkeepalivescount()
| int pq_setkeepalivescount |
( |
int |
count, |
|
|
Port * |
port |
|
) |
| |
Definition at line 1831 of file pqcomm.c.
1832{
1833 if (
port == NULL ||
port->laddr.addr.ss_family == AF_UNIX)
1835
1836#ifdef TCP_KEEPCNT
1837 if (count ==
port->keepalives_count)
1839
1840 if (
port->default_keepalives_count <= 0)
1841 {
1843 {
1844 if (count == 0)
1846 else
1848 }
1849 }
1850
1851 if (count == 0)
1852 count =
port->default_keepalives_count;
1853
1854 if (setsockopt(
port->sock, IPPROTO_TCP, TCP_KEEPCNT,
1855 (char *) &count, sizeof(count)) < 0)
1856 {
1858 (
errmsg(
"%s(%s) failed: %m",
"setsockopt",
"TCP_KEEPCNT")));
1860 }
1861
1862 port->keepalives_count = count;
1863#else
1864 if (count != 0)
1865 {
1867 (
errmsg(
"%s(%s) not supported",
"setsockopt",
"TCP_KEEPCNT")));
1869 }
1870#endif
1871
1873}
int pq_getkeepalivescount(Port *port)
References ereport, errmsg(), LOG, port, pq_getkeepalivescount(), STATUS_ERROR, and STATUS_OK.
Referenced by assign_tcp_keepalives_count(), and pq_init().
◆ pq_setkeepalivesidle()
| int pq_setkeepalivesidle |
( |
int |
idle, |
|
|
Port * |
port |
|
) |
| |
Definition at line 1667 of file pqcomm.c.
1668{
1669 if (
port == NULL ||
port->laddr.addr.ss_family == AF_UNIX)
1671
1672
1673#if defined(PG_TCP_KEEPALIVE_IDLE) || defined(SIO_KEEPALIVE_VALS)
1674 if (idle ==
port->keepalives_idle)
1676
1677#ifndef WIN32
1678 if (
port->default_keepalives_idle <= 0)
1679 {
1681 {
1682 if (idle == 0)
1684 else
1686 }
1687 }
1688
1689 if (idle == 0)
1690 idle =
port->default_keepalives_idle;
1691
1692 if (setsockopt(
port->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE_IDLE,
1693 (char *) &idle, sizeof(idle)) < 0)
1694 {
1696 (
errmsg(
"%s(%s) failed: %m",
"setsockopt", PG_TCP_KEEPALIVE_IDLE_STR)));
1698 }
1699
1700 port->keepalives_idle = idle;
1701#else
1702 return pq_setkeepaliveswin32(
port, idle,
port->keepalives_interval);
1703#endif
1704#else
1705 if (idle != 0)
1706 {
1708 (
errmsg(
"setting the keepalive idle time is not supported")));
1710 }
1711#endif
1712
1714}
int pq_getkeepalivesidle(Port *port)
References ereport, errmsg(), LOG, port, pq_getkeepalivesidle(), STATUS_ERROR, and STATUS_OK.
Referenced by assign_tcp_keepalives_idle(), and pq_init().
◆ pq_setkeepalivesinterval()
| int pq_setkeepalivesinterval |
( |
int |
interval, |
|
|
Port * |
port |
|
) |
| |
Definition at line 1752 of file pqcomm.c.
1753{
1754 if (
port == NULL ||
port->laddr.addr.ss_family == AF_UNIX)
1756
1757#if defined(TCP_KEEPINTVL) || defined(SIO_KEEPALIVE_VALS)
1760
1761#ifndef WIN32
1762 if (
port->default_keepalives_interval <= 0)
1763 {
1765 {
1768 else
1770 }
1771 }
1772
1775
1776 if (setsockopt(
port->sock, IPPROTO_TCP, TCP_KEEPINTVL,
1778 {
1780 (
errmsg(
"%s(%s) failed: %m",
"setsockopt",
"TCP_KEEPINTVL")));
1782 }
1783
1785#else
1787#endif
1788#else
1790 {
1792 (
errmsg(
"%s(%s) not supported",
"setsockopt",
"TCP_KEEPINTVL")));
1794 }
1795#endif
1796
1798}
int pq_getkeepalivesinterval(Port *port)
References ereport, errmsg(), LOG, port, pq_getkeepalivesinterval(), STATUS_ERROR, and STATUS_OK.
Referenced by assign_tcp_keepalives_interval(), and pq_init().
◆ pq_settcpusertimeout()
| int pq_settcpusertimeout |
( |
int |
timeout, |
|
|
Port * |
port |
|
) |
| |
Definition at line 1906 of file pqcomm.c.
1907{
1908 if (
port == NULL ||
port->laddr.addr.ss_family == AF_UNIX)
1910
1911#ifdef TCP_USER_TIMEOUT
1912 if (timeout ==
port->tcp_user_timeout)
1914
1915 if (
port->default_tcp_user_timeout <= 0)
1916 {
1918 {
1919 if (timeout == 0)
1921 else
1923 }
1924 }
1925
1926 if (timeout == 0)
1927 timeout =
port->default_tcp_user_timeout;
1928
1929 if (setsockopt(
port->sock, IPPROTO_TCP, TCP_USER_TIMEOUT,
1930 (char *) &timeout, sizeof(timeout)) < 0)
1931 {
1933 (
errmsg(
"%s(%s) failed: %m",
"setsockopt",
"TCP_USER_TIMEOUT")));
1935 }
1936
1937 port->tcp_user_timeout = timeout;
1938#else
1939 if (timeout != 0)
1940 {
1942 (
errmsg(
"%s(%s) not supported",
"setsockopt",
"TCP_USER_TIMEOUT")));
1944 }
1945#endif
1946
1948}
int pq_gettcpusertimeout(Port *port)
References ereport, errmsg(), LOG, port, pq_gettcpusertimeout(), STATUS_ERROR, and STATUS_OK.
Referenced by assign_tcp_user_timeout(), and pq_init().
◆ FrontendProtocol
◆ MyClientConnectionInfo