Issue 13694: asynchronous connect in asyncore.dispatcher does not set addr (original) (raw)

Created on 2012-01-02 02:15 by anacrolix, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
dispatcher_connect_addr.patch anacrolix,2012-01-02 02:15 review
Messages (9)
msg150449 - (view) Author: Matt Joiner (anacrolix) Date: 2012-01-02 02:15
Patch attached
msg150455 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2012-01-02 13:14
I'm not sure how useful this is as addr will be set later, when connection is established.
msg150487 - (view) Author: Matt Joiner (anacrolix) Date: 2012-01-03 00:42
I don't believe it is. dispatcher.addr is only set if the connection is immediately established. It's set explicitly in dispatcher.__init__ if a socket is provided that is already connected. It's *not* set after a connection completes. There are 2 solutions as I see it: 1) Set addr after a successful call to socket.connect indicates that a connection is being established. Currently this only occurs if the connection is not delayed. 2) Set the addr when a connect event completes. This would require making getpeername calls like in dispatcher.__init__ and would be significantly more expensive. My patch implements method 1. This conforms to existing addr-setting behaviour in dispatcher.bind.
msg155914 - (view) Author: Matt Joiner (anacrolix) Date: 2012-03-15 17:16
I should mention that this failure to set addr is unusual seeing as most socket instances are wrapping AF_INET* domain sockets, and aren't likely to connect without blocking. This is quite likely a reason nobody has observed it until now. It *is* desirable to save addr at this point, as mentioned in previous comments. Additionally addr is public API insofar as asyncore.sockets are concerned.
msg156414 - (view) Author: Matt Joiner (anacrolix) Date: 2012-03-20 14:40
This patch is a shoo-in, can someone review and commit this?
msg156421 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-20 15:44
New changeset 1c0058991740 by Giampaolo Rodola' in branch 'default': Fix issue #13694: asynchronous connect in asyncore.dispatcher does not set addr. http://hg.python.org/cpython/rev/1c0058991740
msg156422 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-20 15:47
New changeset 4e5ddde76dbe by Giampaolo Rodola' in branch '2.7': Fix issue #13694: asynchronous connect in asyncore.dispatcher does not set addr. http://hg.python.org/cpython/rev/4e5ddde76dbe
msg156423 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-20 15:50
New changeset a5add01e96be by Giampaolo Rodola' in branch '3.2': Fix issue #13694: asynchronous connect in asyncore.dispatcher does not set addr. http://hg.python.org/cpython/rev/a5add01e96be
msg156424 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2012-03-20 15:51
Done. Sorry for the delay.
History
Date User Action Args
2022-04-11 14:57:25 admin set github: 57903
2012-03-20 15:51:39 giampaolo.rodola set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2012-03-20 15:50:04 python-dev set messages: +
2012-03-20 15:47:03 python-dev set messages: +
2012-03-20 15:44:37 python-dev set nosy: + python-devmessages: +
2012-03-20 14:40:18 anacrolix set messages: +
2012-03-15 17:16:52 anacrolix set nosy: + akuchlingmessages: +
2012-01-03 00:42:50 anacrolix set messages: +
2012-01-02 15:01:48 rosslagerwall set nosy: + rosslagerwall
2012-01-02 13:14:03 giampaolo.rodola set messages: +
2012-01-02 12:59:18 pitrou set nosy: + josiahcarlson, giampaolo.rodola, stutzbachstage: patch reviewversions: - Python 2.6, Python 3.1
2012-01-02 02:15:15 anacrolix create