ubik: Introduce new address lock
[openafs.git] / src / ubik / ubik.c
index d3d0b99..c73e781 100644 (file)
@@ -105,11 +105,15 @@ Quorum_StartIO(struct ubik_trans *atrans, struct ubik_server *as)
 {
     struct rx_connection *conn;
 
+    UBIK_ADDR_LOCK;
     conn = as->disk_rxcid;
 
 #ifdef AFS_PTHREAD_ENV
     rx_GetConnection(conn);
+    UBIK_ADDR_UNLOCK;
     DBRELE(atrans->dbase);
+#else
+    UBIK_ADDR_UNLOCK;
 #endif /* AFS_PTHREAD_ENV */
 
     return conn;
@@ -407,6 +411,7 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort,
     MUTEX_INIT(&tdb->versionLock, "version lock", MUTEX_DEFAULT, 0);
     MUTEX_INIT(&beacon_globals.beacon_lock, "beacon lock", MUTEX_DEFAULT, 0);
     MUTEX_INIT(&vote_globals.vote_lock, "vote lock", MUTEX_DEFAULT, 0);
+    MUTEX_INIT(&addr_globals.addr_lock, "address lock", MUTEX_DEFAULT, 0);
 #else
     Lock_Init(&tdb->versionLock);
 #endif
@@ -1368,10 +1373,14 @@ ubikGetPrimaryInterfaceAddr(afs_uint32 addr)
     struct ubik_server *ts;
     int j;
 
+    UBIK_ADDR_LOCK;
     for (ts = ubik_servers; ts; ts = ts->next)
        for (j = 0; j < UBIK_MAX_INTERFACE_ADDR; j++)
-           if (ts->addr[j] == addr)
+           if (ts->addr[j] == addr) {
+               UBIK_ADDR_UNLOCK;
                return ts->addr[0];     /* net byte order */
+           }
+    UBIK_ADDR_UNLOCK;
     return 0;                  /* if not in server database, return error */
 }