Can non-blocking sockets be used with epoll's level triggered mode?

152 views Asked by At

Currently I have a server application which supports multiple client sessions. Server is running with epoll's edge triggered mode. The sockets which are used inside the server are all non-blocking in nature. The main epoll loop looks something like this,

n = epoll_wait()
iterate over n
  if event is epollin(assume client has written some data)
    while(1)
      drain the buffer untill you get EAGAIN
      break

Problem here arises when the data continuously flowing over the buffer and buffer never drains. The other sessions does not get a chance to be entertained by the server. Because of this possible starvation to other clients, I am thinking of using level triggered mode which allows server to entertain all the active sessions in a round robin way. Can I just use level triggered mode by removing "EPOLLET" from the subscribed event and read buffer data once(like, in LT mode)? Any comments/references are appreciated. Thanks !

0

There are 0 answers