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

Re: svn commit: r10132 - trunk/subversion/clients/cmdline

From: Greg Hudson <ghudson_at_MIT.EDU>
Date: 2004-07-04 19:06:53 CEST

On Sun, 2004-07-04 at 12:47, Ben Reser wrote:
> > The timeout should really be unnecessary. Unless I'm missing something,
> > apr_poll() should terminate with EINTR if a signal occurs. (On Unix,
> > anyway. I don't know how this all works under Windows.)
>
> Umm the timeout is the whole point. I'm trying to get an opportunity to
> call the cancel function. I think you missed the entire point of this
> exercise. If all I wanted to do was wait until someone typed something
> I wouldn't need any of this at all. But I want to wait for people to
> type something *AND* periodically poll for a cancel.

I did not miss the point of the exercise. If a handled signal is
invoked, apr_poll() will (on Unix) terminate with EINTR. (I don't even
see a separate Windows implementation of apr_poll, so I'm still confused
as to what happens there.) Your retry loop will of course catch the
EINTR and retry, but that's not really necessary.

Here's a test program if you want to verify. Notice that even though
SIGINT is handled, you can still interrupt the program with ^C.

#include <apr_file_io.h>
#include <apr_poll.h>
#include <apr_signal.h>

static apr_status_t wait_for_input(apr_file_t *f, apr_pool_t *pool)
{
  apr_pollfd_t pollset;
  int srv, n;

  pollset.desc_type = APR_POLL_FILE;
  pollset.desc.f = f;
  pollset.p = pool;
  pollset.reqevents = APR_POLLIN;
    
  srv = apr_poll(&pollset, 1, &n, -1);

  if (n == 1 && pollset.rtnevents & APR_POLLIN)
    return APR_SUCCESS;

  return srv;
}

static void handler(int signum)
{
}

int main()
{
  apr_pool_t *pool;
  apr_file_t *file;

  apr_initialize();
  apr_pool_create(&pool, NULL);
  apr_file_open_stdin(&file, pool);
  apr_signal(SIGINT, handler);
  wait_for_input(file, pool);
  return 0;
}

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Jul 4 19:09:26 2004

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