Skip to content

Commit 6c9c6ef

Browse files
committed
net: call initialize proto function for all connections
This code fixes proto ws and wss, by calling the `conn_init` function even for connections that are not sent back to main. Reported by @suharik71 in OpenSIPS#1956
1 parent 30a7f47 commit 6c9c6ef

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

net/net_tcp.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -924,15 +924,6 @@ struct tcp_connection* tcp_conn_create(int sock, union sockaddr_union* su,
924924
if (c==NULL)
925925
return NULL;
926926

927-
if (protos[c->type].net.conn_init &&
928-
protos[c->type].net.conn_init(c) < 0) {
929-
LM_ERR("failed to do proto %d specific init for conn %p\n",
930-
c->type, c);
931-
tcp_conn_destroy(c);
932-
return NULL;
933-
}
934-
c->flags |= F_CONN_INIT;
935-
936927
return (tcp_conn_send(c) == 0 ? c : NULL);
937928
}
938929

@@ -951,6 +942,15 @@ struct tcp_connection* tcp_conn_new(int sock, union sockaddr_union* su,
951942
available to the rest of the world */
952943
sh_log(c->hist, TCP_REF, "connect, (%d)", c->refcnt);
953944

945+
if (protos[c->type].net.conn_init &&
946+
protos[c->type].net.conn_init(c) < 0) {
947+
LM_ERR("failed to do proto %d specific init for conn %p\n",
948+
c->type, c);
949+
tcp_conn_destroy(c);
950+
return NULL;
951+
}
952+
c->flags |= F_CONN_INIT;
953+
954954
return c;
955955
}
956956

0 commit comments

Comments
 (0)