All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phil Turmel <philip@turmel.org>
To: Eric Wong <normalperson@yhbt.net>
Cc: Andreas Voellmy <andreas.voellmy@yale.edu>,
	viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: epoll with ONESHOT possibly fails to deliver events
Date: Thu, 13 Dec 2012 19:15:02 -0500	[thread overview]
Message-ID: <50CA6F86.30608@turmel.org> (raw)
In-Reply-To: <50CA6E04.1070105@turmel.org>

On 12/13/2012 07:08 PM, Phil Turmel wrote:
> On 12/13/2012 04:32 AM, Eric Wong wrote:
>> Andreas Voellmy <andreas.voellmy@yale.edu> wrote:
> 
> [trim /]
> 
>>>> Another thread, distinct from all of the threads serving particular
>>>> sockets, is perfoming epoll_wait calls. When sockets are returned as
>>>> being ready from an epoll_wait call, the thread signals to the
>>>> condition variable for the socket.
>>
>> Perhaps there is a bug in the way your epoll_wait thread
>> uses the condition variable to notify other threads?
> 
> Have you considered the possibility that data is arriving between
> epoll_ctl and pthread_cond_wait ?  If your monitoring thread returns
> from epoll_wait within this race window, it will call
> pthread_cond_signal while the first thread is not yet waiting for it.
> With the one-shot flag, the next iteration of epoll_wait won't see that
> socket's new data.

Let me clarify:

The read thread must perform the epoll_ctl between pthread_mutex_lock
and pthread_cond_wait, while the monitoring thread must hold the mutex
lock when signaling.

pthread_cond_signal and pthread_cond_broadcast don't require the caller
to hold the mutex in general, but your app needs it.

Phil

      reply	other threads:[~2012-12-14  0:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-11 22:23 epoll with ONESHOT possibly fails to deliver events Andreas Voellmy
2012-12-12 23:49 ` Andreas Voellmy
2012-12-13  9:32   ` Eric Wong
2012-12-13 15:29     ` Andreas Voellmy
2012-12-14  0:16       ` Andreas Voellmy
2012-12-14  0:16         ` Andreas Voellmy
2012-12-15 14:50         ` Andreas Voellmy
2012-12-15 14:50           ` Andreas Voellmy
2012-12-18  2:07           ` Eric Wong
2012-12-18  2:35             ` Andreas Voellmy
2012-12-18 17:27               ` Andreas Voellmy
2012-12-19 19:39                 ` Andreas Voellmy
2012-12-20 21:32         ` Eric Wong
2012-12-20 22:25           ` Junchang(Jason) Wang
2012-12-21 15:32             ` Andreas Voellmy
2012-12-22  2:54             ` Eric Wong
2012-12-14  0:08     ` Phil Turmel
2012-12-14  0:15       ` Phil Turmel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50CA6F86.30608@turmel.org \
    --to=philip@turmel.org \
    --cc=andreas.voellmy@yale.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.