LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-12-2014, 01:36 AM   #1
akonchada
LQ Newbie
 
Registered: Sep 2010
Posts: 21

Rep: Reputation: 1
Strange behavior from epoll in RHEL 6.5


Hello,

Saw some strange behavior from epoll with RHEL 6.5 Kernal ( 2.6.32-431.el6.x86_64).
I have created 2 threads one for reading data from socket and other for sending data on to socket. During my initialization i am creating my epoll FD using "epoll_create1(0)" and after that i will start adding my socket descriptors to it for poll.

While adding my socket to poll list, i am doing
epoll_ctl(m_epoll_fd, operation, socket_fd, &event)
m_epoll_fd : one i created using "epoll_create1(0)"
operation : EPOLL_CTL_ADD or EPOLL_CTL_DEL
socket_fd : Socket FD i created after Socket connection is established
event : "struct epoll_event" with my own data epoll_event.data.ptr and epoll_event.events is "EPOLLIN".

What i am seeing after all this is, after closing the connection and after removing the Socket FD from poll list, i am still getting "EPOLLIN" events for this socket. Also it is not once but varies, sofar i observed highest number of "EPOLLIN" events i received after closing and removing the FD from poll list is 14times.

My question is, is there any know issue in epoll of RHEL 6.5?
Or do i need to do something extra or i am doing something wrong?

Regards,
Ananth
 
Old 06-12-2014, 02:23 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
The event cache could cause the behavior.

If you use an event cache or store all the fd's returned from epoll_wait(2), then make sure to provide a way to mark its closure dynamically (ie- caused by a previous event's processing). Suppose you receive 100 events from epoll_wait(2), and in eventi #47 a condition causes event #13 to be closed. If you remove the structure and close() the fd for event #13, then your event cache might still say there are events waiting for that fd causing confusion.

One solution for this is to call, during the processing of event 47, epoll_ctl(EPOLL_CTL_DEL) to delete fd 13 and close(), then mark its associated data structure as removed and link it to a cleanup list. If you find another event for fd 13 in your batch processing, you will discover the fd had been previously removed and there will be no confusion.
 
Old 06-16-2014, 12:12 AM   #3
akonchada
LQ Newbie
 
Registered: Sep 2010
Posts: 21

Original Poster
Rep: Reputation: 1
Thanks Nini, let me try this out.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange cdrom behavior MasterOfTheWind Linux - Hardware 1 04-12-2006 04:29 AM
Very Strange Behavior raysr Mandriva 4 08-31-2004 02:06 PM
Strange behavior with KDE tsw Linux - Software 2 05-08-2004 11:08 PM
Strange Behavior andrewb758 Linux - Hardware 5 08-31-2003 02:42 PM
strange behavior abhijit Linux - General 3 07-09-2003 11:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration