classification
Title: asynchronous connect in asyncore.dispatcher does not set addr
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, anacrolix, giampaolo.rodola, josiahcarlson, python-dev, rosslagerwall, stutzbach
Priority: normal Keywords: patch

Created on 2012-01-02 02:15 by anacrolix, last changed 2012-03-20 15:51 by giampaolo.rodola. 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) 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) 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) 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
2012-03-20 15:51:39giampaolo.rodolasetstatus: open -> closed
resolution: fixed
messages: + msg156424

stage: patch review -> resolved
2012-03-20 15:50:04python-devsetmessages: + msg156423
2012-03-20 15:47:03python-devsetmessages: + msg156422
2012-03-20 15:44:37python-devsetnosy: + python-dev
messages: + msg156421
2012-03-20 14:40:18anacrolixsetmessages: + msg156414
2012-03-15 17:16:52anacrolixsetnosy: + akuchling
messages: + msg155914
2012-01-03 00:42:50anacrolixsetmessages: + msg150487
2012-01-02 15:01:48rosslagerwallsetnosy: + rosslagerwall
2012-01-02 13:14:03giampaolo.rodolasetmessages: + msg150455
2012-01-02 12:59:18pitrousetnosy: + josiahcarlson, giampaolo.rodola, stutzbach
stage: patch review

versions: - Python 2.6, Python 3.1
2012-01-02 02:15:15anacrolixcreate