Module: kamailio
Branch: master
Commit: 4363b863e9dcd3b31c1d2b2febd9b11c40ec3eec
URL:
https://github.com/kamailio/kamailio/commit/4363b863e9dcd3b31c1d2b2febd9b11…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-07-21T08:52:44+02:00
db_postgres: handle return code for setsockopt()
---
Modified: src/modules/db_postgres/pg_con.c
---
Diff:
https://github.com/kamailio/kamailio/commit/4363b863e9dcd3b31c1d2b2febd9b11…
Patch:
https://github.com/kamailio/kamailio/commit/4363b863e9dcd3b31c1d2b2febd9b11…
---
diff --git a/src/modules/db_postgres/pg_con.c b/src/modules/db_postgres/pg_con.c
index 7b8085c8ac..851685d353 100644
--- a/src/modules/db_postgres/pg_con.c
+++ b/src/modules/db_postgres/pg_con.c
@@ -302,8 +302,14 @@ int pg_con_connect(db_con_t* con)
#if defined(SO_KEEPALIVE) && defined(TCP_KEEPIDLE)
if (pg_keepalive) {
i = 1;
- setsockopt(PQsocket(pcon->con), SOL_SOCKET, SO_KEEPALIVE, &i, sizeof(i));
- setsockopt(PQsocket(pcon->con), IPPROTO_TCP, TCP_KEEPIDLE, &pg_keepalive,
sizeof(pg_keepalive));
+ if(setsockopt(PQsocket(pcon->con), SOL_SOCKET, SO_KEEPALIVE, &i,
+ sizeof(i))<0) {
+ LM_WARN("failed to set socket option keepalive\n");
+ }
+ if(setsockopt(PQsocket(pcon->con), IPPROTO_TCP, TCP_KEEPIDLE,
+ &pg_keepalive, sizeof(pg_keepalive))<0) {
+ M_WARN("failed to set socket option keepidle\n");
+ }
}
#endif