lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 17 Nov 2011 15:28:32 +0000
From:	Jamie Lokier <jamie@...reable.org>
To:	Robin Dong <hao.bigrat@...il.com>
Cc:	linux-api@...r.kernel.org, linux-netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org, davidel@...ilserver.org
Subject: Re: [Bug] epoll_wait return EPOLLOUT even with EPOLLET flag

Robin Dong wrote:
> Hi,
> 
> I am a linux user and I found some question when using epoll with EPOLLET.
> 
> My program's step:
> 
> 1. create a socket (sfd) and connect to server
> 2. create epoll (efd)
> 3. add socket descriptor (sfd) to epoll (efd) with flag EPOLLET
> 4. get a EPOLLOUT event through epoll_wait
> 
> After that, the program will nerver get a EPOLLOUT event because ituse
> EPOLLET mode (the same event will not be got twice)

Hi Robin,

With EPOLLET|EPOLLOUT, you should get a message from epoll whenever
the fd's status changes from "cannot output" to "can output".

So you should get a message when sfd transitions from write()
returning EAGAIN to write() accepting more data.

Until you get EAGAIN while writing, your program should assume the
socket is still writable.  "man epoll" has a few things to say about
this (look for all the places here it says EAGAIN).

> BUT,when a message comes from server,the client socket will get aevent
> and this event contains EPOLLOUT and EPOLLIN, looks epoll_waitreturn
> too much events than it should

The message always contains the latest status, so says EPOLLOUT|EPOLLIN.

It's doesn't mean there's an EPOLLOUT "event", it just means a message
is triggered (by the socket becoming readable) so you get a status
update.  In theory the program doesn't need to be told about EPOLLOUT
here (it should be assuming the socket is writable already), but it
doesn't do any harm.

EPOLLET is just a way to reduce the number of messages from epoll when
you call epoll_wait().  In effect you are telling the kernel "don't
send me repeated status messages and I'll maintain my own flags".  But
it doesn't change the status value in messages that are sent.

Enjoy,
-- Jamie
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ