convert xstat and friends to pthreads 53/12753/13
authorMichael Meffie <mmeffie@sinenomine.net>
Tue, 17 Oct 2017 20:39:50 +0000 (16:39 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 25 Jan 2019 23:13:21 +0000 (18:13 -0500)
Convert the xstat, fsprobe, and gtx libraries and test programs to
pthreads. Build these libraries with libtool.

Build the scout and afsmonitor programs with pthreads instead of LWP.

Change-Id: Ie1737e71b4e57735bf7b6c7dc3177d717ea35ac6
Reviewed-on: https://gerrit.openafs.org/12753
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

19 files changed:
src/afsmonitor/Makefile.in
src/fsprobe/.gitignore
src/fsprobe/Makefile.in
src/fsprobe/fsprobe.c
src/fsprobe/liboafs_fsprobe.la.sym [new file with mode: 0644]
src/gtx/Makefile.in
src/gtx/input.c
src/gtx/liboafs_gtx.la.sym [new file with mode: 0644]
src/scout/Makefile.in
src/scout/scout.c
src/xstat/.gitignore
src/xstat/Makefile.in
src/xstat/NTMakefile
src/xstat/liboafs_xstat_cm.la.sym [new file with mode: 0644]
src/xstat/liboafs_xstat_fs.la.sym [new file with mode: 0644]
src/xstat/xstat_cm.c
src/xstat/xstat_cm_test.c
src/xstat/xstat_fs.c
src/xstat/xstat_fs_test.c

index 73ef4d2..ea9ab15 100644 (file)
@@ -7,7 +7,7 @@
 
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
-include @TOP_OBJDIR@/src/config/Makefile.lwp
+include @TOP_OBJDIR@/src/config/Makefile.pthread
 
 
 INCLS=${TOP_INCDIR}/afs/gtxobjects.h \
@@ -26,17 +26,19 @@ INCLS=${TOP_INCDIR}/afs/gtxobjects.h \
        ${TOP_INCDIR}/afs/xstat_cm.h \
        afsmonitor.h \
        afsmon-labels.h
-LIBS=${TOP_LIBDIR}/libxstat_fs.a \
-       ${TOP_LIBDIR}/libxstat_cm.a \
-       ${TOP_LIBDIR}/libgtx.a \
-       ${TOP_LIBDIR}/libafsint.a \
-       ${TOP_LIBDIR}/libcmd.a \
-       ${TOP_LIBDIR}/librx.a \
-       ${TOP_LIBDIR}/libafshcrypto_lwp.a \
-       ${TOP_LIBDIR}/liblwp.a \
-       ${TOP_LIBDIR}/libsys.a \
-       $(TOP_LIBDIR)/libopr.a \
-       ${TOP_LIBDIR}/util.a
+
+LT_deps=\
+       $(top_builddir)/src/xstat/liboafs_xstat_fs.la \
+       $(top_builddir)/src/xstat/liboafs_xstat_cm.la \
+       $(top_builddir)/src/gtx/liboafs_gtx.la \
+       $(top_builddir)/src/rxkad/liboafs_rxkad.la \
+       $(top_builddir)/src/fsint/liboafs_fsint.la \
+       $(top_builddir)/src/cmd/liboafs_cmd.la \
+       $(top_builddir)/src/util/liboafs_util.la \
+       $(top_builddir)/src/opr/liboafs_opr.la \
+       $(top_builddir)/src/lwp/liboafs_lwpcompat.la \
+       $(top_builddir)/src/volser/liboafs_volser.la \
+
 
 EXTRA_LIBS=${LIB_curses} ${XLIBS}
 
@@ -46,13 +48,13 @@ afsmon-output.o: afsmon-output.c ${INCLS}
 afsmon-win.o: afsmon-win.c ${INCLS}
 afsmonitor.o: afsmonitor.c ${INCLS} AFS_component_version_number.c
 
-afsmonitor: afsmonitor.o afsmon-win.o afsmon-output.o ${LIBS}
-       $(AFS_LDRULE) afsmonitor.o afsmon-win.o afsmon-output.o \
-               ${LIBS} $(LIB_roken) ${EXTRA_LIBS}
+afsmonitor: afsmonitor.o afsmon-win.o afsmon-output.o ${LT_deps}
+       $(LT_LDRULE_static) afsmonitor.o afsmon-win.o afsmon-output.o \
+               ${LT_deps} $(LIB_roken) ${EXTRA_LIBS}
 
-afsmon-parselog:  afsmon-parselog.o ${LIBS}
-       $(AFS_LDRULE) afsmon-parselog.c \
-               ${LIBS} $(LIB_roken) ${EXTRA_LIBS}
+afsmon-parselog:  afsmon-parselog.o ${LT_deps}
+       $(LT_LDRULE_static) afsmon-parselog.c \
+               ${LT_deps} $(LIB_roken) ${EXTRA_LIBS}
 
 install: afsmonitor
        ${INSTALL} -d ${DESTDIR}${bindir}
@@ -63,6 +65,7 @@ dest: afsmonitor
        ${INSTALL_PROGRAM} afsmonitor ${DEST}/bin/afsmonitor
 
 clean:
+       $(LT_CLEAN)
        $(RM) -f *.o afsmonitor AFS_component_version_number.c
 
 include ../config/Makefile.version
index bf549b4..72f58f1 100644 (file)
@@ -2,4 +2,6 @@
 #     git ls-files -i --exclude-standard
 # to check that you haven't inadvertently ignored any tracked files.
 
+/afscbint.h
+/afscbint.ss.c
 /fsprobe_test
index 3056500..fa9cb26 100644 (file)
@@ -7,29 +7,30 @@
 
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
-include @TOP_OBJDIR@/src/config/Makefile.lwp
-
-
-RPCINCLS=${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/rx/rx.h
-
-INCLS=fsprobe.h ${RPCINCLS}
-
-LIBS=${TOP_LIBDIR}/libvolser.a ${TOP_LIBDIR}/vlib.a ${TOP_LIBDIR}/libacl.a \
-        ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/libvldb.a \
-        ${TOP_LIBDIR}/libubik.a \
-        ${TOP_LIBDIR}/libauth.a ${TOP_LIBDIR}/libsys.a \
-        ${TOP_LIBDIR}/libcmd.a ${TOP_LIBDIR}/librxkad.a \
-        ${TOP_LIBDIR}/libafscom_err.a ${TOP_LIBDIR}/libkauth.a \
-       ${TOP_LIBDIR}/libaudit.a \
-       ${TOP_LIBDIR}/libafsint.a \
-       ${TOP_LIBDIR}/librx.a \
-       ${TOP_LIBDIR}/liblwp.a \
-       ${TOP_LIBDIR}/libsys.a \
-       ${TOP_LIBDIR}/util.a ${TOP_LIBDIR}/libopr.a \
-       ${TOP_LIBDIR}/libafsrfc3961.a \
-       ${TOP_LIBDIR}/libafshcrypto_lwp.a
-
-all: ${TOP_INCDIR}/afs/fsprobe.h ${TOP_LIBDIR}/libfsprobe.a fsprobe_test
+include @TOP_OBJDIR@/src/config/Makefile.pthread
+include @TOP_OBJDIR@/src/config/Makefile.libtool
+
+INCLS=fsprobe.h ${TOP_INCDIR}/rx/rx.h
+
+LT_deps = \
+       $(top_builddir)/src/rxkad/liboafs_rxkad.la \
+       $(top_builddir)/src/fsint/liboafs_fsint.la \
+       $(top_builddir)/src/cmd/liboafs_cmd.la \
+       $(top_builddir)/src/util/liboafs_util.la \
+       $(top_builddir)/src/opr/liboafs_opr.la \
+       $(top_builddir)/src/volser/liboafs_volser.la
+
+LT_objs = \
+    fsprobe.lo \
+    fsprobe_callback.lo \
+    afscbint.ss.lo \
+    AFS_component_version_number.lo
+
+all: \
+    liboafs_fsprobe.la \
+    ${TOP_INCDIR}/afs/fsprobe.h \
+    ${TOP_LIBDIR}/libfsprobe.a \
+    fsprobe_test
 
 ${TOP_INCDIR}/afs/fsprobe.h: fsprobe.h
        ${INSTALL_DATA} $? $@
@@ -40,18 +41,29 @@ ${TOP_LIBDIR}/libfsprobe.a: libfsprobe.a
 #
 # Build targets
 #
-libfsprobe.a: fsprobe.o fsprobe_callback.o AFS_component_version_number.o
-       -$(RM) -f $@
-       $(AR) crv $@ fsprobe.o fsprobe_callback.o AFS_component_version_number.o
-       $(RANLIB) $@
+liboafs_fsprobe.la: liboafs_fsprobe.la.sym $(LT_objs) $(LT_deps)
+       $(LT_LDLIB_shlib) $(LT_objs) $(LT_deps) $(LT_libs)
 
-fsprobe.o: fsprobe.c ${INCLS} AFS_component_version_number.c
+libfsprobe.a: $(LT_objs)
+       $(LT_LDLIB_static) $(LT_objs)
 
-fsprobe_callback.o: fsprobe_callback.c ${INCLS}
+# afscbint.ss.c is required for RXAFSCB_ExecuteRequest.
+afscbint.h: $(top_builddir)/src/fsint/afscbint.h
+       ${INSTALL_DATA} $? $@
 
-fsprobe_test: fsprobe_test.o libfsprobe.a ${LIBS}
-       $(AFS_LDRULE) fsprobe_test.o libfsprobe.a \
-               ${LIBS} $(LIB_roken) ${XLIBS}
+afscbint.ss.c: $(top_builddir)/src/fsint/afscbint.ss.c
+       ${INSTALL_DATA} $? $@
+
+fsprobe.lo: fsprobe.c ${INCLS} AFS_component_version_number.c
+fsprobe_callback.lo: fsprobe_callback.c ${INCLS}
+afscbint.ss.lo: afscbint.ss.c afscbint.h
+
+#
+# Test programs
+#
+fsprobe_test: fsprobe_test.o libfsprobe.a $(LT_deps)
+       $(LT_LDRULE_static) fsprobe_test.o libfsprobe.a \
+               $(LT_deps) $(LIB_roken) ${XLIBS}
 
 #
 # Install targets
@@ -72,6 +84,8 @@ dest: fsprobe.h libfsprobe.a
 # Misc others
 #
 clean:
-       $(RM) -f *.o fsprobe_test libfsprobe.a core AFS_component_version_number.c
+       $(LT_CLEAN)
+       $(RM) -f *.o afscbint.ss.c afscbint.h fsprobe_test libfsprobe.a \
+               core AFS_component_version_number.c
 
 include ../config/Makefile.version
index 8ddb320..00ed854 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <roken.h>
 
-#include <lwp.h>               /*Lightweight process package */
+#include <pthread.h>
 #include <afs/cellconfig.h>
 #include <afs/afsint.h>
 #include <afs/afsutil.h>
@@ -29,8 +29,6 @@
 
 #include "fsprobe.h"           /*Interface for this module */
 
-#define LWP_STACK_SIZE (16 * 1024)
-
 /*
  * Exported variables.
  */
@@ -45,9 +43,11 @@ int fsprobe_ProbeFreqInSecs; /*Probe freq. in seconds */
 static int fsprobe_initflag = 0;       /*Was init routine called? */
 static int fsprobe_debug = 0;  /*Debugging output enabled? */
 static int (*fsprobe_Handler) (void);  /*Probe handler routine */
-static PROCESS probeLWP_ID;    /*Probe LWP process ID */
+static pthread_t fsprobe_thread;       /*Probe thread */
 static int fsprobe_statsBytes; /*Num bytes in stats block */
 static int fsprobe_probeOKBytes;       /*Num bytes in probeOK block */
+static opr_mutex_t fsprobe_force_lock; /*Lock to force probe */
+static opr_cv_t fsprobe_force_cv;      /*Condvar to force probe */
 
 /*------------------------------------------------------------------------
  * [private] fsprobe_CleanupInit
@@ -194,7 +194,7 @@ fsprobe_Cleanup(int a_releaseMem)
  * [private] fsprobe_LWP
  *
  * Description:
- *     This LWP iterates over the server connections and gathers up
+ *     This thread iterates over the server connections and gathers up
  *     the desired statistics from each one on a regular basis.  When
  *     the sweep is done, the associated handler function is called
  *     to process the new data.
@@ -218,6 +218,7 @@ fsprobe_LWP(void *unused)
     static char rn[] = "fsprobe_LWP";  /*Routine name */
     afs_int32 code;    /*Results of calls */
     struct timeval tv;         /*Time structure */
+    struct timespec wait;      /*Time to wait */
     int conn_idx;              /*Connection index */
     struct fsprobe_ConnectionInfo *curr_conn;  /*Current connection */
     struct ProbeViceStatistics *curr_stats;    /*Current stats region */
@@ -352,20 +353,16 @@ fsprobe_LWP(void *unused)
                    rn, code);
 
        /*
-        * Fall asleep for the prescribed number of seconds.
+        * Fall asleep for the prescribed number of seconds or wakeup
+        * sooner if forced.
         */
-       tv.tv_sec = fsprobe_ProbeFreqInSecs;
-       tv.tv_usec = 0;
-       if (fsprobe_debug)
-           fprintf(stderr, "[%s] Falling asleep for %d seconds\n", rn,
-                   fsprobe_ProbeFreqInSecs);
-       code = IOMGR_Select(0,  /*Num fids */
-                           0,  /*Descriptors ready for reading */
-                           0,  /*Descriptors ready for writing */
-                           0,  /*Descriptors w/exceptional conditions */
-                           &tv);       /*Ptr to timeout structure */
-       if (code)
-           fprintf(stderr, "[%s] IOMGR_Select returned code %d\n", rn, code);
+       gettimeofday(&tv, NULL);
+       wait.tv_sec = tv.tv_sec + fsprobe_ProbeFreqInSecs;
+       wait.tv_nsec = tv.tv_usec * 1000;
+       opr_mutex_enter(&fsprobe_force_lock);
+       code = opr_cv_timedwait(&fsprobe_force_cv, &fsprobe_force_lock, &wait);
+       opr_Assert(code == 0 || code == ETIMEDOUT);
+       opr_mutex_exit(&fsprobe_force_lock);
     }                          /*Service loop */
     AFS_UNREACHED(free(stats64.ViceStatistics64_val));
     AFS_UNREACHED(return(NULL));
@@ -439,7 +436,7 @@ XListPartitions(struct rx_connection *aconn, struct partList *ptrPartList,
  *
  * Description:
  *     Initialize the fsprobe module: set up Rx connections to the
- *     given set of servers, start up the probe and callback LWPs,
+ *     given set of servers, start up the probe and callback threads,
  *     and associate the routine to be called when a probe completes.
  *
  * Arguments:
@@ -452,7 +449,7 @@ XListPartitions(struct rx_connection *aconn, struct partList *ptrPartList,
  * Returns:
  *     0 on success,
  *     -2 for (at least one) connection error,
- *     LWP process creation code, if it failed,
+ *     thread process creation code, if it failed,
  *     -1 for other fatal errors.
  *
  * Environment:
@@ -491,6 +488,9 @@ fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
     } else
        fsprobe_initflag = 1;
 
+    opr_mutex_init(&fsprobe_force_lock);
+    opr_cv_init(&fsprobe_force_cv);
+
     /*
      * Check the parameters for bogosities.
      */
@@ -543,11 +543,6 @@ fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
                (a_numServers * sizeof(struct fsprobe_ConnectionInfo)));
        return (-1);            /*No cleanup needs to be done yet */
     }
-#if 0
-    else
-       fprintf(stderr, "[%s] fsprobe_ConnInfo allocated (%d bytes)\n", rn,
-               a_numServers * sizeof(struct fsprobe_ConnectionInfo));
-#endif /* 0 */
 
     fsprobe_statsBytes = a_numServers * sizeof(struct ProbeViceStatistics);
     fsprobe_Results.stats = (struct ProbeViceStatistics *)
@@ -609,18 +604,18 @@ fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
 
     /*
      * Create a null Rx client security object, to be used by the
-     * probe LWP.
+     * probe thread.
      */
     secobj = rxnull_NewClientSecurityObject();
     if (secobj == (struct rx_securityClass *)0) {
        fprintf(stderr,
-               "[%s] Can't create client security object for probe LWP.\n",
+               "[%s] Can't create client security object for probe thread.\n",
                rn);
        fsprobe_Cleanup(1);     /*Delete already-malloc'ed areas */
        return (-1);
     }
     if (fsprobe_debug)
-       fprintf(stderr, "[%s] Probe LWP client security object created\n",
+       fprintf(stderr, "[%s] Probe thread client security object created\n",
                rn);
 
     curr_conn = fsprobe_ConnInfo;
@@ -743,37 +738,20 @@ fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
      */
     if (fsprobe_debug)
        fprintf(stderr, "[%s] Starting up callback listener.\n", rn);
-    rx_StartServer(0 /*Don't donate yourself to LWP pool */ );
+    rx_StartServer(0 /*Don't donate yourself to thread pool */ );
 
     /*
-     * Start up the probe LWP.
+     * Start up the probe thread.
      */
     if (fsprobe_debug)
-       fprintf(stderr, "[%s] Creating the probe LWP\n", rn);
-    code = LWP_CreateProcess(fsprobe_LWP,      /*Function to start up */
-                            LWP_STACK_SIZE,    /*Stack size in bytes */
-                            1, /*Priority */
-                            (void *)0, /*Parameters */
-                            "fsprobe Worker",  /*Name to use */
-                            &probeLWP_ID);     /*Returned LWP process ID */
+       fprintf(stderr, "[%s] Creating the probe thread\n", rn);
+    code = pthread_create(&fsprobe_thread, NULL, fsprobe_LWP, NULL);
     if (code) {
-       fprintf(stderr, "[%s] Can't create fsprobe LWP!  Error is %d\n", rn,
+       fprintf(stderr, "[%s] Can't create fsprobe thread!  Error is %d\n", rn,
                code);
        fsprobe_Cleanup(1);     /*Delete already-malloc'ed areas */
        return (code);
     }
-    if (fsprobe_debug)
-       fprintf(stderr, "[%s] Probe LWP process structure located at %p\n",
-               rn, probeLWP_ID);
-
-#if 0
-    /*
-     * Do I need to do this?
-     */
-    if (fsprobe_debug)
-       fprintf(stderr, "[%s] Calling osi_Wakeup()\n", rn);
-    osi_Wakeup(&rxsrv_afsserver);      /*Wake up anyone waiting for it */
-#endif /* 0 */
 
     /*
      * Return the final results.
@@ -790,7 +768,7 @@ fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
  * [exported] fsprobe_ForceProbeNow
  *
  * Description:
- *     Wake up the probe LWP, forcing it to execute a probe immediately.
+ *     Wake up the probe thread, forcing it to execute a probe immediately.
  *
  * Arguments:
  *     None.
@@ -823,7 +801,9 @@ fsprobe_ForceProbeNow(void)
     /*
      * Kick the sucker in the side.
      */
-    IOMGR_Cancel(probeLWP_ID);
+    opr_mutex_enter(&fsprobe_force_lock);
+    opr_cv_signal(&fsprobe_force_cv);
+    opr_mutex_exit(&fsprobe_force_lock);
 
     /*
      * We did it, so report the happy news.
@@ -861,14 +841,14 @@ fsprobe_Wait(int sleep_secs)
        while (1) {
            tv.tv_sec = 30;
            tv.tv_usec = 0;
-           code = IOMGR_Select(0, 0, 0, 0, &tv);
-           if (code != 0)
+           code = select(0, 0, 0, 0, &tv);
+           if (code < 0)
                break;
        }
     } else {
        tv.tv_sec = sleep_secs;
        tv.tv_usec = 0;
-       code = IOMGR_Select(0, 0, 0, 0, &tv);
+       code = select(0, 0, 0, 0, &tv);
     }
     return code;
 }
diff --git a/src/fsprobe/liboafs_fsprobe.la.sym b/src/fsprobe/liboafs_fsprobe.la.sym
new file mode 100644 (file)
index 0000000..8178f23
--- /dev/null
@@ -0,0 +1,4 @@
+fsprobe_Cleanup
+fsprobe_ForceProbeNow
+fsprobe_Init
+fsprobe_Wait
index 1688e6f..31a25a3 100644 (file)
@@ -9,10 +9,11 @@
 
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
-include @TOP_OBJDIR@/src/config/Makefile.lwp
+include @TOP_OBJDIR@/src/config/Makefile.pthread
+include @TOP_OBJDIR@/src/config/Makefile.libtool
 
-
-INCLS=gtxobjects.h \
+INCLS = \
+       gtxobjects.h \
        gtxwindows.h \
        gtxcurseswin.h \
        gtxinput.h \
@@ -28,50 +29,31 @@ INCLS=gtxobjects.h \
        ${TOP_INCDIR}/afs/cellconfig.h \
        ${TOP_INCDIR}/afs/cmd.h
 
-LIBS=\
-       ${TOP_LIBDIR}/librx.a \
-       ${TOP_LIBDIR}/liblwp.a \
-       ${TOP_LIBDIR}/libsys.a \
-       ${TOP_LIBDIR}/libcmd.a \
-       ${TOP_LIBDIR}/libkauth.a \
-       ${TOP_LIBDIR}/libauth.a \
-       ${TOP_LIBDIR}/librxkad.a \
-       ${TOP_LIBDIR}/libafsrfc3961.a \
-       ${TOP_LIBDIR}/libafscom_err.a \
-       ${TOP_LIBDIR}/libopr.a \
-       ${TOP_LIBDIR}/util.a
-
-EXTRA_LIBS=${LIB_curses} ${XLIBS}
-
-KEYMAP_SRCS=keymap.c input.c frame.c
-
-KEYMAP_OBJS=keymap.o input.o frame.o
-
-WINDOW_SRCS=curseswindows.c \
-       dumbwindows.c \
-       X11windows.c \
-       windows.c
-
-WINDOW_OBJS=curseswindows.o \
-       dumbwindows.o \
-       X11windows.o \
-       windows.o
-
-OBJECT_SRCS=objects.c \
-       lightobject.c \
-       textobject.c
-
-OBJECT_OBJS=objects.o \
-       lightobject.o \
-       textobject.o
-
-DICT_SRCS=objdict.c
-DICT_OBJS=objdict.o
-
-CB_SRCS=textcb.c
-CB_OBJS=textcb.o
-
-all: gtxtest \
+LT_objs = \
+    AFS_component_version_number.lo \
+    keymap.lo \
+    input.lo \
+    frame.lo \
+    curseswindows.lo \
+    dumbwindows.lo \
+    X11windows.lo \
+    windows.lo \
+    objects.lo \
+    lightobject.lo \
+    textobject.lo \
+    objdict.lo \
+    textcb.lo
+
+LT_libs = \
+       $(top_builddir)/src/rxkad/liboafs_rxkad.la \
+       $(top_builddir)/src/fsint/liboafs_fsint.la \
+       $(top_builddir)/src/cmd/liboafs_cmd.la \
+       $(top_builddir)/src/util/liboafs_util.la \
+       $(top_builddir)/src/opr/liboafs_opr.la \
+       $(top_builddir)/src/lwp/liboafs_lwpcompat.la
+
+all: \
+    liboafs_gtx.la \
        ${TOP_LIBDIR}/libgtx.a \
        ${TOP_INCDIR}/afs/gtxcurseswin.h \
        ${TOP_INCDIR}/afs/gtxdumbwin.h \
@@ -125,72 +107,50 @@ ${TOP_INCDIR}/afs/gtxwindows.h: gtxwindows.h
 ${TOP_INCDIR}/afs/gtxX11win.h: gtxX11win.h
        ${INSTALL_DATA} $? $@
 
-tests: object_test screen_test curses_test cb_test gtxtest
-
-# All objects in the library
-LIBSRCS = ${KEYMAP_SRCS} ${WINDOW_SRCS} ${OBJECT_SRCS} ${DICT_SRCS} ${CB_SRCS}
-LIBOBJS = $(KEYMAP_OBJS) ${WINDOW_OBJS} ${OBJECT_OBJS} ${DICT_OBJS} ${CB_OBJS}
-
-${LIBSRCS}: ${INCLS}
-$(LIBOBJS): ${INCLS}
-
-keymap.o: keymap.c ${INCLS}
-
-frame.o: frame.c $(INCLS)
-
-input.o: input.c ${INCLS}
-
-curseswindows.o: curseswindows.c ${INCLS}
-
-dumbwindows.o: dumbwindows.c ${INCLS}
-
-X11windows.o: X11windows.c ${INCLS}
-
-windows.o: windows.c ${INCLS}
-
-lightobject.o: lightobject.c ${INCLS}
-
-textobject.o: textobject.c ${INCLS}
-
-textcb.o: textcb.c ${INCLS}
-
 #
-# Test programs.
+# Build targets
 #
-curses_test.o: curses_test.c ${INCLS} AFS_component_version_number.o
-
-curses_test: curses_test.o $(LIBS)
-       $(AFS_LDRULE) curses_test.o $(LIBS) ${EXTRA_LIBS}
-
-screen_test.o: screen_test.c ${INCLS} AFS_component_version_number.o
-
-screen_test: screen_test.o ${WINDOW_OBJS} ${LIBS}
-       $(AFS_LDRULE) screen_test.o ${WINDOW_OBJS} ${LIBS} ${EXTRA_LIBS}
+liboafs_gtx.la: liboafs_gtx.la.sym $(LT_objs) $(LT_deps)
+       $(LT_LDLIB_shlib) $(LT_objs) $(LT_deps) $(LT_libs)
+
+libgtx.a: $(LT_objs)
+       $(LT_LDLIB_static) $(LT_objs)
+
+keymap.lo: keymap.c ${INCLS}
+frame.lo: frame.c $(INCLS)
+input.lo: input.c ${INCLS}
+curseswindows.lo: curseswindows.c ${INCLS}
+dumbwindows.lo: dumbwindows.c ${INCLS}
+X11windows.lo: X11windows.c ${INCLS}
+windows.lo: windows.c ${INCLS}
+lightobject.lo: lightobject.c ${INCLS}
+textobject.lo: textobject.c ${INCLS}
+objdict.lo: objdict.c ${INCLS}
+textcb.lo: textcb.c ${INCLS}
 
-cb_test.o: cb_test.c ${INCLS} AFS_component_version_number.o
+#
+# Test programs
+#
+tests: object_test screen_test curses_test cb_test gtxtest
 
-cb_test: cb_test.o ${CB_OBJS} ${LIBS}
-       $(AFS_LDRULE) cb_test.o ${CB_OBJS} ${LIBS} ${EXTRA_LIBS}
+object_test: object_test.o liboafs_gtx.la
+       $(LT_LDRULE_static) object_test.o liboafs_gtx.la ${LIB_curses} ${XLIBS}
 
-gtxtest.o: gtxtest.c ${INCLS} AFS_component_version_number.o
+screen_test: screen_test.o liboafs_gtx.la
+       $(LT_LDRULE_static) screen_test.o liboafs_gtx.la ${LIB_curses} ${XLIBS}
 
-gtxtest: gtxtest.o libgtx.a ${LIBS}
-       $(AFS_LDRULE) gtxtest.o libgtx.a ${LIBS} ${EXTRA_LIBS}
+curses_test: curses_test.o liboafs_gtx.la
+       $(LT_LDRULE_static) curses_test.o liboafs_gtx.la ${LIB_curses} ${XLIBS}
 
-object_test.o: object_test.c ${INCLS} AFS_component_version_number.o
+cb_test: cb_test.o liboafs_gtx.la
+       $(LT_LDRULE_static) cb_test.o liboafs_gtx.la ${LIB_curses} ${XLIBS}
 
-object_test: object_test.o ${WINDOW_OBJS} ${DICT_OBJS} ${OBJECT_OBJS} ${CB_OBJS} ${LIBS}
-       $(AFS_LDRULE) object_test.o ${WINDOW_OBJS} ${DICT_OBJS} \
-               ${OBJECT_OBJS} ${CB_OBJS} ${LIBS} ${EXTRA_LIBS}
+gtxtest: gtxtest.o liboafs_gtx.la
+       $(LT_LDRULE_static) gtxtest.o liboafs_gtx.la ${LIB_curses} ${XLIBS}
 
 #
 # Installation targets
 #
-libgtx.a: ${LIBOBJS} AFS_component_version_number.o
-       -$(RM) -f $@
-       $(AR) crv $@ ${LIBOBJS} AFS_component_version_number.o
-       ${RANLIB} $@
-
 install: libgtx.a
        ${INSTALL} -d ${DESTDIR}${libdir}/afs
        ${INSTALL} -d ${DESTDIR}${includedir}/afs
@@ -229,6 +189,7 @@ dest: libgtx.a
 # Misc targets
 #
 clean:
+       $(LT_CLEAN)
        $(RM) -f  *.o *.a *.ln object_test screen_test curses_test core cb_test gtxtest AFS_component_version_number.c
 
 include ../config/Makefile.version
index f7303f6..c1f1c47 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <roken.h>
 
-#include <lwp.h>
+#include <pthread.h>
 
 #include "gtxobjects.h"
 #include "gtxwindows.h"
@@ -21,6 +21,7 @@
 #include "gtxkeymap.h"
 #include "gtxframe.h"
 #include <afs/stds.h>
+#include <afs/opr.h>
 
 
 /* process input */
@@ -65,7 +66,7 @@ struct gwin *
 gtx_Init(int astartInput,
         int atype)                     /* type of window to create */
 {
-    PROCESS junk;
+    pthread_t thread_id;
     struct onode_initparams oi_params; /* object init params */
     struct gwin_initparams wi_params;  /* window initialization params */
     struct gwin *twin;
@@ -91,12 +92,8 @@ gtx_Init(int astartInput,
        return NULL;
 
     /* if we start input thread */
-    IOMGR_Initialize();                /* input thread uses it */
     if (astartInput) {
-       code = LWP_CreateProcess(gtx_InputServer, 8192, LWP_NORMAL_PRIORITY,
-                                NULL, "gx-listener", &junk);
-       if (code)
-           return NULL;
+       opr_Verify(pthread_create(&thread_id, NULL, gtx_InputServer, NULL) == 0);
     }
 
     /* all done */
diff --git a/src/gtx/liboafs_gtx.la.sym b/src/gtx/liboafs_gtx.la.sym
new file mode 100644 (file)
index 0000000..e84d031
--- /dev/null
@@ -0,0 +1,99 @@
+gator_cursesgwin_box
+gator_cursesgwin_cleanup
+gator_cursesgwin_clear
+gator_cursesgwin_create
+gator_cursesgwin_destroy
+gator_cursesgwin_display
+gator_cursesgwin_drawchar
+gator_cursesgwin_drawline
+gator_cursesgwin_drawrectangle
+gator_cursesgwin_drawstring
+gator_cursesgwin_getchar
+gator_cursesgwin_getdimensions
+gator_cursesgwin_init
+gator_cursesgwin_invert
+gator_cursesgwin_wait
+gator_dumbgwin_box
+gator_dumbgwin_cleanup
+gator_dumbgwin_clear
+gator_dumbgwin_create
+gator_dumbgwin_destroy
+gator_dumbgwin_display
+gator_dumbgwin_drawchar
+gator_dumbgwin_drawline
+gator_dumbgwin_drawrectangle
+gator_dumbgwin_drawstring
+gator_dumbgwin_getchar
+gator_dumbgwin_getdimensions
+gator_dumbgwin_init
+gator_dumbgwin_invert
+gator_dumbgwin_wait
+gator_light_create
+gator_light_destroy
+gator_light_display
+gator_light_release
+gator_light_set
+gator_objdict_add
+gator_objdict_delete
+gator_objdict_init
+gator_objdict_lookup
+gator_objects_create
+gator_objects_init
+gator_objects_lookup
+gator_text_BlankLine
+gator_textcb_BlankLine
+gator_textcb_Create
+gator_textcb_Delete
+gator_textcb_Init
+gator_textcb_Write
+gator_text_create
+gator_text_destroy
+gator_text_display
+gator_text_release
+gator_text_Scroll
+gator_text_Write
+gator_X11gwin_box
+gator_X11gwin_cleanup
+gator_X11gwin_clear
+gator_X11gwin_create
+gator_X11gwin_destroy
+gator_X11gwin_display
+gator_X11gwin_drawchar
+gator_X11gwin_drawline
+gator_X11gwin_drawrectangle
+gator_X11gwin_drawstring
+gator_X11gwin_getchar
+gator_X11gwin_getdimensions
+gator_X11gwin_init
+gator_X11gwin_invert
+gator_X11gwin_wait
+gtx_CopyString
+gtxframe_AddMenu
+gtxframe_AddToList
+gtxframe_AskForString
+gtxframe_ClearList
+gtxframe_ClearMenus
+gtxframe_ClearMessageLine
+gtxframe_Create
+gtxframe_CtrlHCmd
+gtxframe_CtrlUCmd
+gtxframe_Delete
+gtxframe_DeleteMenu
+gtxframe_Display
+gtxframe_DisplayString
+gtxframe_ExitCmd
+gtxframe_GetFrame
+gtxframe_RecursiveEndCmd
+gtxframe_RecursiveErrCmd
+gtxframe_RemoveFromList
+gtxframe_SelfInsertCmd
+gtxframe_SetFrame
+gtx_Init
+gtx_InputServer
+gw_init
+keymap_BindToString
+keymap_Create
+keymap_Delete
+keymap_InitState
+keymap_ProcessKey
+keymap_ResetState
index db0f161..47d1875 100644 (file)
@@ -7,7 +7,7 @@
 
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
-include @TOP_OBJDIR@/src/config/Makefile.lwp
+include @TOP_OBJDIR@/src/config/Makefile.pthread
 
 
 INCLS=${TOP_INCDIR}/afs/gtxobjects.h \
@@ -23,28 +23,16 @@ INCLS=${TOP_INCDIR}/afs/gtxobjects.h \
        ${TOP_INCDIR}/afs/cellconfig.h \
        ${TOP_INCDIR}/afs/cmd.h
 
-LIBS=${TOP_LIBDIR}/libgtx.a \
-       ${TOP_LIBDIR}/libfsprobe.a \
-       ${TOP_LIBDIR}/libvolser.a \
-        ${TOP_LIBDIR}/libubik.a \
-       ${TOP_LIBDIR}/libkauth.a \
-       ${TOP_LIBDIR}/libauth.a \
-       ${TOP_LIBDIR}/librxkad.a \
-       ${TOP_LIBDIR}/libcmd.a \
-       ${TOP_LIBDIR}/vlib.a \
-       ${TOP_LIBDIR}/libacl.a \
-        ${TOP_LIBDIR}/libvldb.a \
-       ${TOP_LIBDIR}/libafsint.a \
-       ${TOP_LIBDIR}/libsys.a \
-       ${TOP_LIBDIR}/librx.a \
-       ${TOP_LIBDIR}/libsys.a \
-       ${TOP_LIBDIR}/libaudit.a \
-       ${TOP_LIBDIR}/libafscom_err.a \
-       ${TOP_LIBDIR}/liblwp.a \
-       ${TOP_LIBDIR}/util.a \
-       ${TOP_LIBDIR}/libopr.a \
-       ${TOP_LIBDIR}/libafsrfc3961.a \
-       ${TOP_LIBDIR}/libafshcrypto_lwp.a
+LIBS=\
+       $(top_builddir)/src/fsprobe/liboafs_fsprobe.la \
+       $(top_builddir)/src/gtx/liboafs_gtx.la \
+       $(top_builddir)/src/rxkad/liboafs_rxkad.la \
+       $(top_builddir)/src/fsint/liboafs_fsint.la \
+       $(top_builddir)/src/cmd/liboafs_cmd.la \
+       $(top_builddir)/src/util/liboafs_util.la \
+       $(top_builddir)/src/opr/liboafs_opr.la \
+       $(top_builddir)/src/lwp/liboafs_lwpcompat.la \
+       $(top_builddir)/src/volser/liboafs_volser.la \
 
 all: scout
 
@@ -54,7 +42,7 @@ all: scout
 scout.o: scout.c ${INCLS} AFS_component_version_number.c
 
 scout: scout.o $(LIBS)
-       $(AFS_LDRULE) scout.o $(LIBS) $(LIB_roken) ${LIB_curses} ${XLIBS}
+       $(LT_LDRULE_static) scout.o $(LIBS) $(LIB_roken) ${LIB_curses} ${XLIBS}
 
 #
 # Installation targets
index 4a38b47..0194e34 100644 (file)
@@ -1636,10 +1636,6 @@ execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg)
     int i;                     /*Generic loop variable */
     int mini_line_bytes;       /*Num bytes in mini_lines */
     int linenum;               /*Current mini-line number */
-#if 0
-    PROCESS pid;               /*Main LWP process ID */
-    PROCESS gxlistener_ID;     /*Input Server LWP process ID */
-#endif /* 0 */
     struct gator_lightobj *lightdata;  /*Private light data */
 
     if (scout_debug) {
@@ -1648,16 +1644,10 @@ execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg)
     }
 
     /*
-     * We have to initialize LWP support before we start up any of
+     * We have to initialize thread support before we start up any of
      * our packages.
      */
-#if 0
-    code = LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid);
-    if (code) {
-       fprintf(stderr, "[%s:%s] Can't initialize LWP\n", pn, rn);
-       scout_CleanExit(code);
-    }
-#endif /* 0 */
+    opr_softsig_Init();
 
     /*
      * Initialize the gtx package.
@@ -1944,19 +1934,6 @@ execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg)
        return (-1);
     }
 
-
-    /*
-     * Start up the input server LWP for our window.
-     */
-#if 0
-    code = LWP_CreateProcess(gtx_InputServer,  /*Fcn to start up */
-                            8192,      /*Stack size in bytes */
-                            LWP_NORMAL_PRIORITY,       /*Priority */
-                            (void *)scout_gwin,        /*Params: Ptr to window */
-                            "gx-listener",     /*Name to use */
-                            &gxlistener_ID);   /*Returned LWP process ID */
-#endif /* 0 */
-
     code = (int)(intptr_t)gtx_InputServer(scout_gwin);
     if (code) {
        fprintf(stderr,
@@ -1966,16 +1943,6 @@ execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg)
     }
 
     fsprobe_Wait(0); /* sleep forever */
-
-#if 0
-    /*
-     * How did we get here?  Oh, well, clean up our windows and
-     * return sweetness and light anyway.
-     */
-    WOP_CLEANUP(&scout_gwin);
-    return (0);
-#endif /* 0 */
-
     return 0;
 }                              /*execute_scout */
 
index 9688fc3..be40652 100644 (file)
@@ -2,5 +2,7 @@
 #     git ls-files -i --exclude-standard
 # to check that you haven't inadvertently ignored any tracked files.
 
+/afscbint.h
+/afscbint.ss.c
 /xstat_cm_test
 /xstat_fs_test
index fcd0a42..596807b 100644 (file)
 
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
-include @TOP_OBJDIR@/src/config/Makefile.lwp
+include @TOP_OBJDIR@/src/config/Makefile.pthread
+include @TOP_OBJDIR@/src/config/Makefile.libtool
 
-
-RPCINCLS=${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/rx/rx.h
-
-LIBS=${TOP_LIBDIR}/libafsint.a \
-       ${TOP_LIBDIR}/libcmd.a \
-       ${TOP_LIBDIR}/librx.a \
-       ${TOP_LIBDIR}/libafshcrypto_lwp.a \
-       ${TOP_LIBDIR}/liblwp.a \
-       ${TOP_LIBDIR}/libsys.a \
-       ${TOP_LIBDIR}/libopr.a \
-       ${TOP_LIBDIR}/util.a
+LT_deps = \
+       $(top_builddir)/src/rxkad/liboafs_rxkad.la \
+       $(top_builddir)/src/fsint/liboafs_fsint.la \
+       $(top_builddir)/src/cmd/liboafs_cmd.la \
+       $(top_builddir)/src/util/liboafs_util.la \
+       $(top_builddir)/src/opr/liboafs_opr.la
 
 all: \
+       liboafs_xstat_fs.la \
+       liboafs_xstat_cm.la \
        ${TOP_INCDIR}/afs/xstat_fs.h \
        ${TOP_INCDIR}/afs/xstat_cm.h \
        ${TOP_LIBDIR}/libxstat_fs.a \
@@ -47,40 +45,61 @@ ${TOP_LIBDIR}/libxstat_cm.a: libxstat_cm.a
 #
 # File Server data collection
 #
-FSINCLS=xstat_fs.h ${RPCINCLS}
+FSINCLS = \
+    xstat_fs.h \
+    ${TOP_INCDIR}/rx/rx.h
 
-libxstat_fs.a: xstat_fs.o xstat_fs_callback.o AFS_component_version_number.o
-       -$(RM) -f $@
-       $(AR) crv $@ xstat_fs.o xstat_fs_callback.o AFS_component_version_number.o
-       $(RANLIB) $@
+LT_objs_fs = \
+    xstat_fs.lo \
+    xstat_fs_callback.lo \
+    afscbint.ss.lo \
+    AFS_component_version_number.lo
 
-xstat_fs.o: xstat_fs.c ${FSINCLS}
+liboafs_xstat_fs.la: liboafs_xstat_fs.la.sym $(LT_objs_fs) $(LT_deps)
+       $(LT_LDLIB_shlib) $(LT_objs_fs) $(LT_deps) $(LT_libs)
 
-xstat_fs_callback.o: xstat_fs_callback.c ${FSINCLS}
+libxstat_fs.a: $(LT_objs_fs)
+       $(LT_LDLIB_static) $(LT_objs_fs)
 
-xstat_fs_test.o: xstat_fs_test.c ${FSINCLS} AFS_component_version_number.c
+# afscbint.ss.c is required for RXAFSCB_ExecuteRequest.
+afscbint.h: $(top_builddir)/src/fsint/afscbint.h
+       ${INSTALL_DATA} $? $@
 
-xstat_fs_test: xstat_fs_test.o libxstat_fs.a ${LIBS}
-       $(AFS_LDRULE) xstat_fs_test.o libxstat_fs.a \
-               ${LIBS} $(LIB_roken) ${XLIBS}
+afscbint.ss.c: $(top_builddir)/src/fsint/afscbint.ss.c
+       ${INSTALL_DATA} $? $@
+
+xstat_fs.lo: xstat_fs.c ${FSINCLS}
+xstat_fs_callback.lo: xstat_fs_callback.c ${FSINCLS}
+xstat_fs_test.lo: xstat_fs_test.c ${FSINCLS} AFS_component_version_number.c
+afscbint.ss.lo: afscbint.ss.c afscbint.h
+
+xstat_fs_test: xstat_fs_test.o liboafs_xstat_fs.la $(LT_deps)
+       $(LT_LDRULE_static) xstat_fs_test.o liboafs_xstat_fs.la \
+               $(LT_deps) $(LIB_roken) ${XLIBS}
 
 #
 # Cache Manager data collection
 #
-CMINCLS=xstat_cm.h ${RPCINCLS}
+CMINCLS = \
+    xstat_cm.h \
+    ${TOP_INCDIR}/rx/rx.h
+
+LT_objs_cm = \
+    xstat_cm.lo \
+    AFS_component_version_number.lo
 
-libxstat_cm.a: xstat_cm.o AFS_component_version_number.o
-       -$(RM) -f libxstat_cm.a
-       $(AR) crv libxstat_cm.a xstat_cm.o AFS_component_version_number.o
-       $(RANLIB) libxstat_cm.a
+liboafs_xstat_cm.la: liboafs_xstat_cm.la.sym $(LT_objs_cm) $(LT_deps)
+       $(LT_LDLIB_shlib) $(LT_objs_cm) $(LT_deps) $(LT_libs)
 
-xstat_cm.o: xstat_cm.c ${CMINCLS}
+libxstat_cm.a: $(LT_objs_cm)
+       $(LT_LDLIB_static) $(LT_objs_cm)
 
+xstat_cm.lo: xstat_cm.c ${CMINCLS}
 xstat_cm_test.o: xstat_cm_test.c ${CMINCLS} AFS_component_version_number.c
 
-xstat_cm_test: xstat_cm_test.o libxstat_cm.a ${LIBS}
-       $(AFS_LDRULE) xstat_cm_test.o libxstat_cm.a \
-               ${LIBS} $(LIB_roken) ${XLIBS}
+xstat_cm_test: xstat_cm_test.o liboafs_xstat_cm.la $(LT_deps)
+       $(LT_LDRULE_static) xstat_cm_test.o liboafs_xstat_cm.la \
+               $(LT_deps) $(LIB_roken) ${XLIBS}
 
 #
 # Installation targets
@@ -113,6 +132,8 @@ dest: xstat_fs.h xstat_cm.h libxstat_fs.a libxstat_cm.a xstat_fs_test \
 # Misc targets
 #
 clean:
-       $(RM) -f *.o *.a xstat_fs_test xstat_cm_test core AFS_component_version_number.c
+       $(LT_CLEAN)
+       $(RM) -f *.o *.a afscbint.ss.c afscbint.h xstat_fs_test xstat_cm_test \
+              core AFS_component_version_number.c
 
 include ../config/Makefile.version
index a0c4cd5..587aaf9 100644 (file)
@@ -16,21 +16,20 @@ LIBDIR = $(DESTDIR)\lib
 INCDIR = $(DESTDIR)\include
 BINDIR = $(DESTDIR)\bin
 
-RPCINCLS=$(INCDIR)\lwp.h $(INCDIR)\rx\rx.h
+RPCINCLS=$(INCDIR)\rx\rx.h
 
 LIBS= \
-       $(LIBDIR)\afs\afsint.lib \
+       $(LIBDIR)\afs\mtafsint.lib \
        $(LIBDIR)\afs\afscmd.lib \
-       $(LIBDIR)\afsrx.lib \
+       $(LIBDIR)\afsrpc.lib \
        $(LIBDIR)\afshcrypto.lib \
-       $(LIBDIR)\afslwp.lib \
+       $(LIBDIR)\afspthread.lib \
        $(LIBDIR)\afs\afspioctl.lib \
-       $(LIBDIR)\afs\afsutil.lib \
+       $(LIBDIR)\afs\mtafsutil.lib \
        $(LIBDIR)\afs\afsreg.lib \
        $(LIBDIR)\afsroken.lib \
        $(LIBDIR)\opr.lib
 
-
 install: \
        $(INCDIR)\afs\xstat_fs.h \
        $(INCDIR)\afs\xstat_cm.h \
diff --git a/src/xstat/liboafs_xstat_cm.la.sym b/src/xstat/liboafs_xstat_cm.la.sym
new file mode 100644 (file)
index 0000000..00acbd8
--- /dev/null
@@ -0,0 +1,5 @@
+xstat_cm_Cleanup
+xstat_cm_ForceProbeNow
+xstat_cm_Init
+xstat_cm_Results
+xstat_cm_Wait
diff --git a/src/xstat/liboafs_xstat_fs.la.sym b/src/xstat/liboafs_xstat_fs.la.sym
new file mode 100644 (file)
index 0000000..8f5fef6
--- /dev/null
@@ -0,0 +1,5 @@
+xstat_fs_Cleanup
+xstat_fs_DecodeFullPerfStats
+xstat_fs_ForceProbeNow
+xstat_fs_Init
+xstat_fs_Wait
index 34fe72c..171aa73 100644 (file)
 #include <afs/param.h>
 
 #include <roken.h>
+#include <afs/opr.h>
 
 #include "xstat_cm.h"          /*Interface for this module */
-#include <lwp.h>               /*Lightweight process package */
+#include <pthread.h>
 
 #include <afs/afsutil.h>
 
-#define LWP_STACK_SIZE (16 * 1024)
-
 /*
  * Exported variables.
  */
@@ -46,9 +45,11 @@ static int xstat_cm_initflag = 0;    /*Was init routine called? */
 static int xstat_cm_debug = 0; /*Debugging output enabled? */
 static int xstat_cm_oneShot = 0;       /*One-shot operation? */
 static int (*xstat_cm_Handler) (void); /*Probe handler routine */
-static PROCESS probeLWP_ID;    /*Probe LWP process ID */
+static pthread_t xstat_cm_thread;      /*Probe thread */
 static int xstat_cm_numCollections;    /*Number of desired collections */
 static afs_int32 *xstat_cm_collIDP;    /*Ptr to collection IDs desired */
+static opr_mutex_t xstat_cm_force_lock;        /*Lock to wakeup probe */
+static opr_cv_t xstat_cm_force_cv;     /*Condvar to wakeup probe */
 
 
 /*------------------------------------------------------------------------
@@ -173,7 +174,7 @@ xstat_cm_Cleanup(int a_releaseMem)
  * [private] xstat_cm_LWP
  *
  * Description:
- *     This LWP iterates over the server connections and gathers up
+ *     This thread iterates over the server connections and gathers up
  *     the desired statistics from each one on a regular basis, for
  *     all known data collections.  The associated handler function
  *     is called each time a new data collection is received.
@@ -198,6 +199,7 @@ xstat_cm_LWP(void *unused)
     afs_int32 code;    /*Results of calls */
     int oneShotCode;           /*Result of one-shot signal */
     struct timeval tv;         /*Time structure */
+    struct timespec wait;      /*Time to wait */
     int conn_idx;              /*Connection index */
     struct xstat_cm_ConnectionInfo *curr_conn; /*Current connection */
     afs_int32 srvVersionNumber;        /*Xstat version # */
@@ -310,36 +312,25 @@ xstat_cm_LWP(void *unused)
 
        if (xstat_cm_oneShot) {
            /*
-            * One-shot execution desired.  Signal our main procedure
-            * that we've finished our collection round.
+            * One-shot execution desired.
             */
-           if (xstat_cm_debug)
-               printf("[%s] Signalling main process at %" AFS_PTR_FMT "\n", rn,
-                      &terminationEvent);
-           oneShotCode = LWP_SignalProcess(&terminationEvent);
-           if (oneShotCode)
-               fprintf(stderr, "[%s] Error %d from LWP_SignalProcess()", rn,
-                       oneShotCode);
            break;              /*from the perpetual while loop */
        } /*One-shot execution */
        else {
            /*
             * Continuous execution desired.  Sleep for the required
-            * number of seconds.
+            * number of seconds or wakeup sooner if forced.
             */
-           tv.tv_sec = xstat_cm_ProbeFreqInSecs;
-           tv.tv_usec = 0;
            if (xstat_cm_debug)
                printf("[%s] Falling asleep for %d seconds\n", rn,
                       xstat_cm_ProbeFreqInSecs);
-           code = IOMGR_Select(0,      /*Num fids */
-                               0,      /*Descs ready for reading */
-                               0,      /*Descs ready for writing */
-                               0,      /*Descs w/exceptional conditions */
-                               &tv);   /*Ptr to timeout structure */
-           if (code)
-               fprintf(stderr, "[%s] IOMGR_Select returned code %d\n", rn,
-                       code);
+           gettimeofday(&tv, NULL);
+           wait.tv_sec = tv.tv_sec + xstat_cm_ProbeFreqInSecs;
+           wait.tv_nsec = tv.tv_usec * 1000;
+           opr_mutex_enter(&xstat_cm_force_lock);
+           code = opr_cv_timedwait(&xstat_cm_force_cv, &xstat_cm_force_lock, &wait);
+           opr_Assert(code == 0 || code == ETIMEDOUT);
+           opr_mutex_exit(&xstat_cm_force_lock);
        }                       /*Continuous execution */
     }                          /*Service loop */
     return NULL;
@@ -351,7 +342,7 @@ xstat_cm_LWP(void *unused)
  *
  * Description:
  *     Initialize the xstat_cm module: set up Rx connections to the
- *     given set of Cache Managers, start up the probe LWP, and
+ *     given set of Cache Managers, start up the probe thread, and
  *     associate the routine to be called when a probe completes.
  *     Also, let it know which collections you're interested in.
  *
@@ -367,7 +358,7 @@ xstat_cm_LWP(void *unused)
  * Returns:
  *     0 on success,
  *     -2 for (at least one) connection error,
- *     LWP process creation code, if it failed,
+ *     thread process creation code, if it failed,
  *     -1 for other fatal errors.
  *
  * Environment:
@@ -404,6 +395,9 @@ xstat_cm_Init(int a_numServers, struct sockaddr_in *a_socketArray,
     } else
        xstat_cm_initflag = 1;
 
+    opr_mutex_init(&xstat_cm_force_lock);
+    opr_cv_init(&xstat_cm_force_cv);
+
     /*
      * Check the parameters for bogosities.
      */
@@ -497,17 +491,17 @@ xstat_cm_Init(int a_numServers, struct sockaddr_in *a_socketArray,
 
     /*
      * Create a null Rx client security object, to be used by the
-     * probe LWP.
+     * probe thread.
      */
     secobj = rxnull_NewClientSecurityObject();
     if (secobj == (struct rx_securityClass *)0) {
        fprintf(stderr,
-               "[%s] Can't create probe LWP client security object.\n", rn);
+               "[%s] Can't create probe thread client security object.\n", rn);
        xstat_cm_Cleanup(1);    /*Delete already-malloc'ed areas */
        return (-1);
     }
     if (xstat_cm_debug)
-       printf("[%s] Probe LWP client security object created\n", rn);
+       printf("[%s] Probe thread client security object created\n", rn);
 
     curr_conn = xstat_cm_ConnInfo;
     conn_err = 0;
@@ -569,25 +563,17 @@ xstat_cm_Init(int a_numServers, struct sockaddr_in *a_socketArray,
     }                          /*for curr_srv */
 
     /*
-     * Start up the probe LWP.
+     * Start up the probe thread.
      */
     if (xstat_cm_debug)
-       printf("[%s] Creating the probe LWP\n", rn);
-    code = LWP_CreateProcess(xstat_cm_LWP,     /*Function to start up */
-                            LWP_STACK_SIZE,    /*Stack size in bytes */
-                            1, /*Priority */
-                            (void *)0, /*Parameters */
-                            "xstat_cm Worker", /*Name to use */
-                            &probeLWP_ID);     /*Returned LWP process ID */
+       printf("[%s] Creating the probe thread\n", rn);
+    code = pthread_create(&xstat_cm_thread, NULL, xstat_cm_LWP, NULL);
     if (code) {
-       fprintf(stderr, "[%s] Can't create xstat_cm LWP!  Error is %d\n", rn,
+       fprintf(stderr, "[%s] Can't create xstat_cm thread!  Error is %d\n", rn,
                code);
        xstat_cm_Cleanup(1);    /*Delete already-malloc'ed areas */
        return (code);
     }
-    if (xstat_cm_debug)
-       printf("[%s] Probe LWP process structure located at %" AFS_PTR_FMT "\n", rn,
-              probeLWP_ID);
 
     /*
      * Return the final results.
@@ -603,7 +589,7 @@ xstat_cm_Init(int a_numServers, struct sockaddr_in *a_socketArray,
  * [exported] xstat_cm_ForceProbeNow
  *
  * Description:
- *     Wake up the probe LWP, forcing it to execute a probe immediately.
+ *     Wake up the probe thread, forcing it to execute a probe immediately.
  *
  * Arguments:
  *     None.
@@ -635,7 +621,9 @@ xstat_cm_ForceProbeNow(void)
     /*
      * Kick the sucker in the side.
      */
-    IOMGR_Cancel(probeLWP_ID);
+    opr_mutex_enter(&xstat_cm_force_lock);
+    opr_cv_signal(&xstat_cm_force_cv);
+    opr_mutex_exit(&xstat_cm_force_lock);
 
     /*
      * We did it, so report the happy news.
@@ -666,14 +654,13 @@ xstat_cm_Wait(int sleep_secs)
         * One-shot operation; just wait for the collection to be done.
         */
        if (xstat_cm_debug)
-           printf("[%s] Calling LWP_WaitProcess() on event %" AFS_PTR_FMT
-                  "\n", rn, &terminationEvent);
-       code = LWP_WaitProcess(&terminationEvent);
+           printf("[%s] Calling pthread_join()\n", rn);
+       code = pthread_join(xstat_cm_thread, NULL);
        if (xstat_cm_debug)
-           printf("[%s] Returned from LWP_WaitProcess()\n", rn);
+           printf("[%s] Returned from pthread_join()\n", rn);
        if (code) {
            fprintf(stderr,
-                   "[%s] Error %d encountered by LWP_WaitProcess()\n",
+                   "[%s] Error %d encountered by pthread_join()\n",
                    rn, code);
        }
     } else if (sleep_secs == 0) {
@@ -681,17 +668,15 @@ xstat_cm_Wait(int sleep_secs)
        tv.tv_sec = 24 * 60;
        tv.tv_usec = 0;
        if (xstat_cm_debug)
-           fprintf(stderr, "[ %s ] going to sleep ...\n", rn);
+           fprintf(stderr, "[%s] going to sleep ...\n", rn);
        while (1) {
-           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);
+           code = select(0,    /*Num fds */
+                         0,    /*Descriptors ready for reading */
+                         0,    /*Descriptors ready for writing */
+                         0,    /*Descriptors with exceptional conditions */
+                         &tv); /*Timeout structure */
+           if (code < 0) {
+               fprintf(stderr, "[%s] select() error %d\n", rn, errno);
                break;
            }
        }
@@ -703,15 +688,13 @@ xstat_cm_Wait(int sleep_secs)
                 sleep_secs);
        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);
+       code = select(0,        /*Num fds */
+                     0,        /*Descriptors ready for reading */
+                     0,        /*Descriptors ready for writing */
+                     0,        /*Descriptors with exceptional conditions */
+                     &tv);     /*Timeout structure */
+       if (code < 0)
+           fprintf(stderr, "[%s] select() error: %d\n", rn, errno);
     }
     return code;
 }
index c146172..e65177c 100644 (file)
@@ -21,6 +21,7 @@
 #include "xstat_cm.h"          /*Interface for xstat_cm module */
 #include <afs/cmd.h>           /*Command line interpreter */
 #include <afs/afsutil.h>
+#include <opr/softsig.h>
 
 /*
  * Command line parameter indices.
@@ -751,6 +752,8 @@ RunTheTest(struct cmd_syndesc *a_s, void *arock)
     int freq;                  /*Frequency of polls */
     int period;                        /*Time in minutes of data collection */
 
+    opr_softsig_Init();
+
     /*
      * Are we doing one-shot measurements?
      */
index e4f72b8..ba2066e 100644 (file)
 #include <afs/param.h>
 
 #include <roken.h>
+#include <afs/opr.h>
 
 #include "xstat_fs.h"          /*Interface for this module */
-#include <lwp.h>               /*Lightweight process package */
+#include <pthread.h>
 
 #include <afs/afsutil.h>
 #include <afs/afscbint.h>
 
-#define LWP_STACK_SIZE (16 * 1024)
-
 /*
  * Exported variables.
  */
@@ -47,9 +46,11 @@ static int xstat_fs_initflag = 0;    /*Was init routine called? */
 static int xstat_fs_debug = 0; /*Debugging output enabled? */
 static int xstat_fs_oneShot = 0;       /*One-shot operation? */
 static int (*xstat_fs_Handler) (void); /*Probe handler routine */
-static PROCESS probeLWP_ID;    /*Probe LWP process ID */
+static pthread_t xstat_fs_thread;      /*Probe thread */
 static int xstat_fs_numCollections;    /*Number of desired collections */
 static afs_int32 *xstat_fs_collIDP;    /*Ptr to collection IDs desired */
+static opr_mutex_t xstat_fs_force_lock;        /*Lock to wakeup probe */
+static opr_cv_t xstat_fs_force_cv;     /*Condvar to wakeup probe */
 
 
 /*------------------------------------------------------------------------
@@ -194,7 +195,7 @@ xstat_fs_Cleanup(int a_releaseMem)
  * [private] xstat_fs_LWP
  *
  * Description:
- *     This LWP iterates over the server connections and gathers up
+ *     This thread iterates over the server connections and gathers up
  *     the desired statistics from each one on a regular basis.  When
  *     the sweep is done, the associated handler function is called
  *     to process the new data.
@@ -216,10 +217,10 @@ xstat_fs_Cleanup(int a_releaseMem)
 static void *
 xstat_fs_LWP(void *unused)
 {
-    static char rn[] = "xstat_fs_LWP"; /*Routine name */
+    static char rn[] = "xstat_fs_thread";      /*Routine name */
     afs_int32 code;    /*Results of calls */
-    int oneShotCode;           /*Result of one-shot signal */
     struct timeval tv;         /*Time structure */
+    struct timespec wait;      /*Time to wait */
     int conn_idx;              /*Connection index */
     struct xstat_fs_ConnectionInfo *curr_conn; /*Current connection */
     afs_int32 srvVersionNumber;        /*Xstat version # */
@@ -329,36 +330,21 @@ xstat_fs_LWP(void *unused)
 
        if (xstat_fs_oneShot) {
            /*
-            * One-shot execution desired.  Signal our main procedure
-            * that we've finished our collection round.
+            * One-shot execution desired.
             */
-           if (xstat_fs_debug)
-               printf("[%s] Signalling main process at %" AFS_PTR_FMT "\n", rn,
-                      &terminationEvent);
-           oneShotCode = LWP_SignalProcess(&terminationEvent);
-           if (oneShotCode)
-               fprintf(stderr, "[%s] Error %d from LWP_SignalProcess()", rn,
-                       oneShotCode);
-           break;              /*from the perpetual while loop */
-       } /*One-shot execution */
-       else {
+           break;
+       } else {
            /*
             * Continuous execution desired.  Sleep for the required
-            * number of seconds.
+            * number of seconds or wakeup sooner if forced.
             */
-           tv.tv_sec = xstat_fs_ProbeFreqInSecs;
-           tv.tv_usec = 0;
-           if (xstat_fs_debug)
-               printf("[%s] Falling asleep for %d seconds\n", rn,
-                      xstat_fs_ProbeFreqInSecs);
-           code = IOMGR_Select(0,      /*Num fids */
-                               0,      /*Descs ready for reading */
-                               0,      /*Descs ready for writing */
-                               0,      /*Descs w/exceptional conditions */
-                               &tv);   /*Ptr to timeout structure */
-           if (code)
-               fprintf(stderr, "[%s] IOMGR_Select returned code %d\n", rn,
-                       code);
+           gettimeofday(&tv, NULL);
+           wait.tv_sec = tv.tv_sec + xstat_fs_ProbeFreqInSecs;
+           wait.tv_nsec = tv.tv_usec * 1000;
+           opr_mutex_enter(&xstat_fs_force_lock);
+           code = opr_cv_timedwait(&xstat_fs_force_cv, &xstat_fs_force_lock, &wait);
+           opr_Verify(code == 0 || code == ETIMEDOUT);
+           opr_mutex_exit(&xstat_fs_force_lock);
        }                       /*Continuous execution */
     }                          /*Service loop */
     return NULL;
@@ -369,7 +355,7 @@ xstat_fs_LWP(void *unused)
  *
  * Description:
  *     Initialize the xstat_fs module: set up Rx connections to the
- *     given set of File Servers, start up the probe and callback LWPs,
+ *     given set of File Servers, start up the probe and callback threads,
  *     and associate the routine to be called when a probe completes.
  *     Also, let it know which collections you're interested in.
  *
@@ -425,6 +411,9 @@ xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray,
     } else
        xstat_fs_initflag = 1;
 
+    opr_mutex_init(&xstat_fs_force_lock);
+    opr_cv_init(&xstat_fs_force_cv);
+
     /*
      * Check the parameters for bogosities.
      */
@@ -532,17 +521,17 @@ xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray,
 
     /*
      * Create a null Rx client security object, to be used by the
-     * probe LWP.
+     * probe thread.
      */
     secobj = rxnull_NewClientSecurityObject();
     if (secobj == (struct rx_securityClass *)0) {
        fprintf(stderr,
-               "[%s] Can't create probe LWP client security object.\n", rn);
+               "[%s] Can't create probe thread client security object.\n", rn);
        xstat_fs_Cleanup(1);    /*Delete already-malloc'ed areas */
        return (-1);
     }
     if (xstat_fs_debug)
-       printf("[%s] Probe LWP client security object created\n", rn);
+       printf("[%s] Probe thread client security object created\n", rn);
 
     curr_conn = xstat_fs_ConnInfo;
     conn_err = 0;
@@ -636,22 +625,14 @@ xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray,
      * Start up the probe LWP.
      */
     if (xstat_fs_debug)
-       printf("[%s] Creating the probe LWP\n", rn);
-    code = LWP_CreateProcess(xstat_fs_LWP,     /*Function to start up */
-                            LWP_STACK_SIZE,    /*Stack size in bytes */
-                            1, /*Priority */
-                            (void *)0, /*Parameters */
-                            "xstat_fs Worker", /*Name to use */
-                            &probeLWP_ID);     /*Returned LWP process ID */
+       printf("[%s] Creating the probe thread\n", rn);
+    code = pthread_create(&xstat_fs_thread, NULL, xstat_fs_LWP, NULL);
     if (code) {
-       fprintf(stderr, "[%s] Can't create xstat_fs LWP!  Error is %d\n", rn,
+       fprintf(stderr, "[%s] Can't create xstat_fs thread!  Error is %d\n", rn,
                code);
        xstat_fs_Cleanup(1);    /*Delete already-malloc'ed areas */
        return (code);
     }
-    if (xstat_fs_debug)
-       printf("[%s] Probe LWP process structure located at %" AFS_PTR_FMT "\n", rn,
-              probeLWP_ID);
 
     /*
      * Return the final results.
@@ -667,7 +648,7 @@ xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray,
  * [exported] xstat_fs_ForceProbeNow
  *
  * Description:
- *     Wake up the probe LWP, forcing it to execute a probe immediately.
+ *     Wake up the probe thread, forcing it to execute a probe immediately.
  *
  * Arguments:
  *     None.
@@ -699,7 +680,9 @@ xstat_fs_ForceProbeNow(void)
     /*
      * Kick the sucker in the side.
      */
-    IOMGR_Cancel(probeLWP_ID);
+    opr_mutex_enter(&xstat_fs_force_lock);
+    opr_cv_signal(&xstat_fs_force_cv);
+    opr_mutex_exit(&xstat_fs_force_lock);
 
     /*
      * We did it, so report the happy news.
@@ -864,14 +847,13 @@ xstat_fs_Wait(int sleep_secs)
         * One-shot operation; just wait for the collection to be done.
         */
        if (xstat_fs_debug)
-           printf("[%s] Calling LWP_WaitProcess() on event %" AFS_PTR_FMT
-                  "\n", rn, &terminationEvent);
-       code = LWP_WaitProcess(&terminationEvent);
+           printf("[%s] Calling pthread_join\n", rn);
+       code = pthread_join(xstat_fs_thread, NULL);
        if (xstat_fs_debug)
-           printf("[%s] Returned from LWP_WaitProcess()\n", rn);
+           printf("[%s] Returned from pthread_join()\n", rn);
        if (code) {
            fprintf(stderr,
-                   "[%s] Error %d encountered by LWP_WaitProcess()\n",
+                   "[%s] Error %d encountered by pthread_join()\n",
                    rn, code);
        }
     } else if (sleep_secs == 0) {
@@ -881,15 +863,13 @@ xstat_fs_Wait(int sleep_secs)
        if (xstat_fs_debug)
            fprintf(stderr, "[ %s ] going to sleep ...\n", rn);
        while (1) {
-           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);
+           code = select(0,    /*Num fds */
+                         0,    /*Descriptors ready for reading */
+                         0,    /*Descriptors ready for writing */
+                         0,    /*Descriptors with exceptional conditions */
+                         &tv); /*Timeout structure */
+           if (code < 0) {
+               fprintf(stderr, "[%s] select() error %d\n", rn, errno);
                break;
            }
        }
@@ -901,15 +881,13 @@ xstat_fs_Wait(int sleep_secs)
                 sleep_secs);
        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);
+       code = select(0,        /*Num fds */
+                     0,        /*Descriptors ready for reading */
+                     0,        /*Descriptors ready for writing */
+                     0,        /*Descriptors with exceptional conditions */
+                     &tv);     /*Timeout structure */
+       if (code < 0)
+           fprintf(stderr, "[%s] select() error %d\n", rn, errno);
     }
     return code;
 }
index 59ec162..a066e8b 100644 (file)
@@ -21,6 +21,7 @@
 #include "xstat_fs.h"          /*Interface for xstat_fs module */
 #include <afs/cmd.h>           /*Command line interpreter */
 #include <afs/afsutil.h>
+#include <opr/softsig.h>
 
 /*
  * Command line parameter indices.
@@ -664,6 +665,8 @@ RunTheTest(struct cmd_syndesc *a_s, void *dummy)
     int freq;                  /*Frequency of polls */
     int period;                        /*Time in minutes of data collection */
 
+    opr_softsig_Init();
+
     /*
      * Are we doing one-shot measurements?
      */