[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PATCH: server_shutdown() attempts to shutdown bufs twice

From: James E Jurach Jr.
Subject: PATCH: server_shutdown() attempts to shutdown bufs twice
Date: Tue, 09 Jul 2002 13:00:32 -0500

When CVS server receives a signal (e.g. ctrl-c during cvs update within an
rsh transport), it calls server_cleanup(), which closes (but does not
otherwise invalidate) a set of internal I/O buffer structures, nor does it
exit.  Processing continues, but fails on the next call to read or write
I/O, which causes a loop to exit and server_cleanup() to be called again at
the bottom of server(), with the newly invalidated I/O buffers.

Actually, there is an assert() which tests to make sure the file associated
with the buffer is not closed -- a state which should be impossible.  The 
assert throws an IOT trap, causing the process to drop core.  I do not know
why this core was so huge (~ 225Mb on AIX 5.1), but it was enough to 
exhaust our temp space and cause us headaches yesterday.

I thought the fix was to close and set to NULL these buffers.  However,
there is little telling what state the system is in when the signal handler
returns, so free'ing and NULL'ing is probably not a good idea.  I think
enforcing the policy that buf->shutdown can only be called once by setting
buf->shutdown to NULL after it has been called makes sense.  Advice?


Index: buffer.c
RCS file: /mesa/cvsroot/tools/cvs/src/buffer.c,v
retrieving revision 1.2
diff -u -3 -r1.2 buffer.c
--- buffer.c    3 Jul 2002 21:33:19 -0000       1.2
+++ buffer.c    9 Jul 2002 17:56:55 -0000
@@ -1203,9 +1203,12 @@
 buf_shutdown (buf)
      struct buffer *buf;
+    int ret = 0;
     if (buf->shutdown)
-       return (*buf->shutdown) (buf);
-    return 0;
+       ret = (*buf->shutdown) (buf);
+    /* prevent more than one shutdown. */
+    buf->shutdown = NULL;
+    return ret;
 /* The simplest type of buffer is one built on top of a stdio FILE.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]