xstat: add xstat_*_Wait functions
[openafs.git] / src / xstat / xstat_fs_test.c
index d1e1fa3..59ec162 100644 (file)
@@ -660,10 +660,7 @@ RunTheTest(struct cmd_syndesc *a_s, void *dummy)
     struct cmd_item *curr_item;        /*Current FS cmd line record */
     struct sockaddr_in FSSktArray[20]; /*File Server socket array - FIX! */
     struct hostent *he;                /*Host entry */
-    struct timeval tv;         /*Time structure */
-    int sleep_secs;            /*Number of seconds to sleep */
     int initFlags;             /*Flags passed to the init fcn */
-    int waitCode;              /*Result of LWP_WaitProcess() */
     int freq;                  /*Frequency of polls */
     int period;                        /*Time in minutes of data collection */
 
@@ -772,47 +769,8 @@ RunTheTest(struct cmd_syndesc *a_s, void *dummy)
        exit(-1);
     }
 
-    if (one_shot) {
-       /*
-        * One-shot operation; just wait for the collection to be done.
-        */
-       if (debugging_on)
-           printf("[%s] Calling LWP_WaitProcess() on event %" AFS_PTR_FMT "\n", rn,
-                  &terminationEvent);
-       waitCode = LWP_WaitProcess(&terminationEvent);
-       if (debugging_on)
-           printf("[%s] Returned from LWP_WaitProcess()\n", rn);
-       if (waitCode) {
-           if (debugging_on)
-               fprintf(stderr,
-                       "[%s] Error %d encountered by LWP_WaitProcess()\n",
-                       rn, waitCode);
-       }
-    } else {
-       /*
-        * Continuous operation.
-        */
-       sleep_secs = 60 * period;       /*length of data collection */
-       printf
-           ("xstat_fs service started, main thread sleeping for %d secs.\n",
-            sleep_secs);
-
-       /*
-        * Let's just fall asleep for a while, then we'll clean up.
-        */
-       tv.tv_sec = sleep_secs;
-       tv.tv_usec = 0;
-       code = IOMGR_Select(0,  /*Num fds */
-                           0,  /*Descriptors ready for reading */
-                           0,  /*Descriptors ready for writing */
-                           0,  /*Descriptors with exceptional conditions */
-                           &tv);       /*Timeout structure */
-       if (code) {
-           fprintf(stderr,
-                   "[%s] IOMGR_Select() returned non-zero value: %d\n", rn,
-                   code);
-       }
-    }
+    /* Wait for the collection complete. */
+    xstat_fs_Wait(60 * period);
 
     /*
      * We're all done.  Clean up, put the last nail in Rx, then
@@ -821,7 +779,7 @@ RunTheTest(struct cmd_syndesc *a_s, void *dummy)
     if (debugging_on)
        printf("\nYawn, main thread just woke up.  Cleaning things out...\n");
 
-    code = xstat_fs_Cleanup(1);        /*Get rid of malloc'ed data */
+    xstat_fs_Cleanup(1);       /*Get rid of malloc'ed data */
     rx_Finalize();
     return (0);
 }
@@ -839,7 +797,7 @@ main(int argc, char **argv)
     /*
      * Set up the commands we understand.
      */
-    ts = cmd_CreateSyntax("initcmd", RunTheTest, 0, "initialize the program");
+    ts = cmd_CreateSyntax("initcmd", RunTheTest, 0, 0, "initialize the program");
     cmd_AddParm(ts, "-fsname", CMD_LIST, CMD_REQUIRED,
                "File Server name(s) to monitor");
     cmd_AddParm(ts, "-collID", CMD_LIST, CMD_REQUIRED,