Fixes as per bug #37081
authorZdeněk Šustr <sustr4@cesnet.cz>
Tue, 2 Feb 2010 15:45:13 +0000 (15:45 +0000)
committerZdeněk Šustr <sustr4@cesnet.cz>
Tue, 2 Feb 2010 15:45:13 +0000 (15:45 +0000)
- Locking the critial section in connPool initiation
- Reducing portions of code carried out under overall pool lock

org.glite.lb.client/src/connection.c
org.glite.lb.client/src/prod_proto.c
org.glite.lb.common/src/connpool.c

index a8f8574..62cf7b3 100644 (file)
@@ -305,6 +305,10 @@ int edg_wll_open(edg_wll_Context ctx, int* connToUse)
         #endif
 
        *connToUse = index;
+
+       //Lock the select connection, unlock the rest of the pool 
+       edg_wll_connectionTryLock(ctx, index);
+       edg_wll_poolUnlock(); 
        
        /* Old Comment: support anonymous connections, perhaps add a flag to the connPool
         * struct specifying whether or not this connection shall be authenticated
@@ -412,7 +416,9 @@ ok:
 
 end:
 
-       edg_wll_poolUnlock(); /* One way or the other, there are no more pool-wide operations */
+//     edg_wll_poolUnlock(); /* One way or the other, there are no more pool-wide operations */
+//     ZS, 2 Feb 2010: Overall pool lock replaced with a connection-specific 
+//     lock for the most part
 
 //     xxxxx
 
index 90f6785..062d959 100644 (file)
@@ -246,6 +246,10 @@ int edg_wll_log_connect(edg_wll_Context ctx, int *conn)
                        ctx->connections->connPool[index].peerPort,index);
 #endif  
 
+       // Unlock the pool here but lock the connection in question
+       edg_wll_connectionTryLock(ctx, index);
+       edg_wll_poolUnlock();
+
 #if 0
        /* acquire gss credentials */
        ret = edg_wll_gss_acquire_cred_gsi(
@@ -324,7 +328,10 @@ edg_wll_log_connect_err:
 edg_wll_log_connect_end:
        if (index >= 0) edg_wll_connectionTryLock(ctx, index);
 
-       edg_wll_poolUnlock();
+//     edg_wll_poolUnlock();
+//      ZS, 2 Feb 2010: Overall pool lock replaced with a connection-specific 
+//      lock for the most part
+
 
 #ifdef EDG_WLL_LOG_STUB
        if (answer) {
index 0f287a9..9091061 100644 (file)
@@ -250,6 +250,8 @@ edg_wll_Connections* edg_wll_initConnections() {
         printf("Entering edg_wll_initConnections\n");
     #endif
 
+    edg_wll_poolLock();
+
     if((connectionsHandle.connPool == NULL) &&
        (connectionsHandle.poolSize > 0)) { /* We need to allocate memory for the connPool and connectionLock arrays */ 
 
@@ -277,6 +279,7 @@ edg_wll_Connections* edg_wll_initConnections() {
         connectionsHandle.serverConnection = (edg_wll_ConnPool *) calloc(1, sizeof(edg_wll_ConnPool));
     }
 
+    edg_wll_poolUnlock();
 
   return (&connectionsHandle);
 }