src/hg/utils/refreshNamedSessionCustomTracks/refreshNamedSessionCustomTracks.c 1.10
1.10 2009/05/19 23:54:31 angie
Instead of processing the hgcentral query of session info row by row, slurp the results into memory and then process. Hopefully this will reduce the frequency of losing the connection to hgcentral (currently 4x/day).
Index: src/hg/utils/refreshNamedSessionCustomTracks/refreshNamedSessionCustomTracks.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/utils/refreshNamedSessionCustomTracks/refreshNamedSessionCustomTracks.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -b -B -U 4 -r1.9 -r1.10
--- src/hg/utils/refreshNamedSessionCustomTracks/refreshNamedSessionCustomTracks.c 18 May 2009 21:38:07 -0000 1.9
+++ src/hg/utils/refreshNamedSessionCustomTracks/refreshNamedSessionCustomTracks.c 19 May 2009 23:54:31 -0000 1.10
@@ -131,8 +131,16 @@
freeMem(contentsToChop);
return updateIfAny;
}
+struct sessionInfo
+ {
+ struct sessionInfo *next;
+ char userName[256];
+ char sessionName[256];
+ char *contents;
+ };
+
void refreshNamedSessionCustomTracks(char *centralDbName)
/* refreshNamedSessionCustomTracks -- cron robot for keeping alive custom
* tracks that are referenced by saved sessions. */
{
@@ -151,27 +159,38 @@
verbose(2, "Got connection to %s\n", centralDbName);
if (sqlTableExists(conn, savedSessionTable))
{
+ struct sessionInfo *sessionList = NULL, *si;
struct sqlResult *sr = NULL;
char **row = NULL;
char query[512];
safef(query, sizeof(query),
"select userName,sessionName,contents from %s "
"order by userName,sessionName", savedSessionTable);
sr = sqlGetResult(conn, query);
+ // Slurp results into memory instead of processing row by row,
+ // reducing the chance of lost connection.
while ((row = sqlNextRow(sr)) != NULL)
{
- char *updateIfAny = scanSettingsForCT(row[0], row[1], row[2],
+ AllocVar(si);
+ safecpy(si->userName, sizeof(si->userName), row[0]);
+ safecpy(si->sessionName, sizeof(si->sessionName), row[1]);
+ si->contents = cloneString(row[2]);
+ slAddHead(&sessionList, si);
+ }
+ sqlFreeResult(&sr);
+ for (si = sessionList; si != NULL; si = si->next)
+ {
+ char *updateIfAny = scanSettingsForCT(si->userName, si->sessionName, si->contents,
&liveCount, &expiredCount);
if (updateIfAny)
{
AllocVar(update);
update->name = updateIfAny;
slAddHead(&updateList, update);
}
}
- sqlFreeResult(&sr);
}
/* Now that we're done reading from savedSessionTable, we can modify it: */
if (optionExists("hardcore"))