Skip to content

Commit

Permalink
net: call initialize proto function for all connections
Browse files Browse the repository at this point in the history
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 #1956

(cherry picked from commit 6c9c6ef)
  • Loading branch information
razvancrainea committed Feb 6, 2020
1 parent c221d84 commit c558682
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions net/net_tcp.c
Expand Up @@ -907,15 +907,6 @@ struct tcp_connection* tcp_conn_create(int sock, union sockaddr_union* su,
if (c==NULL)
return NULL;

if (protos[c->type].net.conn_init &&
protos[c->type].net.conn_init(c) < 0) {
LM_ERR("failed to do proto %d specific init for conn %p\n",
c->type, c);
tcp_conn_destroy(c);
return NULL;
}
c->flags |= F_CONN_INIT;

return (tcp_conn_send(c) == 0 ? c : NULL);
}

Expand All @@ -934,6 +925,15 @@ struct tcp_connection* tcp_conn_new(int sock, union sockaddr_union* su,
available to the rest of the world */
sh_log(c->hist, TCP_REF, "connect, (%d)", c->refcnt);

if (protos[c->type].net.conn_init &&
protos[c->type].net.conn_init(c) < 0) {
LM_ERR("failed to do proto %d specific init for conn %p\n",
c->type, c);
tcp_conn_destroy(c);
return NULL;
}
c->flags |= F_CONN_INIT;

return c;
}

Expand Down

0 comments on commit c558682

Please sign in to comment.