config_transport: Enable TCP_NODELAY on TLS transports
authorGeorge Joseph <gjoseph@digium.com>
Sat, 13 Jan 2018 19:49:07 +0000 (12:49 -0700)
committerGeorge Joseph <gjoseph@digium.com>
Sat, 13 Jan 2018 19:57:03 +0000 (13:57 -0600)
We did this for TCP transports already but I'm not sure why we
didn't do it for TLS transports.

ASTERISK_27474 #not_final_fix

Change-Id: I5b1ef4b882f7b859e718236686b7898751dbb262

res/res_pjsip/config_transport.c

index a9a90ac..63bf118 100644 (file)
@@ -618,6 +618,8 @@ static int transport_apply(const struct ast_sorcery *sorcery, void *obj)
                                &temp_state->state->factory);
                }
        } else if (transport->type == AST_TRANSPORT_TLS) {
+               static int option = 1;
+
                if (transport->async_operations > 1 && ast_compare_versions(pj_get_version(), "2.5.0") < 0) {
                        ast_log(LOG_ERROR, "Transport: %s: When protocol=tls and pjproject version < 2.5.0, async_operations can't be > 1\n",
                                        ast_sorcery_object_get_id(obj));
@@ -627,6 +629,13 @@ static int transport_apply(const struct ast_sorcery *sorcery, void *obj)
                temp_state->state->tls.password = pj_str((char*)transport->password);
                set_qos(transport, &temp_state->state->tls.qos_params);
 
+               /* sockopt_params.options is copied to each newly connected socket */
+               temp_state->state->tls.sockopt_params.options[0].level = pj_SOL_TCP();
+               temp_state->state->tls.sockopt_params.options[0].optname = pj_TCP_NODELAY();
+               temp_state->state->tls.sockopt_params.options[0].optval = &option;
+               temp_state->state->tls.sockopt_params.options[0].optlen = sizeof(option);
+               temp_state->state->tls.sockopt_params.cnt = 1;
+
                for (i = 0; i < BIND_TRIES && res != PJ_SUCCESS; i++) {
                        if (perm_state && perm_state->state && perm_state->state->factory
                                && perm_state->state->factory->destroy) {