summaryrefslogtreecommitdiff
path: root/include/asterisk
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:51:47 -0400
commit38cebc73a33195fa14d6fa417284c59efe6111ee (patch)
tree187ba2eac60466d82253c8753a4ffc144b14809a /include/asterisk
parentbaeabb82eaa92a9d493ae92b77ece72faf37d619 (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 'include/asterisk')
-rw-r--r--include/asterisk/network.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/asterisk/network.h b/include/asterisk/network.h
index 3371e5895..5216f4c61 100644
--- a/include/asterisk/network.h
+++ b/include/asterisk/network.h
@@ -86,6 +86,11 @@ const char *ast_inet_ntoa(struct in_addr ia);
#endif
#define inet_ntoa __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__
+#ifdef getprotobyname
+#undef getprotobyname
+#endif
+#define getprotobyname __getprotobyname_is_not_threadsafe__do_not_use__
+
/*! \brief Compares the source address and port of two sockaddr_in */
static force_inline int inaddrcmp(const struct sockaddr_in *sin1, const struct sockaddr_in *sin2)
{