diff options
Diffstat (limited to 'subversion/svnfsfs/svnfsfs.c')
-rw-r--r-- | subversion/svnfsfs/svnfsfs.c | 77 |
1 files changed, 16 insertions, 61 deletions
diff --git a/subversion/svnfsfs/svnfsfs.c b/subversion/svnfsfs/svnfsfs.c index f8b1e4b19992c..ed3e66470d920 100644 --- a/subversion/svnfsfs/svnfsfs.c +++ b/subversion/svnfsfs/svnfsfs.c @@ -21,8 +21,6 @@ * ==================================================================== */ -#include <apr_signal.h> - #include "svn_pools.h" #include "svn_cmdline.h" #include "svn_opt.h" @@ -42,45 +40,7 @@ /*** Code. ***/ -/* A flag to see if we've been cancelled by the client or not. */ -static volatile sig_atomic_t cancelled = FALSE; - -/* A signal handler to support cancellation. */ -static void -signal_handler(int signum) -{ - apr_signal(signum, SIG_IGN); - cancelled = TRUE; -} - - -/* A helper to set up the cancellation signal handlers. */ -static void -setup_cancellation_signals(void (*handler)(int signum)) -{ - apr_signal(SIGINT, handler); -#ifdef SIGBREAK - /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */ - apr_signal(SIGBREAK, handler); -#endif -#ifdef SIGHUP - apr_signal(SIGHUP, handler); -#endif -#ifdef SIGTERM - apr_signal(SIGTERM, handler); -#endif -} - - -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 @@ -341,8 +301,12 @@ sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool) opt_state.help = TRUE; break; case 'M': - opt_state.memory_cache_size - = 0x100000 * apr_strtoi64(opt_arg, NULL, 0); + { + apr_uint64_t sz_val; + SVN_ERR(svn_cstring_atoui64(&sz_val, opt_arg)); + + opt_state.memory_cache_size = 0x100000 * sz_val; + } break; case svnfsfs__version: opt_state.version = TRUE; @@ -391,17 +355,17 @@ sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool) } else { - const char *first_arg = os->argv[os->ind++]; + const char *first_arg; + + SVN_ERR(svn_utf_cstring_to_utf8(&first_arg, os->argv[os->ind++], + pool)); subcommand = svn_opt_get_canonical_subcommand2(cmd_table, first_arg); if (subcommand == NULL) { - const char *first_arg_utf8; - SVN_ERR(svn_utf_cstring_to_utf8(&first_arg_utf8, - first_arg, pool)); svn_error_clear( svn_cmdline_fprintf(stderr, pool, _("Unknown subcommand: '%s'\n"), - first_arg_utf8)); + first_arg)); SVN_ERR(subcommand__help(NULL, NULL, pool)); *exit_code = EXIT_FAILURE; return SVN_NO_ERROR; @@ -465,19 +429,7 @@ sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool) } /* 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. */ @@ -537,5 +489,8 @@ main(int argc, const char *argv[]) } svn_pool_destroy(pool); + + svn_cmdline__cancellation_exit(); + return exit_code; } |