This file is indexed.

/usr/share/doc/python-jabber/patches/unused/JacobLundqvist/timeout_v0.3.1.diff is in python-jabber 0.5.0-1.6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
--- diffed/indented-namespaces	2003-01-12 21:48:56.000000000 +0100
+++ jabber.py	2003-01-12 22:02:01.000000000 +0100
@@ -387,38 +387,44 @@
 
     ## functions for sending element with ID's ##
 
-    def waitForResponse(self, ID, timeout=0):
+    def waitForResponse(self, ID, timeout=300):
         """Blocks untils a protocol element with the given id is received.
            If an error is received, waitForResponse returns None and
            self.lastErr and self.lastErrCode is set to the received error.  If
            the operation times out (which only happens if a timeout value is
            given), waitForResponse will return None and self.lastErr will be
-           set to "Timeout". """
+           set to "Timeout". 
+           Changed default from timeout=0 to timeout=300 to avoid hangs in
+           scripts and such.
+           If you _really_ want no timeout, just set it to 0"""
         ID = str(ID)
         self._expected[ID] = None
-        then = time.time()
         has_timed_out = False
-        ## TODO , add a timeout
-        while (not self._expected[ID]) or has_timed_out:
-            self.DEBUG("waiting on %s" % str(ID))
-            self.process(1)
-            if timeout and time.time()-then > timeout:
-                has_timed_out = True
-                
-        if has_timed_out:
-            self.lastErr = "Timeout"
-            return None
-        response = self._expected[ID]
-        del self._expected[ID]
-        if response.getErrorCode():
-            self.lastErr     = response.getError()
-            self.lastErrCode = response.getErrorCode()
-            return None
 
-        return response 
+        abort_time = time.time() + timeout
+        if timeout:
+            self.DEBUG("waiting with timeout:%s for %s" % (timeout,str(ID)))
+        else:
+            self.DEBUG("waiting for %s" % str(ID))
+        
+        while (not self._expected[ID]) and not has_timed_out:
+            self.process(0.2)
+            if timeout and (time.time() > abort_time):
+                has_timed_out = True
+        if has_timed_out:
+            self.lastErr = "Timeout"
+            return None
+        response = self._expected[ID]
+        del self._expected[ID]
+        if response.getErrorCode():
+            self.lastErr     = response.getError()
+            self.lastErrCode = response.getErrorCode()
+            return None
+        
+        return response
 
 
-    def SendAndWaitForResponse(self, obj, ID=None):
+    def SendAndWaitForResponse(self, obj, ID=None, timeout=300):
         """Sends a protocol element object and blocks until a response with
            the same ID is received.  The received protocol object is returned
            as the function result. """
@@ -429,7 +435,7 @@
                 obj.setID(ID)
         ID = str(ID)
         self.send(obj)
-        return self.waitForResponse(ID)
+        return self.waitForResponse(ID,timeout)
 
 
     def getAnID(self):