From 793c65cc6135ae65d06bdb63497d00263ae83257 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 7 Oct 2013 00:34:06 +0000 Subject: [PATCH] attempt to fix test http proxy to handle EAGAIN errors --- test/http.py | 15 ++++++++++++--- test/setup_transfer.cpp | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/test/http.py b/test/http.py index 6833cf341..484c53821 100644 --- a/test/http.py +++ b/test/http.py @@ -81,7 +81,7 @@ Qual a diferença entre um proxy Elite, Anónimo e Transparente? """ -import socket, thread, select, sys, base64 +import socket, thread, select, sys, base64, time __version__ = '0.1.0 Draft 1' BUFLEN = 8192 @@ -124,7 +124,16 @@ class ConnectionHandler: def get_base_header(self): while 1: - self.client_buffer += self.client.recv(BUFLEN) + try: + self.client_buffer += self.client.recv(BUFLEN) + except Exception, e: + print dir(e) + print type(e) + # 35 == EAGAIN + if e.errno == 35: + time.sleep(0.5) + continue + raise e end = self.client_buffer.find('\r\n\r\n') if end!=-1: break @@ -185,7 +194,7 @@ class ConnectionHandler: if count == time_out_max: break -def start_server(host='localhost', port=8080, IPv6=False, timeout=60, +def start_server(host='localhost', port=8080, IPv6=False, timeout=100, handler=ConnectionHandler): if IPv6==True: soc_type=socket.AF_INET6 diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 778930480..118afbbf3 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -447,7 +447,7 @@ int start_proxy(int proxy_type) char buf[512]; snprintf(buf, sizeof(buf), "%s --port %d%s", cmd, port, auth); - fprintf(stderr, "%s starting socks proxy on port %d (%s %s)...\n", time_now_string(), port, type, auth); + fprintf(stderr, "%s starting proxy on port %d (%s %s)...\n", time_now_string(), port, type, auth); fprintf(stderr, "%s\n", buf); int r = async_run(buf); if (r == 0) exit(1);