[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Spuriously failing hook scripts

From: berni <bernhard_heibler_at_gmx.de>
Date: 2006-09-13 15:17:45 CEST

I have the same problem on a Dual Xeon Server running with Suse 10.0.
By coincident I debugged this problem today and came to the same
conclusion. I think it is a good idea to handle the
!APR_STATUS_IS_CHILD_DONE condition since we get a proper error
message.

But to really solve the problem I think we should disable the SIGCHLD
while the hook runs using the apr_signal function. I have done the
following changes to 1.3.2 of hooks.c. Until now my hooks seam to work.
But it would be great if someone else could test it !

Regards
Bernhard.

=======================================================================
--- hooks.c.org 2006-09-13 14:46:33.000000000 +0200
+++ hooks.c 2006-09-13 14:47:21.000000000 +0200
@@ -21,6 +21,7 @@

 #include <apr_pools.h>
 #include <apr_file_io.h>
+#include <apr_signal.h>

 #include "svn_error.h"
 #include "svn_path.h"
@@ -58,7 +59,8 @@ run_hook_cmd (const char *name,
   int exitcode;
   apr_exit_why_e exitwhy;
   apr_proc_t cmd_proc;
-
+ apr_sigfunc_t * oldSigFunc;
+
   /* Create a pipe to access stderr of the child. */
   apr_err = apr_file_pipe_create(&read_errhandle, &write_errhandle,
pool);
   if (apr_err)
@@ -92,6 +94,8 @@ run_hook_cmd (const char *name,
     return svn_error_wrap_apr
       (apr_err, _("Can't create null stdout for hook '%s'"), cmd);

+ oldSigFunc = apr_signal(SIGCHLD, SIG_DFL);
+
   err = svn_io_start_cmd (&cmd_proc, ".", cmd, args, FALSE,
                           stdin_handle, null_handle, write_errhandle,
pool);

@@ -101,8 +105,12 @@ run_hook_cmd (const char *name,
      pipe so we don't hang on the read end later, if we need to read
it. */
   apr_err = apr_file_close (write_errhandle);
   if (!err && apr_err)
+ {
+ apr_signal(SIGCHLD, oldSigFunc);
+
     return svn_error_wrap_apr
       (apr_err, _("Error closing write end of stderr pipe"));
+ }

   if (err)
     {
@@ -117,6 +125,7 @@ run_hook_cmd (const char *name,
       err2 = svn_stringbuf_from_aprfile (&error, read_errhandle,
pool);

       err = svn_io_wait_for_cmd(&cmd_proc, cmd, &exitcode, &exitwhy,
pool);
+
       if (! err)
         {
           if (! APR_PROC_CHECK_EXIT (exitwhy) || exitcode != 0)
@@ -145,6 +154,9 @@ run_hook_cmd (const char *name,
         }
     }

+ apr_signal(SIGCHLD, oldSigFunc);
+
+
   /* Hooks are fallible, and so hook failure is "expected" to occur at
      times. When such a failure happens we still want to close the
pipe
      and null file */

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Sep 14 00:21:47 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.