mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Hindman <b...@berkeley.edu>
Subject Re: Review Request 53460: Refactored network::Address into inet::Address.
Date Tue, 29 Nov 2016 20:00:56 GMT


> On Nov. 20, 2016, 11:31 p.m., James Peach wrote:
> > 3rdparty/libprocess/include/process/address.hpp, line 129
> > <https://reviews.apache.org/r/53460/diff/4/?file=1554471#file1554471line129>
> >
> >     Suggest that this should be `explicit`. There's some risk that strings like
`127.0.0.1` would be coverted implicitly, whereas if you have to explicitly convert to `unix::Address`
this is unlikely.

Agreed, done.


> On Nov. 20, 2016, 11:31 p.m., James Peach wrote:
> > 3rdparty/libprocess/include/process/address.hpp, line 241
> > <https://reviews.apache.org/r/53460/diff/4/?file=1554471#file1554471line241>
> >
> >     My usual pattern for dealing with socket addresses is to use a union, which
avoids the fiddly memory copies and casting. For example:
> >     ```
> >     union {
> >       sockaddr sa;
> >       sockaddr_storage storage;
> >       sockaddr_in sin;
> >       sockaddr_in6 sin6;
> >       sockaddr_un sun;
> >     } addr = {0};
> >     
> >     addr.sin.sin_family = AF_INET;
> >     addr.sin.sin_addr = ip.in().get();
> >     addr.sin.sin_port = htons(port);
> >     return network::Address(addr.storage);
> >     ```
> >     
> >     This union helps in lots of places to make code cleaner and to avoid explicit
casting.
> >     
> >     I'm not a fan of building APIs that accept `sockaddr_storage`, since that is
what `sockaddr` is for, but that could jut be a matter of taste :)

I like the `union`, thanks! I'm still using `sockaddr_storage` however, because IIUC `sockaddr`
is not actually big enough to deal with things like `sockaddr_in6`, hence the introduction
of `sockaddr_storage`. I still see `sockaddr` being sufficient when passing by pointer/reference,
but not when wanting to copy all the bits. Am I missing something here?


- Benjamin


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/53460/#review156427
-----------------------------------------------------------


On Nov. 28, 2016, 6:15 a.m., Benjamin Hindman wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/53460/
> -----------------------------------------------------------
> 
> (Updated Nov. 28, 2016, 6:15 a.m.)
> 
> 
> Review request for mesos, Benjamin Mahler and Jie Yu.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Also added unix::Address.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/Makefile.am 71319891a451bd1d565210dcce2fb61fc69e1f61 
>   3rdparty/libprocess/include/process/address.hpp 04e3155d65f476208fa852e83b79d173b66288fd

>   3rdparty/libprocess/include/process/network.hpp 52110667185370a4c92e2fa524819ab1f34bdec9

>   3rdparty/libprocess/include/process/socket.hpp f798af7879546d71e8ef4a295c9cf489a70cb61f

>   3rdparty/libprocess/include/process/ssl/gtest.hpp 21a0fc45b55a368a21b3e616c751ab43eebd4902

>   3rdparty/libprocess/src/address.cpp PRE-CREATION 
>   3rdparty/libprocess/src/libevent_ssl_socket.cpp 5c0929d3d9f5595bd2f343b98b899fd6b06a67b2

>   3rdparty/libprocess/src/poll_socket.cpp eb7b48713edd30b545d7be95b5d51b0f71bd422a 
>   3rdparty/libprocess/src/process.cpp e9a4bbb0b2410e0260d120b97e73972c94eb0f26 
>   3rdparty/libprocess/src/socket.cpp 7f93168e1572f8669f67a4c5e6e5467259b7a407 
>   3rdparty/libprocess/src/tests/socket_tests.cpp PRE-CREATION 
>   3rdparty/libprocess/src/tests/ssl_tests.cpp 55c8c309571b1892b0acc4d766eda9bb98085a6f

>   3rdparty/libprocess/src/tests/test_linkee.cpp 1f6cfafcb73fd41ef350b13e3ac6023d78f16f5a

> 
> Diff: https://reviews.apache.org/r/53460/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Benjamin Hindman
> 
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message