[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [chutney/master] Use values from errno instead of literal constants.



commit dfa4cd3a77ff5e5b3b2dfefff167efad3f546a8e
Author: Linus Nordberg <linus@xxxxxxxxxxxxxx>
Date:   Wed Jun 5 15:48:57 2013 +0200

    Use values from errno instead of literal constants.
    
    Now it might even have a chance of working on non-linuxes!
---
 lib/chutney/Traffic.py |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/chutney/Traffic.py b/lib/chutney/Traffic.py
old mode 100755
new mode 100644
index 4ab4fff..efee8e2
--- a/lib/chutney/Traffic.py
+++ b/lib/chutney/Traffic.py
@@ -9,6 +9,7 @@
 import socket
 import select
 import struct
+import errno
 
 debug_flag = False
 
@@ -138,7 +139,7 @@ class Source(Peer):
         try:
             self.s.connect(dest)
         except socket.error, e:
-            if e[0] != 115:     # EINPROGRESS
+            if e[0] != errno.EINPROGRESS:
                 raise
 
     def on_readable(self):
@@ -176,7 +177,7 @@ class Source(Peer):
         try:
             n = self.s.send(self.outbuf)
         except socket.error, e:
-            if e[0] == 111:     # ECONNREFUSED
+            if e[0] == errno.ECONNREFUSED:
                 debug("connection refused (fd=%d)" % self.fd())
                 return -1
             raise
@@ -185,7 +186,7 @@ class Source(Peer):
         if self.state == self.CONNECTING_THROUGH_PROXY:
             return 1            # Keep us around.
         return len(self.outbuf) # When 0, we're being removed.
-        
+
 class TrafficTester():
     def __init__(self, endpoint, data={}, timeout=3):
         self.listener = Listener(self, endpoint)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits