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 \
${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}
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}
${INSTALL_PROGRAM} afsmonitor ${DEST}/bin/afsmonitor
clean:
+ $(LT_CLEAN)
$(RM) -f *.o afsmonitor AFS_component_version_number.c
include ../config/Makefile.version
# git ls-files -i --exclude-standard
# to check that you haven't inadvertently ignored any tracked files.
+/afscbint.h
+/afscbint.ss.c
/fsprobe_test
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} $? $@
#
# 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
# 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
#include <roken.h>
-#include <lwp.h> /*Lightweight process package */
+#include <pthread.h>
#include <afs/cellconfig.h>
#include <afs/afsint.h>
#include <afs/afsutil.h>
#include "fsprobe.h" /*Interface for this module */
-#define LWP_STACK_SIZE (16 * 1024)
-
/*
* Exported variables.
*/
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
* [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.
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 */
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));
*
* 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:
* 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:
} else
fsprobe_initflag = 1;
+ opr_mutex_init(&fsprobe_force_lock);
+ opr_cv_init(&fsprobe_force_cv);
+
/*
* Check the parameters for bogosities.
*/
(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 *)
/*
* 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;
*/
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.
* [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.
/*
* 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.
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;
}
--- /dev/null
+fsprobe_Cleanup
+fsprobe_ForceProbeNow
+fsprobe_Init
+fsprobe_Wait
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 \
${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 \
${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
# 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
#include <roken.h>
-#include <lwp.h>
+#include <pthread.h>
#include "gtxobjects.h"
#include "gtxwindows.h"
#include "gtxkeymap.h"
#include "gtxframe.h"
#include <afs/stds.h>
+#include <afs/opr.h>
/* process input */
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;
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 */
--- /dev/null
+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
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 \
${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
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
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) {
}
/*
- * 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.
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,
}
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 */
# 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
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 \
#
# 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
# 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
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 \
--- /dev/null
+xstat_cm_Cleanup
+xstat_cm_ForceProbeNow
+xstat_cm_Init
+xstat_cm_Results
+xstat_cm_Wait
--- /dev/null
+xstat_fs_Cleanup
+xstat_fs_DecodeFullPerfStats
+xstat_fs_ForceProbeNow
+xstat_fs_Init
+xstat_fs_Wait
#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.
*/
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 */
/*------------------------------------------------------------------------
* [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.
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 # */
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;
*
* 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.
*
* 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:
} else
xstat_cm_initflag = 1;
+ opr_mutex_init(&xstat_cm_force_lock);
+ opr_cv_init(&xstat_cm_force_cv);
+
/*
* Check the parameters for bogosities.
*/
/*
* 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;
} /*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.
* [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.
/*
* 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.
* 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) {
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;
}
}
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;
}
#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.
int freq; /*Frequency of polls */
int period; /*Time in minutes of data collection */
+ opr_softsig_Init();
+
/*
* Are we doing one-shot measurements?
*/
#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.
*/
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 */
/*------------------------------------------------------------------------
* [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.
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 # */
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;
*
* 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.
*
} else
xstat_fs_initflag = 1;
+ opr_mutex_init(&xstat_fs_force_lock);
+ opr_cv_init(&xstat_fs_force_cv);
+
/*
* Check the parameters for bogosities.
*/
/*
* 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;
* 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.
* [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.
/*
* 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.
* 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) {
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;
}
}
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;
}
#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.
int freq; /*Frequency of polls */
int period; /*Time in minutes of data collection */
+ opr_softsig_Init();
+
/*
* Are we doing one-shot measurements?
*/