fsprobe: add fsprobe_Wait function
[openafs.git] / src / fsprobe / fsprobe_test.c
index eaa015d..7d78b6a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 #include <afsconfig.h>
 #include <afs/param.h>
 
+#include <roken.h>
 
-#include <string.h>
-#include <fsprobe.h>           /*Interface for fsprobe module */
+#include "fsprobe.h"           /*Interface for fsprobe module */
 #include <afs/afsutil.h>
-    
+
 /*------------------------------------------------------------------------
  * FS_Handler
  *
@@ -145,10 +145,9 @@ main(int argc, char **argv)
 {                              /*Main routine */
 
     static char rn[] = "fsprobe_test"; /*Routine name */
-    register afs_int32 code;   /*Return code */
+    afs_int32 code;    /*Return code */
     struct sockaddr_in FSSktArray[3];  /*socket array */
     struct hostent *he;                /*Host entry */
-    struct timeval tv;         /*Time structure */
     int sleep_secs;            /*Number of seconds to sleep */
 
     printf("\n\nTest of the fsprobe facility.\n\n");
@@ -156,12 +155,8 @@ main(int argc, char **argv)
     /*
      * Fill in the socket array for bigbird, vice1, and vice2.
      */
-#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
-    FSSktArray[0].sin_family = AF_INET;                /*Internet family */
-#else
-    FSSktArray[0].sin_family = htons(AF_INET); /*Internet family */
-#endif
-    FSSktArray[0].sin_port = htons(7000);      /*FileServer port */
+    FSSktArray[0].sin_family = AF_INET;
+    FSSktArray[0].sin_port = htons(7000);      /* FileServer port */
     he = hostutil_GetHostByName("servername1");
     if (he == NULL) {
        fprintf(stderr, "[%s] Can't get host info for servername1\n", rn);
@@ -169,12 +164,8 @@ main(int argc, char **argv)
     }
     memcpy(&(FSSktArray[0].sin_addr.s_addr), he->h_addr, 4);
 
-#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
-    FSSktArray[1].sin_family = AF_INET;                /*Internet address family */
-#else
-    FSSktArray[1].sin_family = htons(AF_INET); /*Internet address family */
-#endif
-    FSSktArray[1].sin_port = htons(7000);      /*FileServer port */
+    FSSktArray[1].sin_family = AF_INET;
+    FSSktArray[1].sin_port = htons(7000);      /* FileServer port */
     he = hostutil_GetHostByName("servername2");
     if (he == NULL) {
        fprintf(stderr, "[%s] Can't get host info for servername2\n", rn);
@@ -182,12 +173,8 @@ main(int argc, char **argv)
     }
     memcpy(&(FSSktArray[1].sin_addr.s_addr), he->h_addr, 4);
 
-#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
-    FSSktArray[2].sin_family = AF_INET;                /*Internet address family */
-#else
-    FSSktArray[2].sin_family = htons(AF_INET); /*Internet address family */
-#endif
-    FSSktArray[2].sin_port = htons(7000);      /*FileServer port */
+    FSSktArray[2].sin_family = AF_INET;
+    FSSktArray[2].sin_port = htons(7000);      /* FileServer port */
     he = hostutil_GetHostByName("servername3");
     if (he == NULL) {
        fprintf(stderr, "[%s] Can't get host info for servername3\n", rn);
@@ -223,20 +210,7 @@ main(int argc, char **argv)
        ("Fsprobe service started, main thread sleeping for %d seconds...\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);
-    }
+    fsprobe_Wait(sleep_secs);
 
     /*
      * We're all done.  Clean up, put the last nail in Rx, then