16f04f5bdeccc1ad1d90c6f17d150e956bec6ecb
kent
  Mon Jan 13 19:34:09 2014 -0800
Librarified some message-the-hub stuff so can reuse
diff --git src/parasol/para/para.c src/parasol/para/para.c
index 88369fa..5b6771d 100644
--- src/parasol/para/para.c
+++ src/parasol/para/para.c
@@ -688,63 +688,30 @@
     {
     line = skipLeadingSpaces(line);
     if (line[0] == '#' || line[0] == 0)
        continue;
     job = jobCommaIn(&line, NULL);
     slAddHead(&db->jobList, job);
     ++db->jobCount;
     }
 lineFileClose(&lf);
 slReverse(&db->jobList);
 verbose(1, "%d jobs in batch\n", db->jobCount);
 verbose(2, "readBatch time: %.2f seconds\n", (clock1000() - time) / 1000.0);
 return db;
 }
 
-struct slRef *hubMultilineQuery(char *query)
-/* Send a command with a multiline response to hub,
- * and return response as a list of strings. */
-{
-struct slRef *list = NULL;
-struct rudp *ru = rudpMustOpen();
-struct paraMessage pm;
-struct paraMultiMessage pmm;
-char *row[256];
-int count = 0;
-pmInitFromName(&pm, "localhost", paraHubPort);
-/* ensure the multi-message response comes from the correct ip and has no duplicate msgs*/
-pmmInit(&pmm, &pm, pm.ipAddress.sin_addr);
-if (!pmSendStringWithRetries(&pm, ru, query))
-    noWarnAbort();
-for (;;)
-    {
-    if (!pmmReceive(&pmm, ru))
-	break;
-    if (pm.size == 0)
-	break;
-    count = chopByChar(pm.data, '\n', row, sizeof(row));
-    if (count > 1) --count;  /* for multiline, count is inflated by one */
-
-    int i;
-    for(i=0;i<count;++i)
-        refAdd(&list, cloneString(row[i]));
-    }
-rudpClose(&ru);
-slReverse(&list);
-return list;
-}
-
 boolean batchRunning(char *batchName)
 /* Return TRUE if a batch is running. */
 {
 #define NUMLISTBATCHCOLUMNS 12
 struct slRef *lineList = hubMultilineQuery("listBatches"), *lineEl;
 boolean ret = FALSE;
 for (lineEl = lineList; lineEl != NULL; lineEl = lineEl->next)
     {
     int wordCount;
     char *line = lineEl->val;
     char *row[NUMLISTBATCHCOLUMNS];
     if (line[0] != '#')
 	{
 	char *b;
 	wordCount = chopLine(line, row);
@@ -783,30 +750,37 @@
     job = jobFromLine(lf, line);
     slAddHead(&db->jobList, job);
     }
 lineFileClose(&lf);
 slReverse(&db->jobList);
 return db;
 }
 
 char *hubSingleLineQuery(char *query)
 /* Send message to hub and get single line response.
  * This should be freeMem'd when done. */
 {
 return pmHubSingleLineQuery(query, "localhost");
 }
 
+struct slRef *hubMultilineQuery(char *query)
+/* Send a command with a multiline response to hub,
+ * and return response as a list of strings. */
+{
+return pmHubMultilineQuery(query, "localhost");
+}
+
 void sendSetPriorityMessage(int priority)
 /* Tell hub to change priority on batch */
 {
 struct dyString *dy = newDyString(1024);
 char *result;
 if ((priority < 1) || (priority > MAX_PRIORITY))
     errAbort("Priority %d out of range, should be 1 to %d",priority,MAX_PRIORITY);
 dyStringPrintf(dy, "setPriority %s %s %d", getUser(), resultsName, priority);
 result = hubSingleLineQuery(dy->string);
 dyStringFree(&dy);
 if (result == NULL || sameString(result, "0"))
     errAbort("Couldn't set priority for %s\n", batchDir);
 freez(&result);
 verbose(1, "Told hub to set priority %d\n",priority);
 }