You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Jun Omae <ju...@gmail.com> on 2024/01/29 12:49:18 UTC

Re: svn commit: r1908547 - /subversion/trunk/subversion/svnserve/svnserve.c

On 2023/03/20 10:27, philip@apache.org wrote:
> Author: philip
> Date: Mon Mar 20 01:27:41 2023
> New Revision: 1908547
> 
> URL: http://svn.apache.org/viewvc?rev=1908547&view=rev
> Log:
> Add SIGTERM/SIGINT handling to svnserve, this allows it to exit more
> gracefully which allows tools like valgrind to monitor whether the
> program exits cleanly and do things like leak detection.
> 
> * subversion/svnserve/svnserve.c
>   (sigtermint_handler): New handler.
>   (accept_connection): Check for signal.
>   (sub_main): Install handler, check for signal, add return.

After r1908547, svnserve shows E000004 error message even if sending
SIGTERM/SIGINT to stop normally the process.

[[[
$ ~/svn/trunk-1915316/bin/svnserve -X &
[1] 3088030
$ kill %1
$ svnserve: E000004: Can't accept client connection: Interrupted system call
]]]

Another example, the error messages are shown repeatedly while running
check-swig-rb which is using svnserve.

[[[
$ make check-swig-rb
...
Loaded suite .
Started
svnserve: E000004: Can't accept client connection: Interrupted system call
.svnserve: E000004: Can't accept client connection: Interrupted system call
.svnserve: E000004: Can't accept client connection: Interrupted system call
.svnserve: E000004: Can't accept client connection: Interrupted system call
.svnserve: E000004: Can't accept client connection: Interrupted system call
]]]

I think we should prevent the messages even if the system call is interrupted
when stop request by SIGTERM/SIGINT.

-- 
Jun Omae <ju...@gmail.com> (大前 潤)


Re: svn commit: r1908547 - /subversion/trunk/subversion/svnserve/svnserve.c

Posted by Jun Omae <ju...@gmail.com>.
On Tue, Jan 30, 2024 at 9:42 PM Daniel Sahlberg
<da...@gmail.com> wrote:
>
> Den tis 30 jan. 2024 kl 01:39 skrev Jun Omae <ju...@gmail.com>:
>>
>> On 2024/01/30 6:15, Daniel Sahlberg wrote:
>> > Good catch! How about:
>> >
>> > [[[
>> > Index: subversion/svnserve/svnserve.c
>> > ===================================================================
>> > --- subversion/svnserve/svnserve.c      (revision 1915424)
>> > +++ subversion/svnserve/svnserve.c      (working copy)
>> > @@ -574,7 +574,7 @@ accept_connection(connection_t **connection,
>> >      || APR_STATUS_IS_ECONNABORTED(status)
>> >      || APR_STATUS_IS_ECONNRESET(status));
>> >
>> > -  return status
>> > +  return status && !sigtermint_seen
>> >         ? svn_error_wrap_apr(status, _("Can't accept client connection"))
>> >         : SVN_NO_ERROR;
>> >  }
>> > ]]]
>>
>> The `sigtermint_seen` variable is not defined if sigaction is unavailable.
>> Instead, how about the following patch?
>>
>> [[[
>> Index: subversion/svnserve/svnserve.c
>> ===================================================================
>> --- subversion/svnserve/svnserve.c      (revision 1915466)
>> +++ subversion/svnserve/svnserve.c      (working copy)
>> @@ -574,9 +574,14 @@ accept_connection(connection_t **connection,
>>      || APR_STATUS_IS_ECONNABORTED(status)
>>      || APR_STATUS_IS_ECONNRESET(status));
>>
>> -  return status
>> -       ? svn_error_wrap_apr(status, _("Can't accept client connection"))
>> -       : SVN_NO_ERROR;
>> +  if (!status)
>> +    return SVN_NO_ERROR;
>> +#if APR_HAVE_SIGACTION
>> +  else if (sigtermint_seen)
>> +    return SVN_NO_ERROR;
>> +#endif
>> +  else
>> +    return svn_error_wrap_apr(status, _("Can't accept client connection"));
>>  }
>>
>>  /* Add a reference to CONNECTION, i.e. keep it and it's pool valid unless
>> ]]]
>
>
> Oh, yes of course. That looks much better. Please commit!
>
> Kind regards,
> Daniel
>

Thanks for the reviewing! I just pushed the changes in r1915492.

-- 
Jun Omae <ju...@gmail.com> (大前 潤)

Re: svn commit: r1908547 - /subversion/trunk/subversion/svnserve/svnserve.c

Posted by Daniel Sahlberg <da...@gmail.com>.
Den tis 30 jan. 2024 kl 01:39 skrev Jun Omae <ju...@gmail.com>:

> On 2024/01/30 6:15, Daniel Sahlberg wrote:
> > Good catch! How about:
> >
> > [[[
> > Index: subversion/svnserve/svnserve.c
> > ===================================================================
> > --- subversion/svnserve/svnserve.c      (revision 1915424)
> > +++ subversion/svnserve/svnserve.c      (working copy)
> > @@ -574,7 +574,7 @@ accept_connection(connection_t **connection,
> >      || APR_STATUS_IS_ECONNABORTED(status)
> >      || APR_STATUS_IS_ECONNRESET(status));
> >
> > -  return status
> > +  return status && !sigtermint_seen
> >         ? svn_error_wrap_apr(status, _("Can't accept client connection"))
> >         : SVN_NO_ERROR;
> >  }
> > ]]]
>
> The `sigtermint_seen` variable is not defined if sigaction is unavailable.
> Instead, how about the following patch?
>
> [[[
> Index: subversion/svnserve/svnserve.c
> ===================================================================
> --- subversion/svnserve/svnserve.c      (revision 1915466)
> +++ subversion/svnserve/svnserve.c      (working copy)
> @@ -574,9 +574,14 @@ accept_connection(connection_t **connection,
>      || APR_STATUS_IS_ECONNABORTED(status)
>      || APR_STATUS_IS_ECONNRESET(status));
>
> -  return status
> -       ? svn_error_wrap_apr(status, _("Can't accept client connection"))
> -       : SVN_NO_ERROR;
> +  if (!status)
> +    return SVN_NO_ERROR;
> +#if APR_HAVE_SIGACTION
> +  else if (sigtermint_seen)
> +    return SVN_NO_ERROR;
> +#endif
> +  else
> +    return svn_error_wrap_apr(status, _("Can't accept client
> connection"));
>  }
>
>  /* Add a reference to CONNECTION, i.e. keep it and it's pool valid unless
> ]]]
>

Oh, yes of course. That looks much better. Please commit!

Kind regards,
Daniel

Re: svn commit: r1908547 - /subversion/trunk/subversion/svnserve/svnserve.c

Posted by Jun Omae <ju...@gmail.com>.
On 2024/01/30 6:15, Daniel Sahlberg wrote:
> Good catch! How about:
> 
> [[[
> Index: subversion/svnserve/svnserve.c
> ===================================================================
> --- subversion/svnserve/svnserve.c      (revision 1915424)
> +++ subversion/svnserve/svnserve.c      (working copy)
> @@ -574,7 +574,7 @@ accept_connection(connection_t **connection,
>      || APR_STATUS_IS_ECONNABORTED(status)
>      || APR_STATUS_IS_ECONNRESET(status));
> 
> -  return status
> +  return status && !sigtermint_seen
>         ? svn_error_wrap_apr(status, _("Can't accept client connection"))
>         : SVN_NO_ERROR;
>  }
> ]]] 

The `sigtermint_seen` variable is not defined if sigaction is unavailable.
Instead, how about the following patch?

[[[
Index: subversion/svnserve/svnserve.c
===================================================================
--- subversion/svnserve/svnserve.c      (revision 1915466)
+++ subversion/svnserve/svnserve.c      (working copy)
@@ -574,9 +574,14 @@ accept_connection(connection_t **connection,
     || APR_STATUS_IS_ECONNABORTED(status)
     || APR_STATUS_IS_ECONNRESET(status));

-  return status
-       ? svn_error_wrap_apr(status, _("Can't accept client connection"))
-       : SVN_NO_ERROR;
+  if (!status)
+    return SVN_NO_ERROR;
+#if APR_HAVE_SIGACTION
+  else if (sigtermint_seen)
+    return SVN_NO_ERROR;
+#endif
+  else
+    return svn_error_wrap_apr(status, _("Can't accept client connection"));
 }

 /* Add a reference to CONNECTION, i.e. keep it and it's pool valid unless
]]]


-- 
Jun Omae <ju...@gmail.com> (大前 潤)


Re: svn commit: r1908547 - /subversion/trunk/subversion/svnserve/svnserve.c

Posted by Daniel Sahlberg <da...@gmail.com>.
Den mån 29 jan. 2024 kl 13:50 skrev Jun Omae <ju...@gmail.com>:

> On 2023/03/20 10:27, philip@apache.org wrote:
> > Author: philip
> > Date: Mon Mar 20 01:27:41 2023
> > New Revision: 1908547
> >
> > URL: http://svn.apache.org/viewvc?rev=1908547&view=rev
> > Log:
> > Add SIGTERM/SIGINT handling to svnserve, this allows it to exit more
> > gracefully which allows tools like valgrind to monitor whether the
> > program exits cleanly and do things like leak detection.
> >
> > * subversion/svnserve/svnserve.c
> >   (sigtermint_handler): New handler.
> >   (accept_connection): Check for signal.
> >   (sub_main): Install handler, check for signal, add return.
>
> After r1908547, svnserve shows E000004 error message even if sending
> SIGTERM/SIGINT to stop normally the process.
>
> [[[
> $ ~/svn/trunk-1915316/bin/svnserve -X &
> [1] 3088030
> $ kill %1
> $ svnserve: E000004: Can't accept client connection: Interrupted system
> call
> ]]]
>
> Another example, the error messages are shown repeatedly while running
> check-swig-rb which is using svnserve.
>
> [[[
> $ make check-swig-rb
> ...
> Loaded suite .
> Started
> svnserve: E000004: Can't accept client connection: Interrupted system call
> .svnserve: E000004: Can't accept client connection: Interrupted system call
> .svnserve: E000004: Can't accept client connection: Interrupted system call
> .svnserve: E000004: Can't accept client connection: Interrupted system call
> .svnserve: E000004: Can't accept client connection: Interrupted system call
> ]]]
>
> I think we should prevent the messages even if the system call is
> interrupted
> when stop request by SIGTERM/SIGINT.
>
> --
> Jun Omae <ju...@gmail.com> (大前 潤)
>
>
Good catch! How about:

[[[
Index: subversion/svnserve/svnserve.c
===================================================================
--- subversion/svnserve/svnserve.c      (revision 1915424)
+++ subversion/svnserve/svnserve.c      (working copy)
@@ -574,7 +574,7 @@ accept_connection(connection_t **connection,
     || APR_STATUS_IS_ECONNABORTED(status)
     || APR_STATUS_IS_ECONNRESET(status));

-  return status
+  return status && !sigtermint_seen
        ? svn_error_wrap_apr(status, _("Can't accept client connection"))
        : SVN_NO_ERROR;
 }
]]]