Sfoglia il codice sorgente

bit more thread safety

One more potential race condition in hashtables
z3APA3A 10 anni fa
parent
commit
bc725189e3
2 ha cambiato i file con 5 aggiunte e 2 eliminazioni
  1. 4 1
      src/auth.c
  2. 1 1
      src/version.h

+ 4 - 1
src/auth.c

@@ -943,8 +943,11 @@ void hashadd(struct hashtable *ht, const unsigned char* name, unsigned char* val
 
 	unsigned index;
 	
-	if(!value||!name||!ht->hashtable||!ht->hashempty) return;
 	pthread_mutex_lock(&hash_mutex);
+	if(!ht||!value||!name||!ht->hashtable||!ht->hashempty) {
+		pthread_mutex_unlock(&hash_mutex);
+		return;
+	}
 	hen = ht->hashempty;
 	ht->hashempty = ht->hashempty->next;
 	nametohash(name, hen->hash, (unsigned char *)ht->rnd);

+ 1 - 1
src/version.h

@@ -1,2 +1,2 @@
 #define VERSION "3proxy-0.8b-devel"
-#define BUILDDATE "150302210600"
+#define BUILDDATE "150504180421"