7fe80d37afd296f8db0058f3e444737ff88ff80e
markd
  Mon Jul 26 23:50:19 2010 -0700
address problem of hgTables consuming all available sockets before TIME_WAIT period by using the connection cache. Have hgTable log connection usage information to help ensure this is fixed
diff --git src/hg/hgTables/joining.c src/hg/hgTables/joining.c
index 014dc00..e1d5af1 100644
--- src/hg/hgTables/joining.c
+++ src/hg/hgTables/joining.c
@@ -387,7 +387,7 @@
 /* Rearrange order of fields in tj->fieldList so that 
  * they are the same as the order in the database. */
 {
-struct sqlConnection *conn = sqlConnect(tj->database);
+struct sqlConnection *conn = hAllocConn(tj->database);
 char *splitTable = chromTable(conn, tj->table);
 struct hash *fieldHash = hashNew(0);
 struct slName *field, *fieldList = sqlListFields(conn, splitTable);
@@ -396,7 +396,7 @@
 /* Build up hash of field names. */
 for (dtf = tj->fieldList; dtf != NULL; dtf = dtf->next)
     hashAdd(fieldHash, dtf->field, dtf);
-sqlDisconnect(&conn);
+hFreeConn(&conn);
 
 /* Build up new list in correct order. */
 for (field = fieldList; field != NULL; field = field->next)
@@ -584,7 +584,7 @@
 struct joinerPair *jp;
 int fieldCount = 0, keyCount = 0;
 int idFieldIx = -1;
-struct sqlConnection *conn = sqlConnect(tj->database);
+struct sqlConnection *conn = hAllocConn(tj->database);
 char *identifierFilter = NULL;
 char *filter;
 boolean needUpdateFilter = FALSE;
@@ -694,7 +694,7 @@
 	}
     }
 tj->loaded = TRUE;
-sqlDisconnect(&conn);
+hFreeConn(&conn);
 }
 	
 struct joinedTables *tjLoadFirst(struct region *regionList,
@@ -983,7 +983,7 @@
 
 if (! doJoin)
     {
-    struct sqlConnection *conn = sqlConnect(dtfList->database);
+    struct sqlConnection *conn = hAllocConn(dtfList->database);
     struct dyString *dy = dyStringNew(0);
     
     if (hIsBigBed(database, dtfList->table, NULL, ctLookupName))
@@ -993,7 +993,7 @@
     else
 	makeDbOrderedCommaFieldList(conn, dtfList->table, dtfList, dy);
     doTabOutTable(dtfList->database, dtfList->table, f, conn, dy->string);
-    sqlDisconnect(&conn);
+    hFreeConn(&conn);
     }
 else
     {