cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH] HTTP pipelining test

From: Linus Nielsen Feltzing <linus_at_haxx.se>
Date: Tue, 16 Apr 2013 09:27:37 +0200

Use poll() instead of epoll(), since that is Linux-only.

---
 tests/http_pipe.py |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tests/http_pipe.py b/tests/http_pipe.py
index 67185be..66a453e 100755
--- a/tests/http_pipe.py
+++ b/tests/http_pipe.py
@@ -357,8 +357,8 @@ class PipelineRequestHandler(SocketServer.BaseRequestHandler):
     self._send_buffer = ""
     self._start_time = time.time()
     try:
-      poller = select.epoll(sizehint=1)
-      poller.register(self.request.fileno(), select.EPOLLIN)
+      poller = select.poll()
+      poller.register(self.request.fileno(), select.POLLIN)
       while not self._response_builder.processed_end or self._send_buffer:
 
         time_left = self._GetTimeUntilTimeout()
@@ -369,10 +369,10 @@ class PipelineRequestHandler(SocketServer.BaseRequestHandler):
         if max_poll_time > 0:
           if self._send_buffer:
             poller.modify(self.request.fileno(),
-                          select.EPOLLIN | select.EPOLLOUT)
+                          select.POLLIN | select.POLLOUT)
           else:
-            poller.modify(self.request.fileno(), select.EPOLLIN)
-          events = poller.poll(timeout=max_poll_time)
+            poller.modify(self.request.fileno(), select.POLLIN)
+          events = poller.poll(max_poll_time)
 
         if self._GetTimeUntilTimeout() <= 0:
           return
@@ -383,7 +383,7 @@ class PipelineRequestHandler(SocketServer.BaseRequestHandler):
           self._last_queued_time = 0
 
         for fd, mode in events:
-          if mode & select.EPOLLIN:
+          if mode & select.POLLIN:
             new_data = self.request.recv(MAX_REQUEST_SIZE, socket.MSG_DONTWAIT)
             if not new_data:
               return
@@ -392,7 +392,7 @@ class PipelineRequestHandler(SocketServer.BaseRequestHandler):
                 new_requests, self._request_parser.were_all_requests_http_1_1)
             self._num_queued += len(new_requests)
             self._last_queued_time = time.time()
-          elif mode & select.EPOLLOUT:
+          elif mode & select.POLLOUT:
             num_bytes_sent = self.request.send(self._send_buffer[0:4096])
             self._send_buffer = self._send_buffer[num_bytes_sent:]
             time.sleep(0.05)
-- 
1.7.10.4
--------------010202040009060302040800
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
--------------010202040009060302040800--
Received on 2001-09-17