You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2016/02/09 22:43:04 UTC
svn commit: r1729463 - in /subversion/trunk/subversion: include/private/
libsvn_subr/ svn/ svnadmin/ svnbench/ svnfsfs/ svnlook/ svnrdump/ svnsync/
Author: philip
Date: Tue Feb 9 21:43:03 2016
New Revision: 1729463
URL: http://svn.apache.org/viewvc?rev=1729463&view=rev
Log:
Move signal handling and cancellation code to libsvn_subr to avoid
duplication in multiple programs.
* subversion/include/private/svn_cmdline_private.h
(svn_cmdline__setup_cancellation_handler,
svn_cmdline__disable_cancellation_handler,
svn_cmdline__get_cancellation_signal): New.
* subversion/libsvn_subr/cmdline.c
(signal_handler, check_cancel,
svn_cmdline__setup_cancellation_handler,
svn_cmdline__disable_cancellation_handler,
svn_cmdline__get_cancellation_signal): New, code from svn.c and svnadmin.c.
* subversion/svn/cl.h
(svn_cl__check_cancel): Change type to pointer.
* subversion/svn/svn.c
(svn_cl__check_cancel): Change type to pointer.
(signal_handler): Remove.
(sub_main, main): Call new functions.
* subversion/svnadmin/svnadmin.c
(check_cancel): Change type to pointer.
(signal_handler, setup_cancellation_signalsl): Remove.
(repos_notify_handler, subcommand_recover, subcommand_upgrade,
sub_main, main): Call new functions.
* subversion/svnbench/cl.h
(svn_cl__check_cancel): Change type to pointer.
* subversion/svnbench/svnbench.c
(svn_cl__check_cancel): Change type to pointer.
(signal_handler): Remove.
(sub_main, main): Call new functions.
* subversion/svnfsfs/svnfsfs.h
(check_cancel): Change type to pointer.
* subversion/svnfsfs/svnfsfs.c
(check_cancel): Change type to pointer.
(signal_handler, setup_cancellation_signals): Remove.
(sub_main, main): Call new functions.
* subversion/svnlook/svnlook.c
(check_cancel): Change type to pointer.
(signal_handler): Remove.
(sub_main, main): Call new functions.
* subversion/svnrdump/svnrdump.c
(check_cancel): Change type to pointer.
(signal_handler): Remove.
(sub_main, main): Call new functions.
* subversion/svnsync/svnsync.c
(check_cancel): Change type to pointer.
(signal_handler): Remove.
(sub_main, main): Call new functions.
Modified:
subversion/trunk/subversion/include/private/svn_cmdline_private.h
subversion/trunk/subversion/libsvn_subr/cmdline.c
subversion/trunk/subversion/svn/cl.h
subversion/trunk/subversion/svn/svn.c
subversion/trunk/subversion/svnadmin/svnadmin.c
subversion/trunk/subversion/svnbench/cl.h
subversion/trunk/subversion/svnbench/svnbench.c
subversion/trunk/subversion/svnfsfs/svnfsfs.c
subversion/trunk/subversion/svnfsfs/svnfsfs.h
subversion/trunk/subversion/svnlook/svnlook.c
subversion/trunk/subversion/svnrdump/svnrdump.c
subversion/trunk/subversion/svnsync/svnsync.c
Modified: subversion/trunk/subversion/include/private/svn_cmdline_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_cmdline_private.h?rev=1729463&r1=1729462&r2=1729463&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_cmdline_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_cmdline_private.h Tue Feb 9 21:43:03 2016
@@ -251,6 +251,22 @@ svn_cmdline__parse_trust_options(
const char *opt_arg,
apr_pool_t *scratch_pool);
+/* Setup signal handlers for signals such as SIGINT and return a
+ cancellation handler function. This also sets some other signals
+ to be ignored. */
+svn_cancel_func_t
+svn_cmdline__setup_cancellation_handler(void);
+
+/* Set the handlers for signals such as SIGINT back to default. */
+void
+svn_cmdline__disable_cancellation_handler(void);
+
+/* Return a signal that triggered cancellation if any, or zero
+ otherwise. If a signal is returned the signal handling for that
+ signal will be reset to default. */
+int
+svn_cmdline__get_cancellation_signal(void);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
Modified: subversion/trunk/subversion/libsvn_subr/cmdline.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cmdline.c?rev=1729463&r1=1729462&r2=1729463&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cmdline.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cmdline.c Tue Feb 9 21:43:03 2016
@@ -42,6 +42,7 @@
#include <apr_general.h> /* for apr_initialize/apr_terminate */
#include <apr_strings.h> /* for apr_snprintf */
#include <apr_pools.h>
+#include <apr_signal.h>
#include "svn_cmdline.h"
#include "svn_ctype.h"
@@ -1606,3 +1607,95 @@ svn_cmdline__parse_trust_options(
return SVN_NO_ERROR;
}
+
+/* Flags to see if we've been cancelled by the client or not. */
+static volatile sig_atomic_t cancelled = FALSE;
+static volatile sig_atomic_t signum_cancelled = 0;
+
+/* The signals we handle. */
+static int signal_map [] = {
+ SIGINT
+#ifdef SIGBREAK
+ /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
+ , SIGBREAK
+#endif
+#ifdef SIGHUP
+ , SIGHUP
+#endif
+#ifdef SIGTERM
+ , SIGTERM
+#endif
+};
+
+/* A signal handler to support cancellation. */
+static void
+signal_handler(int signum)
+{
+ int i;
+
+ apr_signal(signum, SIG_IGN);
+ cancelled = TRUE;
+ for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
+ if (signal_map[i] == signum)
+ {
+ signum_cancelled = i + 1;
+ break;
+ }
+}
+
+/* An svn_cancel_func_t callback. */
+static svn_error_t *
+check_cancel(void *baton)
+{
+ /* Cancel baton should be always NULL in command line client. */
+ SVN_ERR_ASSERT(baton == NULL);
+ if (cancelled)
+ return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
+ else
+ return SVN_NO_ERROR;
+}
+
+svn_cancel_func_t
+svn_cmdline__setup_cancellation_handler(void)
+{
+ int i;
+
+ for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
+ apr_signal(signal_map[i], signal_handler);
+
+#ifdef SIGPIPE
+ /* Disable SIGPIPE generation for the platforms that have it. */
+ apr_signal(SIGPIPE, SIG_IGN);
+#endif
+
+#ifdef SIGXFSZ
+ /* Disable SIGXFSZ generation for the platforms that have it, otherwise
+ * working with large files when compiled against an APR that doesn't have
+ * large file support will crash the program, which is uncool. */
+ apr_signal(SIGXFSZ, SIG_IGN);
+#endif
+
+ return check_cancel;
+}
+
+void
+svn_cmdline__disable_cancellation_handler(void)
+{
+ int i;
+
+ for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
+ apr_signal(signal_map[i], SIG_DFL);
+}
+
+int
+svn_cmdline__get_cancellation_signal(void)
+{
+ int signum = 0;
+
+ if (cancelled && signum_cancelled)
+ signum = signal_map[signum_cancelled - 1];
+ if (signum)
+ apr_signal(signum, SIG_DFL);
+
+ return signum;
+}
Modified: subversion/trunk/subversion/svn/cl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl.h?rev=1729463&r1=1729462&r2=1729463&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Tue Feb 9 21:43:03 2016
@@ -338,8 +338,7 @@ svn_cl__try(svn_error_t *err,
/* Our cancellation callback. */
-svn_error_t *
-svn_cl__check_cancel(void *baton);
+extern svn_cancel_func_t svn_cl__check_cancel;
Modified: subversion/trunk/subversion/svn/svn.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/svn.c?rev=1729463&r1=1729462&r2=1729463&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/svn.c (original)
+++ subversion/trunk/subversion/svn/svn.c Tue Feb 9 21:43:03 2016
@@ -1800,51 +1800,8 @@ check_lib_versions(void)
return svn_ver_check_list2(&my_version, checklist, svn_ver_equal);
}
-
-/* A flag to see if we've been cancelled by the client or not. */
-static volatile sig_atomic_t cancelled = FALSE;
-static volatile sig_atomic_t signum_cancelled = 0;
-static int signal_map [] = {
- SIGINT
-#ifdef SIGBREAK
- /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
- , SIGBREAK
-#endif
-#ifdef SIGHUP
- , SIGHUP
-#endif
-#ifdef SIGTERM
- , SIGTERM
-#endif
-};
-
-/* A signal handler to support cancellation. */
-static void
-signal_handler(int signum)
-{
- int i;
-
- apr_signal(signum, SIG_IGN);
- cancelled = TRUE;
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- if (signal_map[i] == signum)
- {
- signum_cancelled = i + 1;
- break;
- }
-}
-
-/* Our cancellation callback. */
-svn_error_t *
-svn_cl__check_cancel(void *baton)
-{
- /* Cancel baton should be always NULL in command line client. */
- SVN_ERR_ASSERT(baton == NULL);
- if (cancelled)
- return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
- else
- return SVN_NO_ERROR;
-}
+/* The cancelation handler setup by the cmdline library. */
+svn_cancel_func_t svn_cl__check_cancel = NULL;
/* Add a --search argument to OPT_STATE.
* These options start a new search pattern group. */
@@ -2975,21 +2932,8 @@ sub_main(int *exit_code, int argc, const
}
/* Set up our cancellation support. */
+ svn_cl__check_cancel = svn_cmdline__setup_cancellation_handler();
ctx->cancel_func = svn_cl__check_cancel;
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- apr_signal(signal_map[i], signal_handler);
-
-#ifdef SIGPIPE
- /* Disable SIGPIPE generation for the platforms that have it. */
- apr_signal(SIGPIPE, SIG_IGN);
-#endif
-
-#ifdef SIGXFSZ
- /* Disable SIGXFSZ generation for the platforms that have it, otherwise
- * working with large files when compiled against an APR that doesn't have
- * large file support will crash the program, which is uncool. */
- apr_signal(SIGXFSZ, SIG_IGN);
-#endif
/* Set up Authentication stuff. */
SVN_ERR(svn_cmdline_create_auth_baton2(
@@ -3165,16 +3109,12 @@ main(int argc, const char *argv[])
/* Resend any signal as this may cause the program to exit and
allows the shell to use WIFSIGNALED and WTERMSIG to detect the
signal. See http://www.cons.org/cracauer/sigint.html */
- if (cancelled && signum_cancelled)
- {
- int saved_signum = signal_map[signum_cancelled - 1];
+ {
+ int signum = svn_cmdline__get_cancellation_signal();
- if (saved_signum)
- {
- apr_signal(saved_signum, SIG_DFL);
- /* No APR support for getpid() so cannot use apr_proc_kill(). */
- kill(getpid(), saved_signum);
- }
+ if (signum)
+ /* No APR support for getpid() so cannot use apr_proc_kill(). */
+ kill(getpid(), signum);
}
#endif
Modified: subversion/trunk/subversion/svnadmin/svnadmin.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnadmin/svnadmin.c?rev=1729463&r1=1729462&r2=1729463&view=diff
==============================================================================
--- subversion/trunk/subversion/svnadmin/svnadmin.c (original)
+++ subversion/trunk/subversion/svnadmin/svnadmin.c Tue Feb 9 21:43:03 2016
@@ -53,6 +53,7 @@
#include "private/svn_opt_private.h"
#include "private/svn_sorts_private.h"
#include "private/svn_subr_private.h"
+#include "private/svn_cmdline_private.h"
#include "svn_private_config.h"
@@ -64,61 +65,7 @@
* The current threshold is 64MB. */
#define BLOCK_READ_CACHE_THRESHOLD (0x40 * 0x100000)
-/* A flag to see if we've been cancelled by the client or not. */
-static volatile sig_atomic_t cancelled = FALSE;
-static volatile sig_atomic_t signum_cancelled = 0;
-static int signal_map [] = {
- SIGINT
-#ifdef SIGBREAK
- /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
- , SIGBREAK
-#endif
-#ifdef SIGHUP
- , SIGHUP
-#endif
-#ifdef SIGTERM
- , SIGTERM
-#endif
-};
-
-/* A signal handler to support cancellation. */
-static void
-signal_handler(int signum)
-{
- int i;
-
- apr_signal(signum, SIG_IGN);
- cancelled = TRUE;
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- if (signal_map[i] == signum)
- {
- signum_cancelled = i + 1;
- break;
- }
-}
-
-
-/* A helper to set up the cancellation signal handlers. */
-static void
-setup_cancellation_signals(void (*handler)(int signum))
-{
- int i;
-
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- apr_signal(signal_map[i], signal_handler);
-}
-
-
-/* Our cancellation callback. */
-static svn_error_t *
-check_cancel(void *baton)
-{
- if (cancelled)
- return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
- else
- return SVN_NO_ERROR;
-}
-
+static svn_cancel_func_t check_cancel = NULL;
/* Custom filesystem warning function. */
static void
@@ -1110,8 +1057,7 @@ repos_notify_handler(void *baton,
return;
case svn_repos_notify_mutex_acquired:
- /* Enable cancellation signal handlers. */
- setup_cancellation_signals(signal_handler);
+ svn_cmdline__setup_cancellation_handler();
return;
case svn_repos_notify_recover_start:
@@ -1663,7 +1609,7 @@ subcommand_recover(apr_getopt_t *os, voi
/* Restore default signal handlers until after we have acquired the
* exclusive lock so that the user interrupt before we actually
* touch the repository. */
- setup_cancellation_signals(SIG_DFL);
+ svn_cmdline__disable_cancellation_handler();
err = svn_repos_recover4(opt_state->repository_path, TRUE,
repos_notify_handler, feedback_stream,
@@ -2546,7 +2492,7 @@ subcommand_upgrade(apr_getopt_t *os, voi
SVN_ERR(svn_stream_for_stdout(&feedback_stream, pool));
/* Restore default signal handlers. */
- setup_cancellation_signals(SIG_DFL);
+ svn_cmdline__disable_cancellation_handler();
err = svn_repos_upgrade2(opt_state->repository_path, TRUE,
repos_notify_handler, feedback_stream, pool);
@@ -2977,20 +2923,7 @@ sub_main(int *exit_code, int argc, const
}
}
- /* Set up our cancellation support. */
- setup_cancellation_signals(signal_handler);
-
-#ifdef SIGPIPE
- /* Disable SIGPIPE generation for the platforms that have it. */
- apr_signal(SIGPIPE, SIG_IGN);
-#endif
-
-#ifdef SIGXFSZ
- /* Disable SIGXFSZ generation for the platforms that have it, otherwise
- * working with large files when compiled against an APR that doesn't have
- * large file support will crash the program, which is uncool. */
- apr_signal(SIGXFSZ, SIG_IGN);
-#endif
+ check_cancel = svn_cmdline__setup_cancellation_handler();
/* Configure FSFS caches for maximum efficiency with svnadmin.
* Also, apply the respective command line parameters, if given. */
@@ -3055,17 +2988,13 @@ main(int argc, const char *argv[])
/* Resend any signal as this may cause the program to exit and
allows the shell to use WIFSIGNALED and WTERMSIG to detect the
signal. See http://www.cons.org/cracauer/sigint.html */
- if (cancelled && signum_cancelled)
- {
- int saved_signum = signal_map[signum_cancelled - 1];
+ {
+ int signum = svn_cmdline__get_cancellation_signal();
- if (saved_signum)
- {
- apr_signal(saved_signum, SIG_DFL);
- /* No APR support for getpid() so cannot use apr_proc_kill(). */
- kill(getpid(), saved_signum);
- }
- }
+ if (signum)
+ /* No APR support for getpid() so cannot use apr_proc_kill(). */
+ kill(getpid(), signum);
+ }
#endif
return exit_code;
Modified: subversion/trunk/subversion/svnbench/cl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnbench/cl.h?rev=1729463&r1=1729462&r2=1729463&view=diff
==============================================================================
--- subversion/trunk/subversion/svnbench/cl.h (original)
+++ subversion/trunk/subversion/svnbench/cl.h Tue Feb 9 21:43:03 2016
@@ -150,8 +150,7 @@ svn_cl__try(svn_error_t *err,
/* Our cancellation callback. */
-svn_error_t *
-svn_cl__check_cancel(void *baton);
+extern svn_cancel_func_t svn_cl__check_cancel;
Modified: subversion/trunk/subversion/svnbench/svnbench.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnbench/svnbench.c?rev=1729463&r1=1729462&r2=1729463&view=diff
==============================================================================
--- subversion/trunk/subversion/svnbench/svnbench.c (original)
+++ subversion/trunk/subversion/svnbench/svnbench.c Tue Feb 9 21:43:03 2016
@@ -332,39 +332,6 @@ check_lib_versions(void)
}
-/* A flag to see if we've been cancelled by the client or not. */
-static volatile sig_atomic_t cancelled = FALSE;
-static volatile sig_atomic_t signum_cancelled = 0;
-static int signal_map [] = {
- SIGINT
-#ifdef SIGBREAK
- /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
- , SIGBREAK
-#endif
-#ifdef SIGHUP
- , SIGHUP
-#endif
-#ifdef SIGTERM
- , SIGTERM
-#endif
-};
-
-/* A signal handler to support cancellation. */
-static void
-signal_handler(int signum)
-{
- int i;
-
- apr_signal(signum, SIG_IGN);
- cancelled = TRUE;
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- if (signal_map[i] == signum)
- {
- signum_cancelled = i + 1;
- break;
- }
-}
-
/* Baton for ra_progress_func() callback. */
typedef struct ra_progress_baton_t
{
@@ -383,14 +350,7 @@ ra_progress_func(apr_off_t progress,
}
/* Our cancellation callback. */
-svn_error_t *
-svn_cl__check_cancel(void *baton)
-{
- if (cancelled)
- return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
- else
- return SVN_NO_ERROR;
-}
+svn_cancel_func_t svn_cl__check_cancel = NULL;
/*** Main. ***/
@@ -933,9 +893,8 @@ sub_main(int *exit_code, int argc, const
}
/* Set up our cancellation support. */
+ svn_cl__check_cancel = svn_cmdline__setup_cancellation_handler();
ctx->cancel_func = svn_cl__check_cancel;
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- apr_signal(signal_map[i], signal_handler);
#ifdef SIGPIPE
/* Disable SIGPIPE generation for the platforms that have it. */
@@ -1070,17 +1029,13 @@ main(int argc, const char *argv[])
/* Resend any signal as this may cause the program to exit and
allows the shell to use WIFSIGNALED and WTERMSIG to detect the
signal. See http://www.cons.org/cracauer/sigint.html */
- if (cancelled && signum_cancelled)
- {
- int saved_signum = signal_map[signum_cancelled - 1];
+ {
+ int signum = svn_cmdline__get_cancellation_signal();
- if (saved_signum)
- {
- apr_signal(saved_signum, SIG_DFL);
- /* No APR support for getpid() so cannot use apr_proc_kill(). */
- kill(getpid(), saved_signum);
- }
- }
+ if (signum)
+ /* No APR support for getpid() so cannot use apr_proc_kill(). */
+ kill(getpid(), signum);
+ }
#endif
return exit_code;
Modified: subversion/trunk/subversion/svnfsfs/svnfsfs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnfsfs/svnfsfs.c?rev=1729463&r1=1729462&r2=1729463&view=diff
==============================================================================
--- subversion/trunk/subversion/svnfsfs/svnfsfs.c (original)
+++ subversion/trunk/subversion/svnfsfs/svnfsfs.c Tue Feb 9 21:43:03 2016
@@ -47,60 +47,7 @@
/*** Code. ***/
-/* A flag to see if we've been cancelled by the client or not. */
-static volatile sig_atomic_t cancelled = FALSE;
-static volatile sig_atomic_t signum_cancelled = 0;
-static int signal_map [] = {
- SIGINT
-#ifdef SIGBREAK
- /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
- , SIGBREAK
-#endif
-#ifdef SIGHUP
- , SIGHUP
-#endif
-#ifdef SIGTERM
- , SIGTERM
-#endif
-};
-
-/* A signal handler to support cancellation. */
-static void
-signal_handler(int signum)
-{
- int i;
-
- apr_signal(signum, SIG_IGN);
- cancelled = TRUE;
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- if (signal_map[i] == signum)
- {
- signum_cancelled = i + 1;
- break;
- }
-}
-
-
-/* A helper to set up the cancellation signal handlers. */
-static void
-setup_cancellation_signals(void (*handler)(int signum))
-{
- int i;
-
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- apr_signal(signal_map[i], signal_handler);
-}
-
-
-svn_error_t *
-check_cancel(void *baton)
-{
- if (cancelled)
- return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
- else
- return SVN_NO_ERROR;
-}
-
+svn_cancel_func_t check_cancel = NULL;
/* Custom filesystem warning function. */
static void
@@ -485,19 +432,7 @@ sub_main(int *exit_code, int argc, const
}
/* Set up our cancellation support. */
- setup_cancellation_signals(signal_handler);
-
-#ifdef SIGPIPE
- /* Disable SIGPIPE generation for the platforms that have it. */
- apr_signal(SIGPIPE, SIG_IGN);
-#endif
-
-#ifdef SIGXFSZ
- /* Disable SIGXFSZ generation for the platforms that have it, otherwise
- * working with large files when compiled against an APR that doesn't have
- * large file support will crash the program, which is uncool. */
- apr_signal(SIGXFSZ, SIG_IGN);
-#endif
+ check_cancel = svn_cmdline__setup_cancellation_handler();
/* Configure FSFS caches for maximum efficiency with svnfsfs.
* Also, apply the respective command line parameters, if given. */
@@ -562,17 +497,13 @@ main(int argc, const char *argv[])
/* Resend any signal as this may cause the program to exit and
allows the shell to use WIFSIGNALED and WTERMSIG to detect the
signal. See http://www.cons.org/cracauer/sigint.html */
- if (cancelled && signum_cancelled)
- {
- int saved_signum = signal_map[signum_cancelled - 1];
+ {
+ int signum = svn_cmdline__get_cancellation_signal();
- if (saved_signum)
- {
- apr_signal(saved_signum, SIG_DFL);
- /* No APR support for getpid() so cannot use apr_proc_kill(). */
- kill(getpid(), saved_signum);
- }
- }
+ if (signum)
+ /* No APR support for getpid() so cannot use apr_proc_kill(). */
+ kill(getpid(), signum);
+ }
#endif
return exit_code;
Modified: subversion/trunk/subversion/svnfsfs/svnfsfs.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnfsfs/svnfsfs.h?rev=1729463&r1=1729462&r2=1729463&view=diff
==============================================================================
--- subversion/trunk/subversion/svnfsfs/svnfsfs.h (original)
+++ subversion/trunk/subversion/svnfsfs/svnfsfs.h Tue Feb 9 21:43:03 2016
@@ -63,8 +63,7 @@ open_fs(svn_fs_t **fs,
apr_pool_t *pool);
/* Our cancellation callback. */
-svn_error_t *
-check_cancel(void *baton);
+extern svn_cancel_func_t check_cancel;
#ifdef __cplusplus
}
Modified: subversion/trunk/subversion/svnlook/svnlook.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnlook/svnlook.c?rev=1729463&r1=1729462&r2=1729463&view=diff
==============================================================================
--- subversion/trunk/subversion/svnlook/svnlook.c (original)
+++ subversion/trunk/subversion/svnlook/svnlook.c Tue Feb 9 21:43:03 2016
@@ -379,52 +379,10 @@ typedef struct svnlook_ctxt_t
} svnlook_ctxt_t;
-/* A flag to see if we've been cancelled by the client or not. */
-static volatile sig_atomic_t cancelled = FALSE;
-static volatile sig_atomic_t signum_cancelled = 0;
-static int signal_map [] = {
- SIGINT
-#ifdef SIGBREAK
- /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
- , SIGBREAK
-#endif
-#ifdef SIGHUP
- , SIGHUP
-#endif
-#ifdef SIGTERM
- , SIGTERM
-#endif
-};
-
/*** Helper functions. ***/
-/* A signal handler to support cancellation. */
-static void
-signal_handler(int signum)
-{
- int i;
-
- apr_signal(signum, SIG_IGN);
- cancelled = TRUE;
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- if (signal_map[i] == signum)
- {
- signum_cancelled = i + 1;
- break;
- }
-}
-
-/* Our cancellation callback. */
-static svn_error_t *
-check_cancel(void *baton)
-{
- if (cancelled)
- return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
- else
- return SVN_NO_ERROR;
-}
-
+static svn_cancel_func_t check_cancel = NULL;
/* Version compatibility check */
static svn_error_t *
@@ -2827,21 +2785,7 @@ sub_main(int *exit_code, int argc, const
}
}
- /* Set up our cancellation support. */
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- apr_signal(signal_map[i], signal_handler);
-
-#ifdef SIGPIPE
- /* Disable SIGPIPE generation for the platforms that have it. */
- apr_signal(SIGPIPE, SIG_IGN);
-#endif
-
-#ifdef SIGXFSZ
- /* Disable SIGXFSZ generation for the platforms that have it, otherwise
- * working with large files when compiled against an APR that doesn't have
- * large file support will crash the program, which is uncool. */
- apr_signal(SIGXFSZ, SIG_IGN);
-#endif
+ check_cancel = svn_cmdline__setup_cancellation_handler();
/* Configure FSFS caches for maximum efficiency with svnadmin.
* Also, apply the respective command line parameters, if given. */
@@ -2906,17 +2850,13 @@ main(int argc, const char *argv[])
/* Resend any signal as this may cause the program to exit and
allows the shell to use WIFSIGNALED and WTERMSIG to detect the
signal. See http://www.cons.org/cracauer/sigint.html */
- if (cancelled && signum_cancelled)
- {
- int saved_signum = signal_map[signum_cancelled - 1];
+ {
+ int signum = svn_cmdline__get_cancellation_signal();
- if (saved_signum)
- {
- apr_signal(saved_signum, SIG_DFL);
- /* No APR support for getpid() so cannot use apr_proc_kill(). */
- kill(getpid(), saved_signum);
- }
- }
+ if (signum)
+ /* No APR support for getpid() so cannot use apr_proc_kill(). */
+ kill(getpid(), signum);
+ }
#endif
return exit_code;
Modified: subversion/trunk/subversion/svnrdump/svnrdump.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/svnrdump.c?rev=1729463&r1=1729462&r2=1729463&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/svnrdump.c (original)
+++ subversion/trunk/subversion/svnrdump/svnrdump.c Tue Feb 9 21:43:03 2016
@@ -52,49 +52,8 @@
/*** Cancellation ***/
-/* A flag to see if we've been cancelled by the client or not. */
-static volatile sig_atomic_t cancelled = FALSE;
-static volatile sig_atomic_t signum_cancelled = 0;
-static int signal_map [] = {
- SIGINT
-#ifdef SIGBREAK
- /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
- , SIGBREAK
-#endif
-#ifdef SIGHUP
- , SIGHUP
-#endif
-#ifdef SIGTERM
- , SIGTERM
-#endif
-};
-
-/* A signal handler to support cancellation. */
-static void
-signal_handler(int signum)
-{
- int i;
-
- apr_signal(signum, SIG_IGN);
- cancelled = TRUE;
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- if (signal_map[i] == signum)
- {
- signum_cancelled = i + 1;
- break;
- }
-}
-
/* Our cancellation callback. */
-static svn_error_t *
-check_cancel(void *baton)
-{
- if (cancelled)
- return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
- else
- return SVN_NO_ERROR;
-}
-
+static svn_cancel_func_t check_cancel = NULL;
@@ -832,19 +791,7 @@ sub_main(int *exit_code, int argc, const
os->interleave = TRUE; /* Options and arguments can be interleaved */
/* Set up our cancellation support. */
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- apr_signal(signal_map[i], signal_handler);
-
-#ifdef SIGPIPE
- /* Disable SIGPIPE generation for the platforms that have it. */
- apr_signal(SIGPIPE, SIG_IGN);
-#endif
-#ifdef SIGXFSZ
- /* Disable SIGXFSZ generation for the platforms that have it, otherwise
- * working with large files when compiled against an APR that doesn't have
- * large file support will crash the program, which is uncool. */
- apr_signal(SIGXFSZ, SIG_IGN);
-#endif
+ check_cancel = svn_cmdline__setup_cancellation_handler();
received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
@@ -1181,17 +1128,13 @@ main(int argc, const char *argv[])
/* Resend any signal as this may cause the program to exit and
allows the shell to use WIFSIGNALED and WTERMSIG to detect the
signal. See http://www.cons.org/cracauer/sigint.html */
- if (cancelled && signum_cancelled)
- {
- int saved_signum = signal_map[signum_cancelled - 1];
+ {
+ int signum = svn_cmdline__get_cancellation_signal();
- if (saved_signum)
- {
- apr_signal(saved_signum, SIG_DFL);
- /* No APR support for getpid() so cannot use apr_proc_kill(). */
- kill(getpid(), saved_signum);
- }
- }
+ if (signum)
+ /* No APR support for getpid() so cannot use apr_proc_kill(). */
+ kill(getpid(), signum);
+ }
#endif
return exit_code;
Modified: subversion/trunk/subversion/svnsync/svnsync.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnsync/svnsync.c?rev=1729463&r1=1729462&r2=1729463&view=diff
==============================================================================
--- subversion/trunk/subversion/svnsync/svnsync.c (original)
+++ subversion/trunk/subversion/svnsync/svnsync.c Tue Feb 9 21:43:03 2016
@@ -329,50 +329,8 @@ typedef struct opt_baton_t {
/*** Helper functions ***/
-/* Global record of whether the user has requested cancellation. */
-static volatile sig_atomic_t cancelled = FALSE;
-static volatile sig_atomic_t signum_cancelled = 0;
-static int signal_map [] = {
- SIGINT
-#ifdef SIGBREAK
- /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
- , SIGBREAK
-#endif
-#ifdef SIGHUP
- , SIGHUP
-#endif
-#ifdef SIGTERM
- , SIGTERM
-#endif
-};
-
-/* Callback function for apr_signal(). */
-static void
-signal_handler(int signum)
-{
- int i;
-
- apr_signal(signum, SIG_IGN);
- cancelled = TRUE;
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- if (signal_map[i] == signum)
- {
- signum_cancelled = i + 1;
- break;
- }
-}
-
-
/* Cancellation callback function. */
-static svn_error_t *
-check_cancel(void *baton)
-{
- if (cancelled)
- return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
- else
- return SVN_NO_ERROR;
-}
-
+static svn_cancel_func_t check_cancel = 0;
/* Check that the version of libraries in use match what we expect. */
static svn_error_t *
@@ -2389,21 +2347,7 @@ sub_main(int *exit_code, int argc, const
opt_baton.source_prop_encoding = source_prop_encoding;
- for (i = 0; i < sizeof(signal_map)/sizeof(signal_map[0]); ++i)
- apr_signal(signal_map[i], signal_handler);
-
-#ifdef SIGPIPE
- /* Disable SIGPIPE generation for the platforms that have it. */
- apr_signal(SIGPIPE, SIG_IGN);
-#endif
-
-#ifdef SIGXFSZ
- /* Disable SIGXFSZ generation for the platforms that have it,
- otherwise working with large files when compiled against an APR
- that doesn't have large file support will crash the program,
- which is uncool. */
- apr_signal(SIGXFSZ, SIG_IGN);
-#endif
+ check_cancel = svn_cmdline__setup_cancellation_handler();
err = svn_cmdline_create_auth_baton2(
&opt_baton.source_auth_baton,
@@ -2489,17 +2433,13 @@ main(int argc, const char *argv[])
/* Resend any signal as this may cause the program to exit and
allows the shell to use WIFSIGNALED and WTERMSIG to detect the
signal. See http://www.cons.org/cracauer/sigint.html */
- if (cancelled && signum_cancelled)
- {
- int saved_signum = signal_map[signum_cancelled - 1];
+ {
+ int signum = svn_cmdline__get_cancellation_signal();
- if (saved_signum)
- {
- apr_signal(saved_signum, SIG_DFL);
- /* No APR support for getpid() so cannot use apr_proc_kill(). */
- kill(getpid(), saved_signum);
- }
- }
+ if (signum)
+ /* No APR support for getpid() so cannot use apr_proc_kill(). */
+ kill(getpid(), signum);
+ }
#endif
return exit_code;