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

Re: [PATCH] cancellation, take one

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2003-02-17 19:03:38 CET

Garrett Rooney <rooneg@electricjellyfish.net> writes:

> * subversion/libsvn_subr/cancel.c: new file, implements the
> * cancellation editor.

I'm a little worried about the organisation of this stuff. The
cancellation editor is an svn_delta_editor_t editor but you have
implemented it in libsvn_subr. Doesn't that introduce a cyclic
dependency? You have libsvn_subr call svn_delta_default_editor but
libsvn_delta already uses libsvn_subr routines.

> Index: subversion/include/svn_cancel.h
> ===================================================================
> --- subversion/include/svn_cancel.h (working copy)
> +++ subversion/include/svn_cancel.h (working copy)
> @@ -0,0 +1,51 @@
> +/**
> + * @copyright
> + * ====================================================================
> + * Copyright (c) 2000-2003 CollabNet. All rights reserved.

2000-2003? Should a new file use that or just 2003?

> + *
> + * This software is licensed as described in the file COPYING, which
> + * you should have received as part of this distribution. The terms
> + * are also available at http://subversion.tigris.org/license-1.html.
> + * If newer versions of this license are posted there, you may use a
> + * newer version instead, at your option.
> + *
> + * This software consists of voluntary contributions made by many
> + * individuals. For exact contribution history, see the revision
> + * history and logs, available at http://subversion.tigris.org/.
> + * ====================================================================
> + * @endcopyright
> + *
> + * @file svn_cancel.h
> + * @brief Routines to support cancelation of running subversion functions.
> + */
> +
> +#include "svn_delta.h"
> +
> +#ifndef SVN_CANCEL_H
> +#define SVN_CANCEL_H
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif /* __cplusplus */
> +
> +/** A user defined callback that subversion will call with a user defined
> + * baton to see if the current operation should be continued. If the operation
> + * should continue, the function should return @c SVN_NO_ERROR, if not, it
> + * should return @c SVN_ERR_CANCELLED.
> + */
> +typedef svn_error_t *(*svn_cancel_func_t) (void *cancel_baton);
> +
> +svn_error_t *
> +svn_cancel_get_cancellation_editor (svn_cancel_func_t cancel_func,
> + void *cancel_baton,
> + const svn_delta_editor_t *wrapped_editor,
> + void *wrapped_baton,
> + const svn_delta_editor_t **editor,
> + void **edit_baton,
> + apr_pool_t *pool);
> +
> +#ifdef __cplusplus
> +}
> +#endif /* __cplusplus */
> +
> +#endif /* SVN_CANCEL_H */
> Index: subversion/clients/cmdline/main.c
> ===================================================================
> --- subversion/clients/cmdline/main.c (revision 4912)
> +++ subversion/clients/cmdline/main.c (working copy)
> @@ -29,6 +29,7 @@
> #include <apr_tables.h>
> #include <apr_general.h>
> #include <apr_lib.h>
> +#include <apr_signal.h>
>
> #include "svn_pools.h"
> #include "svn_wc.h"
> @@ -506,7 +507,23 @@
> { NULL, NULL, {0}, NULL, {0} }
> };
>
   /* Flag used by the SIGINT signal handler */
> +static volatile sig_atomic_t interrupted = 0;
>
   /* A SIGINT signal handler */
> +static void
> +sig_int (int unused)
> +{
> + interrupted = 1;
> +}
> +

   /* A cancellation editor cancel callback */
> +static svn_error_t *
> +check_cancel (void *baton)
> +{
> + if (interrupted)
> + return svn_error_create (SVN_ERR_CANCELLED, NULL, "caught SIGINT");
> + else
> + return SVN_NO_ERROR;
> +}
> +
>
> /*** Main. ***/
>
> @@ -945,6 +962,10 @@
> ctx.log_msg_baton = svn_cl__make_log_msg_baton (&opt_state, NULL,
> ctx.config, pool);
>
> + apr_signal (SIGINT, sig_int);
> +
> + ctx.cancel_func = check_cancel;
> +
> err = (*subcommand->cmd_func) (os, &command_baton, pool);
> if (err)
> {

-- 
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Feb 17 19:04:27 2003

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