[Patches] [ python-Patches-1102879 ] Fix for 926423: socket timeouts + Ctrl-C don't play nice

SourceForge.net noreply at sourceforge.net
Thu Feb 24 21:42:18 CET 2005


Patches item #1102879, was opened at 2005-01-15 12:37
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1102879&group_id=5470

Category: Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Irmen de Jong (irmen)
Assigned to: Nobody/Anonymous (nobody)
Summary: Fix for 926423: socket timeouts + Ctrl-C don't play nice

Initial Comment:
Please have a close look at the attached patch.
Essentially, it fixes internal_select to not return
zero on error condition, and also adds a test for errno
at all calls to internal_select.

A few remarks:
1) as indicated in the patch, I'm not sure if errno
should also be tested in the internal_connect function;
2) 'timeout' is no longer a boolean indicating a
timeout condition, it should probably be renamed to
'selectresult' or something similar;
3) I'm not too happy with the fact that the
if(timeout==-1 && erro) test must be duplicated in a
lot of functions;
4) does it do the right thing? The check for
timeout==-1 MUST be there otherwise a lot of errors
turn up in the regression tests. With this patch they
run fine, btw



----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2005-02-24 21:42

Message:
Logged In: YES 
user_id=21627

Thanks for the patch.

1) I could not see where you dealt with internal_connect in
the patch. However, as a connect can also be cancelled with
Ctrl-C, I think you need to deal with it, too.

2) I agree, renaming it would be good

3) you could come up with a macro to avoid code duplication
(relying on consistent naming of variables, but that might
confure more than help

4) This is almost right. The critical thing is that you read
errno much too late. errno is meant to be read immediately
after the system call. Any later system call can modify the
value - including all of the pthread calls that we do
in-between. So the right solution is to copy errno right
after select, into a local variable of the caller, and read
*that* variable. In order to avoid modifying SetFromErrno,
you can assign back to errno before calling it.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1102879&group_id=5470


More information about the Patches mailing list