summaryrefslogtreecommitdiff
path: root/channels/chan_skinny.c
diff options
context:
space:
mode:
authorSean Bright <sean.bright@gmail.com>2017-03-18 13:30:32 -0400
committerSean Bright <sean.bright@gmail.com>2017-03-20 08:55:05 -0400
commitfc71c18a9b572296e171eb6b1f87aee5c2256c8c (patch)
tree8c1123cca9cfe951f7562dcd80a4b8d24e0bb9f6 /channels/chan_skinny.c
parentb05d2fda0c8b3473c3d6d7bd1cc0473e2728b744 (diff)
thread safety: Don't use getprotobyname()
POSIX does not require getprotobyname() to be thread safe and some implementations use static memory which causes issues when multiple threads are used. Further, our usage of it today is just to ultimately get IPPROTO_TCP for calls to setsockopt(). So instead we just use IPPROTO_TCP directly. Change-Id: I2e14e58674808f7ce99b2f5e900d0f90d0d8da48
Diffstat (limited to 'channels/chan_skinny.c')
-rw-r--r--channels/chan_skinny.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index a3a2f87fb..d1c2b927a 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -7639,7 +7639,6 @@ static void *accept_thread(void *ignore)
struct sockaddr_in sin;
socklen_t sinlen;
struct skinnysession *s;
- struct protoent *p;
int arg = 1;
for (;;) {
@@ -7656,12 +7655,10 @@ static void *accept_thread(void *ignore)
continue;
}
- p = getprotobyname("tcp");
- if(p) {
- if( setsockopt(as, p->p_proto, TCP_NODELAY, (char *)&arg, sizeof(arg) ) < 0 ) {
- ast_log(LOG_WARNING, "Failed to set Skinny tcp connection to TCP_NODELAY mode: %s\n", strerror(errno));
- }
+ if (setsockopt(as, IPPROTO_TCP, TCP_NODELAY, (char *) &arg, sizeof(arg)) < 0) {
+ ast_log(LOG_WARNING, "Failed to set TCP_NODELAY on Skinny TCP connection: %s\n", strerror(errno));
}
+
if (!(s = ast_calloc(1, sizeof(struct skinnysession)))) {
close(as);
ast_atomic_fetchadd_int(&unauth_sessions, -1);