Message239758
With the PEP 475, the BEGIN_SELECT_LOOP and END_SELECT_LOOP macros of Modules/socketmodule.c became complex. Moreover, they are misused to handle EINTR. Most functions currently reimplemented their own loop inside the existing "select loop", and so the timeout is not recomputed correctly.
Attached patch replaces the two macros with a new sock_call() function which takes a function as a parameter. IMO, the new code (sock_xxx_impl functions) is simpler to read, understand and debug.
I hate debugging code (especially in gdb) using complex macros.
Copy of sock_call() documentation:
/* Call a socket function.
If the socket has a timeout, wait until the socket is ready before calling
the function: wait until the socket is writable if writing is nonzero, wait
until the socket received data otherwise.
If the function is interrupted by a signal (failed with EINTR): retry the
function, except if the signal handler raised an exception (PEP 475).
When the function is retried, recompute the timeout using a monotonic clock.
Raise an exception and return -1 on error, return 0 on success. */
I was surprised by the number of lines of code. It probably means that we are solving a non trivial problem: calling correctly socket functions with a timeout and retrying when interrupted by a signal. |
|
Date |
User |
Action |
Args |
2015-03-31 22:55:07 | vstinner | set | recipients:
+ vstinner, pitrou, neologix, serhiy.storchaka |
2015-03-31 22:55:06 | vstinner | set | messageid: <1427842506.28.0.704301607448.issue23834@psf.upfronthosting.co.za> |
2015-03-31 22:55:06 | vstinner | link | issue23834 messages |
2015-03-31 22:55:06 | vstinner | create | |
|