--- scanner.c.orig	2004-07-30 19:42:28.000000000 +0200
+++ scanner.c	2004-07-30 19:45:14.000000000 +0200
@@ -34,6 +34,7 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <clamav.h>
+#include <pthread.h>
 
 #include "cfgparser.h"
 #include "others.h"
@@ -49,6 +50,8 @@
 dev_t procdev; /* /proc device */
 #endif
 
+pthread_mutex_t gh_mutex = PTHREAD_MUTEX_INITIALIZER;
+
 int checksymlink(const char *path)
 {
 	struct stat statbuf;
@@ -239,11 +242,14 @@
 	server.sin_port = htons(port);
 
 	if((cpt = cfgopt(copt, "TCPAddr"))) {
-	    if ((he = gethostbyname(cpt->strarg)) == 0) {
+	    pthread_mutex_lock(&gh_mutex);
+	    if((he = gethostbyname(cpt->strarg)) == 0) {
 		logg("!gethostbyname(%s) error: %s\n", cpt->strarg);
 		mdprintf(odesc, "gethostbyname(%s) ERROR\n", cpt->strarg);
+		pthread_mutex_unlock(&gh_mutex);
 		return -1;
 	    }
+	    pthread_mutex_unlock(&gh_mutex);
 	    server.sin_addr = *(struct in_addr *) he->h_addr_list[0];
 	} else
 	    server.sin_addr.s_addr = INADDR_ANY;
