Reputation: 934
I'm using a framework which I give a socket to and it will call my callback if there is data to be read (or if timeout).
However it keeps calling me as fast as my cpu can handle although there is no data to be read from the socket.
Here what I see in loop on strace:
[pid 16586] poll([{fd=16, events=POLLIN}, {fd=17, events=POLLIN}], 2, 1000) = 2 ([{fd=16, revents=POLLIN}, {fd=17, revents=POLLIN}])
[pid 16586] recvfrom(16, "", 1024, 0, NULL, NULL) = 0
Shouldn't the recvfrom() return something or the poll stops raising the even?
Or do I need to do something else to clean the event?
Upvotes: 4
Views: 1392
Reputation: 934
As mentioned in the comments, since the device I'm connected to closes the socket (as seen as FIN/ACK coming from the device in wireshark), it is seen as an EOF condition on my end.
As EOF also triggers the POLLIN event, this is why the event is continuously triggered.
Upvotes: 3