]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
PJSIP: provide valid tcp nodelay option for reuse 51/3151/2
authorScott Griepentrog <scott@griepentrog.com>
Thu, 7 Jul 2016 15:55:42 +0000 (10:55 -0500)
committerScott Griepentrog <sgriepentrog@digium.com>
Thu, 7 Jul 2016 16:28:31 +0000 (11:28 -0500)
When using TCP transport with chan_pjsip, the TCP_NODELAY
option value was allocated on the stack, then passed as a
pointer to the tcp transport configuration structure, and
later re-used on subsequently created sockets when it was
no longer valid.  This patch changes the allocation to be
a static.

ASTERISK-26180 #close
Reported by: Scott Griepentrog

Change-Id: I3251164c7f710dbdab031282f00e30a9770626a0

res/res_pjsip/config_transport.c

index b9208976fc37bd47cc5c423bbb386c654a6e2cd2..60b4507cdb8fed51eaba631cca255e24b7cc65e1 100644 (file)
@@ -562,12 +562,13 @@ static int transport_apply(const struct ast_sorcery *sorcery, void *obj)
                }
        } else if (transport->type == AST_TRANSPORT_TCP) {
                pjsip_tcp_transport_cfg cfg;
-               int option = 1;
+               static int option = 1;
 
                pjsip_tcp_transport_cfg_default(&cfg, temp_state->state->host.addr.sa_family);
                cfg.bind_addr = temp_state->state->host;
                cfg.async_cnt = transport->async_operations;
                set_qos(transport, &cfg.qos_params);
+               /* sockopt_params.options is copied to each newly connected socket */
                cfg.sockopt_params.options[0].level = pj_SOL_TCP();
                cfg.sockopt_params.options[0].optname = pj_TCP_NODELAY();
                cfg.sockopt_params.options[0].optval = &option;