← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~pappacena/launchpad:librarian-epoll-data-read into launchpad:master

 

Thiago F. Pappacena has proposed merging ~pappacena/launchpad:librarian-epoll-data-read into launchpad:master.

Commit message:
Fixing how we check for incoming data on librarian client's epoll

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/388600
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:librarian-epoll-data-read into launchpad:master.
diff --git a/lib/lp/services/librarian/client.py b/lib/lp/services/librarian/client.py
index 3a32abe..4896cbf 100644
--- a/lib/lp/services/librarian/client.py
+++ b/lib/lp/services/librarian/client.py
@@ -118,7 +118,12 @@ class FileUploadClient:
         poll_result = self.state.s_poll.poll(0)
         if poll_result:
             fileno, event = poll_result[0]
-            if fileno != self.state.s.fileno() or event != select.EPOLLIN:
+            # Accepts any event that contains input data. Even if we
+            # only subscribed to EPOLLIN, when connection is closed right
+            # after sending data, we will receive [EPOLLHUP | EPOLLERR |
+            # EPOLLIN] == 25, for example). EPOLLIN is the first bit,
+            # so we should check just that for incoming data.
+            if fileno != self.state.s.fileno() or not event & select.EPOLLIN:
                 return
             response = six.ensure_str(
                 self.state.f.readline().strip(), errors='replace')