From 575fe8903cbabe9576b95aae8eb6ae077a5483aa Mon Sep 17 00:00:00 2001 From: Pieter Droogendijk Date: Sat, 7 Feb 2015 22:23:17 +0100 Subject: [PATCH] Comment about the buffer size to epoll_wait --- inotify_poller.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/inotify_poller.go b/inotify_poller.go index 726818c..8a95df6 100644 --- a/inotify_poller.go +++ b/inotify_poller.go @@ -73,6 +73,10 @@ func newFdPoller(fd int) (*fdPoller, error) { // Returns true if something is ready to be read, // false if there is not. func (poller *fdPoller) wait() (bool, error) { + // 3 possible events per fd, and 2 fds, makes a maximum of 6 events. + // I don't know whether epoll_wait returns the number of events returned, + // or the total number of events ready. + // I decided to catch both by making the buffer one larger than the maximum. events := make([]syscall.EpollEvent, 7) for { n, errno := syscall.EpollWait(poller.epfd, events, -1) @@ -87,7 +91,7 @@ func (poller *fdPoller) wait() (bool, error) { continue } if n > 6 { - // This should never happen. + // This should never happen. More events were returned than should be possible. return false, errors.New("epoll_wait returned more events than I know what to do with") } ready := events[:n] -- 2.50.1