summaryrefslogtreecommitdiffstats
path: root/Include/pytime.h
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-09-28 21:23:11 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-09-28 21:23:11 (GMT)
commit3e1fd27b74af4f1f040f8b11379015140240deff (patch)
treef85346e8049da8b34c291286dd8a250102b93f14 /Include/pytime.h
parentcc868d430b0416e588d53698f560b236c6ba88d2 (diff)
downloadcpython-3e1fd27b74af4f1f040f8b11379015140240deff.zip
cpython-3e1fd27b74af4f1f040f8b11379015140240deff.tar.gz
cpython-3e1fd27b74af4f1f040f8b11379015140240deff.tar.bz2
Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
retry the select() loop instead of bailing out. This is because select() can incorrectly report a socket as ready for reading (for example, if it received some data with an invalid checksum).
Diffstat (limited to 'Include/pytime.h')
-rw-r--r--Include/pytime.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/Include/pytime.h b/Include/pytime.h
index 8ace982..964d096 100644
--- a/Include/pytime.h
+++ b/Include/pytime.h
@@ -25,6 +25,17 @@ typedef struct {
*/
PyAPI_FUNC(void) _PyTime_gettimeofday(_PyTime_timeval *tp);
+#define _PyTime_ADD_SECONDS(tv, interval) \
+do { \
+ tv.tv_usec += (long) (((long) interval - interval) * 1000000); \
+ tv.tv_sec += (time_t) interval + (time_t) (tv.tv_usec / 1000000); \
+ tv.tv_usec %= 1000000; \
+} while (0)
+
+#define _PyTime_INTERVAL(tv_start, tv_end) \
+ ((tv_end.tv_sec - tv_start.tv_sec) + \
+ (tv_end.tv_usec - tv_start.tv_usec) * 0.000001)
+
/* Dummy to force linking. */
PyAPI_FUNC(void) _PyTime_Init(void);