----- Original Message -----
> On Fri, Aug 23, 2013 at 12:17 AM, James Peach <[email protected]> wrote:
> 
> > On Aug 22, 2013, at 5:01 AM, [email protected] wrote:
> >
> > > Updated Branches:
> > >  refs/heads/master e5d27294b -> fa176442f
> > >
> > >
> > > TS-2137: Use relative timeout in EventNotify::timedwait()
> > >
> > > 1) Use relative timeout in EventNotify::timedwait() function.
> > > 2) Remove unused m_name variable.
> > > 3) Use the correct marco HAVE_EVENTFD instead of TS_HAS_EVENTFD which
> > >   is outdated.
> >
> > Good catch!
> >
> > >
> > > Signed-off-by: Yunkai Zhang <[email protected]>
> > >
> > >
> > > Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> > > Commit:
> > http://git-wip-us.apache.org/repos/asf/trafficserver/commit/fa176442
> > > Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/fa176442
> > > Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/fa176442
> > >
> > > Branch: refs/heads/master
> > > Commit: fa176442f45a3d5e8a9dce332775172192f53f34
> > > Parents: e5d2729
> > > Author: Yunkai Zhang <[email protected]>
> > > Authored: Thu Aug 22 16:13:36 2013 +0800
> > > Committer: Yunkai Zhang <[email protected]>
> > > Committed: Thu Aug 22 19:56:02 2013 +0800
> > >
> > > ----------------------------------------------------------------------
> > > lib/ts/EventNotify.cc | 39 +++++++++++++++++++--------------------
> > > lib/ts/EventNotify.h  |  7 +++----
> > > 2 files changed, 22 insertions(+), 24 deletions(-)
> > > ----------------------------------------------------------------------
> > >
> > >
> > >
> > http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa176442/lib/ts/EventNotify.cc
> > > ----------------------------------------------------------------------
> > > diff --git a/lib/ts/EventNotify.cc b/lib/ts/EventNotify.cc
> > > index 5d0cc53..3a499b6 100644
> > > --- a/lib/ts/EventNotify.cc
> > > +++ b/lib/ts/EventNotify.cc
> > > @@ -30,14 +30,14 @@
> > > #include "EventNotify.h"
> > > #include "ink_hrtime.h"
> > >
> > > -#ifdef TS_HAS_EVENTFD
> > > +#ifdef HAVE_EVENTFD
> > > #include <sys/eventfd.h>
> > > #include <sys/epoll.h>
> > > #endif
> > >
> > > -EventNotify::EventNotify(const char *name): m_name(name)
> > > +EventNotify::EventNotify()
> > > {
> > > -#ifdef TS_HAS_EVENTFD
> > > +#ifdef HAVE_EVENTFD
> > >   int ret;
> > >   struct epoll_event ev;
> > >
> > > @@ -59,14 +59,14 @@ EventNotify::EventNotify(const char *name):
> > m_name(name)
> > >   ink_release_assert(ret != -1);
> > > #else
> > >   ink_cond_init(&m_cond);
> > > -  ink_mutex_init(&m_mutex, m_name);
> > > +  ink_mutex_init(&m_mutex, NULL);
> > > #endif
> > > }
> > >
> > > void
> > > EventNotify::signal(void)
> > > {
> > > -#ifdef TS_HAS_EVENTFD
> > > +#ifdef HAVE_EVENTFD
> > >   ssize_t nr;
> > >   uint64_t value = 1;
> > >   nr = write(m_event_fd, &value, sizeof(uint64_t));
> > > @@ -79,7 +79,7 @@ EventNotify::signal(void)
> > > void
> > > EventNotify::wait(void)
> > > {
> > > -#ifdef TS_HAS_EVENTFD
> > > +#ifdef HAVE_EVENTFD
> > >   ssize_t nr;
> > >   uint64_t value = 0;
> > >   nr = read(m_event_fd, &value, sizeof(uint64_t));
> > > @@ -90,20 +90,13 @@ EventNotify::wait(void)
> > > }
> > >
> > > int
> > > -EventNotify::timedwait(ink_timestruc *abstime)
> > > +EventNotify::timedwait(int timeout) // milliseconds
> >
> > Unless -1 is a meaningful value, I'd prefer this was unsigned.
> >
> 
> In some scenario, the upper layer store absolute time before calling
> timedwait, such as ProtectedQueue.
> 
> By using int type, the upper layer can calculate timeout more simply:
> 
>           timeout = now - abstime;
> 
> The upper layer needn't to care about whether the timeout is < 0. We will
> check it automatically inside the timedwait() function. I think use int
> type could be more user friendly.

maybe int64 is a better choice? 


-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: [email protected]
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE

Reply via email to