Skip to content

Commit 1c90d5d

Browse files
Compiling with DISABLE_NAGLE does not propogate tcp_proto_no and never sets TCP_NODELAY (#3859)
1 parent 8cfbb70 commit 1c90d5d

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

net/net_tcp.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ static unsigned int* connection_id=0;
106106
/* array of TCP partitions */
107107
static struct tcp_partition tcp_parts[TCP_PARTITION_SIZE];
108108

109-
/*!< tcp protocol number as returned by getprotobyname */
110-
static int tcp_proto_no=-1;
111-
112109
/* communication socket from generic proc to TCP main */
113110
int unix_tcp_sock = -1;
114111

@@ -241,8 +238,7 @@ int tcp_init_sock_opt(int s, const struct tcp_conn_profile *prof, enum si_flags
241238

242239
#ifdef DISABLE_NAGLE
243240
flags=1;
244-
if ( (tcp_proto_no!=-1) && (setsockopt(s, tcp_proto_no , TCP_NODELAY,
245-
&flags, sizeof(flags))<0) ){
241+
if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &flags, sizeof(flags)) < 0){
246242
LM_WARN("could not disable Nagle: %s\n", strerror(errno));
247243
}
248244
#endif
@@ -327,10 +323,12 @@ static int send2worker(struct tcp_connection* tcpconn,int rw)
327323
int tcp_init_listener(struct socket_info *si)
328324
{
329325
union sockaddr_union* addr = &si->su;
326+
330327
if (init_su(addr, &si->address, si->port_no)<0){
331328
LM_ERR("could no init sockaddr_union\n");
332329
return -1;
333330
}
331+
334332
return 0;
335333
}
336334

@@ -341,17 +339,6 @@ int tcp_bind_listener(struct socket_info *si)
341339
int optval;
342340
#ifdef DISABLE_NAGLE
343341
int flag;
344-
struct protoent* pe;
345-
346-
if (tcp_proto_no==-1){ /* if not already set */
347-
pe=getprotobyname("tcp");
348-
if (pe==0){
349-
LM_ERR("could not get TCP protocol number\n");
350-
tcp_proto_no=-1;
351-
}else{
352-
tcp_proto_no=pe->p_proto;
353-
}
354-
}
355342
#endif
356343

357344
addr = &si->su;
@@ -362,9 +349,7 @@ int tcp_bind_listener(struct socket_info *si)
362349
}
363350
#ifdef DISABLE_NAGLE
364351
flag=1;
365-
if ( (tcp_proto_no!=-1) &&
366-
(setsockopt(si->socket, tcp_proto_no , TCP_NODELAY,
367-
&flag, sizeof(flag))<0) ){
352+
if (setsockopt(si->socket, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag)) < 0){
368353
LM_ERR("could not disable Nagle: %s\n",strerror(errno));
369354
}
370355
#endif

0 commit comments

Comments
 (0)