From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f678f,d5e86a4dbab7c6b6,start X-Google-Attributes: gidf678f,public X-Google-ArrivalTime: 1994-10-27 19:24:28 PST Newsgroups: comp.unix.osf.misc Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!swrinde!news.uh.edu!uuneo.neosoft.com!jabberwock!daniels From: daniels@biles.com (Brad Daniels) Subject: Clean rundown of RPC connection? Followup-To: comp.unix.osf.misc,poster Organization: Biles and Associates Date: Thu, 27 Oct 1994 18:39:50 GMT Message-ID: We have a program which monitors a small homebrew database for changes and returns change records to clients. When each client connects, we create a change queue for the connection and associate it with a context handle. When the client program then requests data, the server checks the connection's queue. If the queue is empty, the request thread goes into a timed wait on a condition variable associated with the queue. The thread which monitors the database then puts changes in the queue as they occur and signals the condition variable (whose associated predicate checks if the queue is empty.) We use the cond_timedwait to avoid excessive overhead when no changes are happening in the database. All of the above works fine until we kill off the client while it is waiting for changes. We need to let any queue manipulations finish and unlock all mutexes before performing rundown to destroy the queue. We tried using pthread_setasynccancel to prevent the thread from exiting before we finish, but that does not seem to have any effect. In fact, the behavior we are seeing is quite puzzling. If we print the thread ID of the thread servicing the request for changes, the number is the same as the one we get when we print the thread ID in the rundown routine. We have no idea how the thread is getting out of our request routine and into the rundown routine. We have considered using pthread_cleanup_push, but we use C++ functions which we cannot clean up safely. We need to ensure that certain operations complete before rundown. Is there anything we can do? What mexchanism is used to stop the processing of the request? Any info is much appreciated. Thanks, - Brad ------------------------------------------------------------------- + Brad Daniels | "Oh, I know you did... + + Biles and Associates | but let's pretend you didn't." + + These are my views, not B&A's | - Darkman + -------------------------------------------------------------------