Browse code

core: tcp main - check setsockopt() result for SO_LINGER

Daniel-Constantin Mierla authored on 16/05/2022 11:48:28
Showing 1 changed files
... ...
@@ -3199,8 +3199,7 @@ error:
3199 3199
 inline static void tcpconn_close_main_fd(struct tcp_connection* tcpconn)
3200 3200
 {
3201 3201
 	int fd;
3202
-	
3203
-	
3202
+
3204 3203
 	fd=tcpconn->s;
3205 3204
 #ifdef USE_TLS
3206 3205
 	if (tcpconn->type==PROTO_TLS || tcpconn->type==PROTO_WSS)
... ...
@@ -3214,7 +3213,10 @@ inline static void tcpconn_close_main_fd(struct tcp_connection* tcpconn)
3214 3213
 				.l_onoff = 1,  /* non-zero value enables linger option in kernel */
3215 3214
 				.l_linger = 0, /* timeout interval in seconds */
3216 3215
 		};
3217
-		setsockopt(fd, SOL_SOCKET, SO_LINGER, &sl, sizeof(sl));
3216
+		if(setsockopt(fd, SOL_SOCKET, SO_LINGER, &sl, sizeof(sl))<0) {
3217
+			LM_WARN("setsockopt SO_LINGER %d - %s\n", errno,
3218
+						strerror(errno));
3219
+		}
3218 3220
 	}
3219 3221
 	if (unlikely(tcp_safe_close(fd)<0))
3220 3222
 		LM_ERR("(%p): %s close(%d) failed (flags 0x%x): %s (%d)\n", tcpconn,