[Live-devel] Shutdown of testRTSPonDemandServer
Ross Finlayson
finlayson at live555.com
Fri Mar 31 11:01:58 PST 2006
> I need to shutdown my hardware cleanly when the program terminates so I
>have added a watch variable to Eventloop. The variable gets set when a
>signal handler is invoked.
>That should stop the eventloop and then I shutdown my hardware.
>
>This works well when the RTSP server is streaming to clients. However,
>when there are no clients the eventloop does not seem respond to the
>watch variable.
>
>Is this to be expected?
This was unexpected, but not really a bug. It happens because - when
the server is sitting around waiting for a request - no 'events' are
happening (no incoming packets, no delayed tasks), so the server sits
forever in "select()", and so never gets to check the watch variable.
> Is there a way to get around this?
Yes. You can schedule a dummy task (that does nothing) to run
periodically (e.g., every 100 ms). This will ensure that the server
leaves "select()" (to check the watch variable) at least every 100ms
Add the following just before "main()":
static void dummyTask(void* /*clientData*/) {
// Call this again, after a brief delay:
int uSecsToDelay = 100000; // 100 ms
env->taskScheduler().scheduleDelayedTask(uSecsToDelay,
(TaskFunc*)dummyTask, NULL);
}
And then, just before the call to "doEventLoop()", do
dummyTask(NULL);
Ross Finlayson
Live Networks, Inc. (LIVE555.COM)
<http://www.live555.com/>
More information about the live-devel
mailing list