Beautiful!  It works great now.

Thanks much,
Noel




[EMAIL PROTECTED] on 06/03/2000 01:09:25 PM

To:   [EMAIL PROTECTED]
cc:   [EMAIL PROTECTED]
Subject:  Re: server file descriptors not being closed




Noel L Yap writes:
>
> I'm having problems adding functionality that uses the client/server protocol.
> After so many calls to send_file_names(), the server starts getting "Too many
> open files" errors on a call to pipe(protocol_pipe).  I suspect that somewhere
> on the server, file descriptors aren't being closed.  The problem is that it's
> extremely difficult to hunt down.

Yep, every time the server executes a CVS command, it leaks four FDs.
I've checked in a fix, here's a patch for anyone who wants it:

Index: server.c
===================================================================
RCS file: /home2/cvsroot/ccvs/src/server.c,v
retrieving revision 1.228
retrieving revision 1.229
diff -u -r1.228 -r1.229
--- server.c   2000/05/19 17:01:33 1.228
+++ server.c   2000/06/03 16:35:42 1.229
@@ -2745,8 +2745,11 @@
         error (1, errno, "can't set up pipes");
     if (dup2 (stderr_pipe[1], STDERR_FILENO) < 0)
         error (1, errno, "can't set up pipes");
+    close (dev_null_fd);
     close (stdout_pipe[0]);
+    close (stdout_pipe[1]);
     close (stderr_pipe[0]);
+    close (stderr_pipe[1]);
     close (protocol_pipe[0]);
 #ifdef SERVER_FLOWCONTROL
     close (flowcontrol_pipe[1]);
@@ -2961,7 +2964,10 @@
          buf_copy_lines (buf_to_net, stdoutbuf, 'M');

          if (status == -1)
+         {
+             close (stdout_pipe[0]);
              stdout_pipe[0] = -1;
+         }
          else if (status > 0)
          {
              buf_output0 (buf_to_net, "E buf_input_data failed\n");
@@ -2983,7 +2989,10 @@
          buf_copy_lines (buf_to_net, stderrbuf, 'E');

          if (status == -1)
+         {
+             close (stderr_pipe[0]);
              stderr_pipe[0] = -1;
+         }
          else if (status > 0)
          {
              buf_output0 (buf_to_net, "E buf_input_data failed\n");
@@ -3005,7 +3014,10 @@
          status = buf_input_data (protocol_inbuf, &count_read);

          if (status == -1)
+         {
+             close (protocol_pipe[0]);
              protocol_pipe[0] = -1;
+         }
          else if (status > 0)
          {
              buf_output0 (buf_to_net, "E buf_input_data failed\n");
@@ -3066,6 +3078,11 @@
         buf_output0 (buf_to_net,
                "E Protocol error: uncounted data discarded\n");

+#ifdef SERVER_FLOWCONTROL
+    close (flowcontrol_pipe[1]);
+    flowcontrol_pipe[1] = -1;
+#endif /* SERVER_FLOWCONTROL */
+
     errs = 0;

     while (command_pid > 0)
@@ -3150,6 +3167,10 @@
     close (stderr_pipe[1]);
     close (stdout_pipe[0]);
     close (stdout_pipe[1]);
+#ifdef SERVER_FLOWCONTROL
+    close (flowcontrol_pipe[0]);
+    close (flowcontrol_pipe[1]);
+#endif /* SERVER_FLOWCONTROL */

  free_args_and_return:
     /* Now free the arguments.  */

-Larry Jones

Girls are like slugs -- they probably serve some purpose, but
it's hard to imagine what. -- Calvin





This communication is for informational purposes only.  It is not intended as
an offer or solicitation for the purchase or sale of any financial instrument
or as an official confirmation of any transaction. All market prices, data
and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of J.P. Morgan & Co. Incorporated, its
subsidiaries and affiliates.

Reply via email to