[SERVER-19220] have NetworkInterfaceASIO set up its own sockets Created: 29/Jun/15  Updated: 05/Feb/16  Resolved: 07/Jul/15

Status: Closed
Project: Core Server
Component/s: Networking
Affects Version/s: 3.1.5
Fix Version/s: 3.1.6

Type: Task Priority: Major - P3
Reporter: Samantha Ritter (Inactive) Assignee: Samantha Ritter (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Minor Change
Sprint: Platform 6 07/17/15
Participants:

 Comments   
Comment by Adam Midvidy [ 14/Jul/15 ]

There actually is a minor backwards compatibility change here regarding how we handle DNS resolution.

In the old networking code we only attempt to connect to the first address that getaddrinfo() returns. See the following code from sock.cpp

int ret = getaddrinfo(target.c_str(), ss.str().c_str(), &hints, &addrs);                                                                                                                                       
// .. other code ..
 // TODO: handle other addresses in linked list;                                                                                                                                                                
fassert(16501, addrs->ai_addrlen <= sizeof(sa));                                                                                                                                                               
memcpy(&sa, addrs->ai_addr, addrs->ai_addrlen);                                                                                                                                                                
addressSize = addrs->ai_addrlen;                                 

As the TODO says, we ignore the other entries of the linked list and only (later) attempt to connect to the first one.

From the getaddrinfo manpage:

There are several reasons why the linked list may have more than one addrinfo structure,
including: the network host is multihomed, accessible over multiple protocols (e.g., both
AF_INET and AF_INET6); or the same service is available from multiple socket types (one
SOCK_STREAM address and another SOCK_DGRAM address, for example). Normally, the application
should try using the addresses in the order in which they are returned. The sorting function
used within getaddrinfo() is defined in RFC 3484; the order can be tweaked for a particular
system by editing /etc/gai.conf (available since glibc 2.5).

ASIO will actually do this for us in async_connect; it will iterate the entries for us until it successfully connects (or all the attempts fail).

Doc for async_connect:

This function attempts to connect a socket to one of a sequence of

  • endpoints. It does this by repeated calls to the socket's @c async_connect
  • member function, once for each endpoint in the sequence, until a connection
  • is successfully established.

I think this is a desirable behavior change (thus the TODO), but it is something we should probably note in the release notes - cc milkie, acm

Comment by Githook User [ 07/Jul/15 ]

Author:

{u'username': u'samantharitter', u'name': u'Samantha Ritter', u'email': u'samantha.ritter@10gen.com'}

Message: SERVER-19220 NetworkInterfaceASIO sets up its own sockets
Branch: master
https://github.com/mongodb/mongo/commit/b1c26e0b08b74ece99bddf911707edeba543107c

Comment by Githook User [ 07/Jul/15 ]

Author:

{u'username': u'samantharitter', u'name': u'Samantha Ritter', u'email': u'samantha.ritter@10gen.com'}

Message: SERVER-19220 Untangle connection logic for future work
Branch: master
https://github.com/mongodb/mongo/commit/4f6d9818210a045dbb9c85fb7cb8ff9c181796d9

Comment by Githook User [ 07/Jul/15 ]

Author:

{u'username': u'samantharitter', u'name': u'Samantha Ritter', u'email': u'samantha.ritter@10gen.com'}

Message: SERVER-19220 only store protocol information with socket
Branch: master
https://github.com/mongodb/mongo/commit/86cbf569b5184e8e3e8670c3af1eaa403179b4cf

Comment by Samantha Ritter (Inactive) [ 30/Jun/15 ]

Yes, adam.midvidy, ASIO provides that functionality.

Comment by Adam Midvidy [ 29/Jun/15 ]

note that this should also include async dns resolution

Generated at Thu Feb 08 03:50:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.