fc1790a9a6117cfa0768ac691b0ba1d9bc1ea43b
galt
  Tue Mar 19 22:05:00 2019 -0700
version 42. hDisconnectCentral(&conn) should never have been there. moving the other line for code clarity.

diff --git src/hg/utils/refreshNamedSessionCustomTracks/refreshNamedSessionCustomTracks.c src/hg/utils/refreshNamedSessionCustomTracks/refreshNamedSessionCustomTracks.c
index 6bf74cb..7e11986 100644
--- src/hg/utils/refreshNamedSessionCustomTracks/refreshNamedSessionCustomTracks.c
+++ src/hg/utils/refreshNamedSessionCustomTracks/refreshNamedSessionCustomTracks.c
@@ -4,31 +4,31 @@
 /* Copyright (C) 2013 The Regents of the University of California 
  * See README in this or parent directory for licensing information. */
 
 #include "common.h"
 #include "options.h"
 #include "hash.h"
 #include "cheapcgi.h"
 #include "customTrack.h"
 #include "customFactory.h"
 #include "hui.h"
 #include "hgConfig.h"
 #include <sys/wait.h>
 #include <signal.h>
 #include "obscure.h"
 
-int version = 40;  // PLEASE INCREMENT THIS BEFORE PUSHING TO SHARED REPO
+int version = 42;  // PLEASE INCREMENT THIS BEFORE PUSHING TO SHARED REPO
                    // SO THAT OTHERS MAY TEST WITH IT, SO THAT EVERYONE KNOWS THEY HAVE THE
                    // EXACT RIGHT VERSION.
 
 #define savedSessionTable "namedSessionDb"
 
 int CFTEcalls = 0; 
 int numUpdates = 0;
 
 int numForks = 10;
 
 int timeoutSecs = 3600; // Timeout for each forked child process
                         // default 3600 seconds is one hour
 
 char *testFailure = NULL;
 
@@ -331,31 +331,30 @@
     if (newContents->stringSize > contentLength)
 	errAbort("ERROR: Uh, why is newContents (%d) longer than original (%d)",
 		 newContents->stringSize, contentLength);
     sqlDyStringPrintf(update, "UPDATE %s set contents='", savedSessionTable);
     dyStringAppendN(update, newContents->string, newContents->stringSize);
     dyStringPrintf(update, "', lastUse=now(), useCount=useCount+1 "
 		   "where userName=\"%s\" and sessionName=\"%s\";",
 		   userName, sessionName);
     verbose(3, "Removing one or more dead CT file settings from %s %s "
 	    "(original length %d, now %d)\n", 
 	    userName, sessionName,
 	    contentLength, newContents->stringSize);
     sqlUpdate(conn, update->string);
     dyStringFree(&update);
     }
-hDisconnectCentral(&conn);
 dyStringFree(&oneSetting);
 dyStringFree(&newContents);
 freeMem(contentsToChop);
 freeMem(contents);
 return;
 
 }
 
 struct sessionInfo
     {
     struct sessionInfo *next;
     char userName[256];
     char sessionName[256];
     };
 
@@ -462,36 +461,36 @@
 // It is CRUCIAL that this program exits with non-zero exit code
 // when it or any of its children exit non-zero, abort, get killed, or crash,
 // in order to tell the calling program that it has failed.
 // This is the only thing will stop the deletion and loss of saved named sessions!
 
 // Every single session MUST be processed in order to save it from deletion.
 for (si = sessionList;  si != NULL;  si = si->next)
     {
 	
     if (parent && sessionsPerForkDone == 0)
 	{
 	pid = forkIt();
 	if (pid == 0)
 	    {
 	    parent = FALSE;
-	    conn = unCachedCentralConn(); // avoid cached connections when forking 
 	    }
         }
     
     if (!parent)
 	{
+	conn = unCachedCentralConn(); // avoid cached connections when forking 
     	scanSettingsForCT(si->userName, si->sessionName, &liveCount, &expiredCount, conn);
 	}
     ++sessionsPerForkDone;
 
     if (sessionsPerForkDone >= perFork) 
 	// the fork has done all of its sessions
 	{
 
 	// Adjust for the fact that divisions have remainders.
 	// We want to split the list into numForks, but it often does not divide evenly.
 	// The first forkRem forks will get one extra session to do if forkRem > 0.
 	// It use important that we do not create any extra fork so that the count will
 	// match numForks (default 10) in the output.
 
 	++fork;