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
This commit is contained in:
Sean Bright
2017-03-18 13:30:32 -04:00
parent baeabb82ea
commit 38cebc73a3
4 changed files with 14 additions and 29 deletions

View File

@@ -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)
{