Option for NODELAY

This commit is contained in:
Sukchan Lee
2019-06-15 16:58:52 +09:00
parent bcd784b1f0
commit 343c72b288
2 changed files with 14 additions and 12 deletions

View File

@@ -50,7 +50,6 @@ ogs_sock_t *ogs_sctp_socket(int family, int type, ogs_socknode_t *node)
.sctp.max_num_of_istreams = 65535, .sctp.max_num_of_istreams = 65535,
.sctp.max_attempts = 4, .sctp.max_attempts = 4,
.sctp.max_initial_timeout = 8000, /* 8 seconds */ .sctp.max_initial_timeout = 8000, /* 8 seconds */
.nodelay = true /* Turn-on NODELAY */
}; };
ogs_sctp_set_option(&option, node); ogs_sctp_set_option(&option, node);
@@ -61,11 +60,6 @@ ogs_sock_t *ogs_sctp_socket(int family, int type, ogs_socknode_t *node)
rv = subscribe_to_events(new); rv = subscribe_to_events(new);
ogs_assert(rv == OGS_OK); ogs_assert(rv == OGS_OK);
if (node->option.nodelay) {
rv = set_nodelay(new, node->option.nodelay);
ogs_assert(rv == OGS_OK);
}
rv = set_paddrparams(new, &option); rv = set_paddrparams(new, &option);
ogs_assert(rv == OGS_OK); ogs_assert(rv == OGS_OK);
@@ -75,6 +69,13 @@ ogs_sock_t *ogs_sctp_socket(int family, int type, ogs_socknode_t *node)
rv = set_initmsg(new, &option); rv = set_initmsg(new, &option);
ogs_assert(rv == OGS_OK); ogs_assert(rv == OGS_OK);
if (node) {
if (node->option.nodelay) {
rv = set_nodelay(new, node->option.nodelay);
ogs_assert(rv == OGS_OK);
}
}
return new; return new;
} }

View File

@@ -67,7 +67,6 @@ ogs_sock_t *ogs_sctp_socket(int family, int type, ogs_socknode_t *node)
.sctp.max_num_of_istreams = 65535, .sctp.max_num_of_istreams = 65535,
.sctp.max_attempts = 4, .sctp.max_attempts = 4,
.sctp.max_initial_timeout = 8000, /* 8 seconds */ .sctp.max_initial_timeout = 8000, /* 8 seconds */
.nodelay = true /* Turn-on NODELAY */
}; };
ogs_sctp_set_option(&option, node); ogs_sctp_set_option(&option, node);
@@ -78,11 +77,13 @@ ogs_sock_t *ogs_sctp_socket(int family, int type, ogs_socknode_t *node)
return NULL; return NULL;
} }
if (option.nodelay) { if (node) {
if (usrsctp_setsockopt(socket, IPPROTO_SCTP, SCTP_NODELAY, if (node->option.nodelay) {
&on, sizeof(int)) < 0) { if (usrsctp_setsockopt(socket, IPPROTO_SCTP, SCTP_NODELAY,
ogs_error("usrsctp_setsockopt SCTP_NODELAY failed"); &on, sizeof(int)) < 0) {
return NULL; ogs_error("usrsctp_setsockopt SCTP_NODELAY failed");
return NULL;
}
} }
} }