Windows: cm_ConnByServer add conn to list after init
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 5 Jul 2012 18:33:50 +0000 (14:33 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 6 Jul 2012 01:18:37 +0000 (18:18 -0700)
Do not add a newly created cm_conn_t to the cm_server_t connsp
list until after the object is fully initialized.

Change-Id: Ic5605abefb51d9342f0d249903e13e99b90452b7
Reviewed-on: http://gerrit.openafs.org/7717
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsd/cm_conn.c

index 2f950ae..c17acd6 100644 (file)
@@ -1584,17 +1584,15 @@ long cm_ConnByServer(cm_server_t *serverp, cm_user_t *userp, afs_uint32 replicat
         cm_GetServer(serverp);
         tcp = malloc(sizeof(*tcp));
         memset(tcp, 0, sizeof(*tcp));
-        tcp->nextp = serverp->connsp;
-        serverp->connsp = tcp;
         cm_HoldUser(userp);
         tcp->userp = userp;
         lock_InitializeMutex(&tcp->mx, "cm_conn_t mutex", LOCK_HIERARCHY_CONN);
-        lock_ObtainMutex(&tcp->mx);
         tcp->serverp = serverp;
         tcp->cryptlevel = rxkad_clear;
         cm_NewRXConnection(tcp, ucellp, serverp, replicated);
         tcp->refCount = 1;
-        lock_ReleaseMutex(&tcp->mx);
+        tcp->nextp = serverp->connsp;
+        serverp->connsp = tcp;
         lock_ReleaseWrite(&cm_connLock);
     } else {
         lock_ReleaseRead(&cm_connLock);