BIND 10 #805: Client side code to request new sockets (C++)

BIND 10 Development do-not-reply at isc.org
Sat Dec 24 11:04:30 UTC 2011


#805: Client side code to request new sockets (C++)
-------------------------------------+-------------------------------------
                   Reporter:         |                 Owner:  UnAssigned
  stephen                            |                Status:  reviewing
                       Type:         |             Milestone:
  enhancement                        |  Sprint-20120110
                   Priority:         |            Resolution:
  blocker                            |             Sensitive:  0
                  Component:         |           Sub-Project:  DNS
  Unclassified                       |  Estimated Difficulty:  5
                   Keywords:         |           Total Hours:  0
            Defect Severity:  N/A    |
Feature Depending on Ticket:         |
  Socket creator                     |
        Add Hours to Ticket:  0      |
                  Internal?:  0      |
-------------------------------------+-------------------------------------

Comment (by vorner):

 So, answering this from #1522:

 > dns_server_unittest.cc
 > This is not for this branch (I guess it's a result of importing #805),
 > but the tests didn't pass for me, too. I needed to add this:
 > {{{#!c++
 >          struct sockaddr_in addr;
 > +        memset(&addr, 0, sizeof(addr));
 >          addr.sin_family = AF_INET;
 > }}}
 > While looking at it I noticed some other things for this file:
 >  * some of the above comments apply to this implementation, too:
 exception safety, consideration for sin_len, non plain-old static object,
 unnecessary namescope-level static.
 >  * I would personally use getaddrinfo to create a sockaddr() to avoid
 this kind of portability issue.
 >  * I would use IPv6 for testing for future generation software like BIND
 10 (we could also test IPv4 if we want).
 >  * technically, passing protocol 0 to socket for AF_INET isn't good:
 > {{{#!c++
 >         int result(socket(AF_INET, type, 0));
 > }}}
 >  If and when DCCP or SCTP is more common this can be ambiguous.

 I switched for the getaddrinfo way. I'm not sure if the protocol field is
 needed, as the type is SOCK_STREAM or SOCK_DGRAM always (and for the DCCP
 or SCTP, there'd be a different type), but I use it anyway.

 An IPv6 address is used (I didn't want to change the whole tests again to
 run twice, once with one and once with other address).

 I did try to find some of the unnecessary static ones (but there are some
 that are needed, some are function-level and some make it not compile when
 removed). Also, the std::string, while arguably safe as it is standard
 library, is now char*.

 I didn't notice anything about exception safety, only the socket wasn't
 released when it returned an error. But if there was an exception, the
 test would terminate right away anyway, so I don't think it is important.

 Did I miss something important?

 Thank you

-- 
Ticket URL: <http://bind10.isc.org/ticket/805#comment:9>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development


More information about the bind10-tickets mailing list