Here is the stripped-down code. The timer expires(reported by epoll_wait) in time but even though interval is set to zero, epoll_wait continually triggers a ready-to-read event (EPOLLIN) for the timer fd. Should it not be triggered just once as interval is set to 0? Answer epoll, poll(), select(), etc. will tell you if the timer descriptor is readable without blocking.
Tag: epoll
chaining multiple epoll instances
Can we add file descriptor returned by epoll_create to another epoll instance using epoll_ctl. how do we chain multiple epoll instances in the application, lets say if we have 2 epoll instances one coming from the application and the other coming from library. Please advise. Answer From man epoll Q3 Is the epoll file descriptor itself poll/epoll/selectable? A3 Yes. If
Linux asynchronous epoll() server having problems when EPOLLRDHUP occurrs
I’m trying to make an asynchronous web server using epoll() in Linux, but problems occur whenever the event EPOLLRDHUP occurs. When the flag EPOLLONESHOT is not set, the server tries to process a useless event (not EPOLLIN or EPOLLOUT) multiple times during the loop without stopping, which causes the server to be come completely unresponsive (and require a restart). When
How to read a [nonblocking] filedescriptor of a file that is appended to (aka, like tail -f)?
Actually, I am using libev; but under the hood this is using epoll (I’m only on linux). When I add a watcher to read a file and all data has been read then I do get a call back that there is data to read, but read(2) returns 0 (EOF). At that point I have to stop the watcher or
meaning of EPOLLERR from epoll_wait with a pipe
This is similar to the question 1 but is about pipes. If epoll_wait returns EPOLLERR for the write end of a pipe, how do I distinguish a general error condition from the read end of the pipe been closed? For the sockets case the answer was to use “use getsockopt and SO_ERROR to get the pending error” and compare that
epoll: must I use multi-threading
I’ve got a basic knowledge from here about epoll. I know that epoll can monitor multiple FDs and handle them. My question is: can a heavy event block the server so I must use multithreading? For example, the epoll of a server is monitoring 2 sockets A and B. Now A starts to send lot of messages to the server
Using linux epoll: epoll_ctl seems to have redundant parameter?
Usually on linux when we wish to use epoll, we first create a epfd, and then register fd and events to it. Above is a common example I found from internet. It works, but problem is: ev.data.fd=fd here I already have my “fd” assigned to ev structure. epoll_ctl still requires the 3rd parameter of this fd. While the 4th parameter
Linux: Recv randomly returns zero
I wrote a simple TCP network library with epoll for linux. In one of my tests, I want to test the throughput of the library. I send 2000000 msgs of 500 bytes. The binded socket randomly returns zero on a recv after 800000 or more msgs have been received. Other times, all messages are received. What would cause this to
Linux, C, epoll(), read() data incompleted?
Linux, C. Below issue only happens by using epoll(). If I use select() on server socket, there is no data loss. ============================= Update: I received errno =11 (Try again) in read(). Do I need to continue, or break the while loop? ============================= I have client side, send 1280 K data in 10 times (each time, I send 128K data); I
Epoll_wait returning events on closed file descriptor
I’m working with a multithreaded embedded application in which epoll is used for IO in one of the threads. I’m relying on a particular feature of epoll that specifies that closing a file descriptor automatically removes it from the epoll set (Question/Answer 6 in man 7 epoll). In this case, the file descriptor close is done in the same thread