From 261716adb158ca8cff92791922d446332fe2a1e2 Mon Sep 17 00:00:00 2001 From: Hartmut Reuter Date: Mon, 12 Feb 2001 19:30:33 +0000 Subject: [PATCH] --- src/rx/rx_lwp.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/rx/rx_lwp.c b/src/rx/rx_lwp.c index 6517423b9..f54df1a66 100644 --- a/src/rx/rx_lwp.c +++ b/src/rx/rx_lwp.c @@ -34,6 +34,7 @@ # include "rx_globals.h" # include +#define MAXTHREADNAMELENGTH 64 int debugSelectFailure; /* # of times select failed */ /* @@ -64,6 +65,16 @@ void rxi_Delay(int sec) IOMGR_Sleep(sec); } +static int quitListening = 0; + +/* This routine will kill the listener thread, if it exists. */ +void +rxi_StopListener() +{ + quitListening = 1; + rxi_ReScheduleEvents(); +} + /* This routine will get called by the event package whenever a new, earlier than others, event is posted. If the Listener process is blocked in selects, this will unblock it. It also can be called @@ -128,10 +139,19 @@ void rxi_ListenerProc(rfds, tnop, newcallp) int lastPollWorked, doingPoll; /* true iff last poll was useful */ struct timeval tv, *tvp; int i, code; + PROCESS pid; + char name[MAXTHREADNAMELENGTH] = "srv_0"; clock_NewTime(); lastPollWorked = 0; nextPollTime = 0; + code = LWP_CurrentProcess(&pid); + if (code) { + fprintf(stderr, "rxi_Listener: Can't get my pid.\n"); + exit(1); + } + rx_listenerPid = pid; + swapthreadname(pid, "listener", &name); for (;;) { /* Grab a new packet only if necessary (otherwise re-use the old one) */ @@ -175,6 +195,11 @@ void rxi_ListenerProc(rfds, tnop, newcallp) } lastPollWorked = 0; /* default is that it didn't find anything */ + if (quitListening) { + quitListening = 0; + LWP_DestroyProcess(pid); + } + switch(code) { case 0: /* Timer interrupt: -- 2.39.5