Protected temporarily with spinlock gethostbyname which is not thread safe. This should be changed permanently so that gethostbyname is replaced with getaddrinfo.

This commit is contained in:
vraatikka 2013-09-05 19:42:59 +03:00
parent 8f98ae4751
commit 4f8057034a

View File

@ -36,6 +36,8 @@
#include <dcb.h>
#include <session.h>
SPINLOCK tmplock = SPINLOCK_INIT;
/**
* Set IP address in socket structure in_addr
*
@ -44,7 +46,12 @@
*/
void
setipaddress(struct in_addr *a, char *p) {
struct hostent *h = gethostbyname(p);
struct hostent *h;
spinlock_acquire(&tmplock);
h = gethostbyname(p);
spinlock_release(&tmplock);
if (h == NULL) {
if ((a->s_addr = inet_addr(p)) == -1) {
fprintf(stderr, "unknown or invalid address [%s]\n", p);