Quantcast

Review Request: Added SystemInfo::isLocalHost to check if a host name refers to the local host.

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Review Request: Added SystemInfo::isLocalHost to check if a host name refers to the local host.

Alan Conway

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

Review request for qpid, Andrew Stitcher and Steve Huston.


Summary
-------

Need by the new HA work to avoid connections to self.
- needs windows  implementation
- doesn't cover ipv6, neither does other Url handling code at this point


Diffs
-----

  /trunk/qpid/cpp/include/qpid/sys/SystemInfo.h 1333473
  /trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp 1333473
  /trunk/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp 1333473
  /trunk/qpid/cpp/src/tests/CMakeLists.txt 1333473
  /trunk/qpid/cpp/src/tests/Makefile.am 1333473
  /trunk/qpid/cpp/src/tests/SystemInfo.cpp PRE-CREATION

Diff: https://reviews.apache.org/r/4992/diff


Testing
-------

New unit test/SystemInfo.cpp.
make check passes


Thanks,

Alan

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Review Request: Added SystemInfo::isLocalHost to check if a host name refers to the local host.

astitcher

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


I'm concerned that using a simple IP address approach to avoiding connecting to yourself also stops you testing (or deploying) using multiple brokers on the same host.


/trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
<https://reviews.apache.org/r/4992/#comment16607>

    Don't use gethostbyname(), it's obsolete (and has been for over 10 years) it's also not threadsafe. Use getaddrinfo()


- Andrew


On 2012-05-03 15:57:01, Alan Conway wrote:

>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/4992/
> -----------------------------------------------------------
>
> (Updated 2012-05-03 15:57:01)
>
>
> Review request for qpid, Andrew Stitcher and Steve Huston.
>
>
> Summary
> -------
>
> Need by the new HA work to avoid connections to self.
> - needs windows  implementation
> - doesn't cover ipv6, neither does other Url handling code at this point
>
>
> Diffs
> -----
>
>   /trunk/qpid/cpp/include/qpid/sys/SystemInfo.h 1333473
>   /trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp 1333473
>   /trunk/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp 1333473
>   /trunk/qpid/cpp/src/tests/CMakeLists.txt 1333473
>   /trunk/qpid/cpp/src/tests/Makefile.am 1333473
>   /trunk/qpid/cpp/src/tests/SystemInfo.cpp PRE-CREATION
>
> Diff: https://reviews.apache.org/r/4992/diff
>
>
> Testing
> -------
>
> New unit test/SystemInfo.cpp.
> make check passes
>
>
> Thanks,
>
> Alan
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Review Request: Added SystemInfo::isLocalHost to check if a host name refers to the local host.

Alan Conway


> On 2012-05-03 16:17:15, Andrew Stitcher wrote:
> > I'm concerned that using a simple IP address approach to avoiding connecting to yourself also stops you testing (or deploying) using multiple brokers on the same host.

Good point, I'll use host:port - no changed needed in isLocalHost though, I will put the port test higher up.


> On 2012-05-03 16:17:15, Andrew Stitcher wrote:
> > /trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp, line 111
> > <https://reviews.apache.org/r/4992/diff/1/?file=106374#file106374line111>
> >
> >     Don't use gethostbyname(), it's obsolete (and has been for over 10 years) it's also not threadsafe. Use getaddrinfo()

Will do.


- Alan


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


On 2012-05-03 15:57:01, Alan Conway wrote:

>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/4992/
> -----------------------------------------------------------
>
> (Updated 2012-05-03 15:57:01)
>
>
> Review request for qpid, Andrew Stitcher and Steve Huston.
>
>
> Summary
> -------
>
> Need by the new HA work to avoid connections to self.
> - needs windows  implementation
> - doesn't cover ipv6, neither does other Url handling code at this point
>
>
> Diffs
> -----
>
>   /trunk/qpid/cpp/include/qpid/sys/SystemInfo.h 1333473
>   /trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp 1333473
>   /trunk/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp 1333473
>   /trunk/qpid/cpp/src/tests/CMakeLists.txt 1333473
>   /trunk/qpid/cpp/src/tests/Makefile.am 1333473
>   /trunk/qpid/cpp/src/tests/SystemInfo.cpp PRE-CREATION
>
> Diff: https://reviews.apache.org/r/4992/diff
>
>
> Testing
> -------
>
> New unit test/SystemInfo.cpp.
> make check passes
>
>
> Thanks,
>
> Alan
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Review Request: Added SystemInfo::isLocalHost to check if a host name refers to the local host.

Alan Conway
In reply to this post by Alan Conway

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

(Updated 2012-05-03 18:07:53.067617)


Review request for qpid, Andrew Stitcher and Steve Huston.


Changes
-------

Now using modern APIs


Summary
-------

Need by the new HA work to avoid connections to self.
- needs windows  implementation
- doesn't cover ipv6, neither does other Url handling code at this point


Diffs (updated)
-----

  /trunk/qpid/cpp/include/qpid/sys/SystemInfo.h 1333473
  /trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp 1333473
  /trunk/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp 1333473
  /trunk/qpid/cpp/src/tests/CMakeLists.txt 1333473
  /trunk/qpid/cpp/src/tests/Makefile.am 1333473
  /trunk/qpid/cpp/src/tests/SystemInfo.cpp PRE-CREATION

Diff: https://reviews.apache.org/r/4992/diff


Testing
-------

New unit test/SystemInfo.cpp.
make check passes


Thanks,

Alan

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Review Request: Added SystemInfo::isLocalHost to check if a host name refers to the local host.

astitcher

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



/trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
<https://reviews.apache.org/r/4992/#comment16633>

    memory leak - result is never freed with freeaddrinfo



/trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
<https://reviews.apache.org/r/4992/#comment16634>

    Not sure it's a big issue, but the algorithm here is order N^2 in number of addresses



/trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
<https://reviews.apache.org/r/4992/#comment16632>

    Some funny formatting thing going on here


- Andrew


On 2012-05-03 18:07:53, Alan Conway wrote:

>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/4992/
> -----------------------------------------------------------
>
> (Updated 2012-05-03 18:07:53)
>
>
> Review request for qpid, Andrew Stitcher and Steve Huston.
>
>
> Summary
> -------
>
> Need by the new HA work to avoid connections to self.
> - needs windows  implementation
> - doesn't cover ipv6, neither does other Url handling code at this point
>
>
> Diffs
> -----
>
>   /trunk/qpid/cpp/include/qpid/sys/SystemInfo.h 1333473
>   /trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp 1333473
>   /trunk/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp 1333473
>   /trunk/qpid/cpp/src/tests/CMakeLists.txt 1333473
>   /trunk/qpid/cpp/src/tests/Makefile.am 1333473
>   /trunk/qpid/cpp/src/tests/SystemInfo.cpp PRE-CREATION
>
> Diff: https://reviews.apache.org/r/4992/diff
>
>
> Testing
> -------
>
> New unit test/SystemInfo.cpp.
> make check passes
>
>
> Thanks,
>
> Alan
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Review Request: Added SystemInfo::isLocalHost to check if a host name refers to the local host.

Alan Conway
In reply to this post by Alan Conway

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

(Updated 2012-05-07 14:34:06.921280)


Review request for qpid, Andrew Stitcher and Steve Huston.


Changes
-------

Fixes astitcher's review comments.


Summary
-------

Need by the new HA work to avoid connections to self.
- needs windows  implementation
- doesn't cover ipv6, neither does other Url handling code at this point


Diffs (updated)
-----

  /trunk/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp 1335016
  /trunk/qpid/cpp/src/tests/CMakeLists.txt 1335016
  /trunk/qpid/cpp/src/tests/Makefile.am 1335016
  /trunk/qpid/cpp/src/tests/SystemInfo.cpp PRE-CREATION
  /trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp 1335016
  /trunk/qpid/cpp/include/qpid/sys/SystemInfo.h 1335016

Diff: https://reviews.apache.org/r/4992/diff


Testing
-------

New unit test/SystemInfo.cpp.
make check passes


Thanks,

Alan

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Review Request: Added SystemInfo::isLocalHost to check if a host name refers to the local host.

astitcher

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


Picky little comment follows!


/trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
<https://reviews.apache.org/r/4992/#comment16849>

    Why not rename FreeAddrInfo as AddrInfo or perhaps AddrInfoHolder (I don't like naming an object with a verb) and have it also proxy the addrinfo struct as well as do the RAII:
   
    viz
    ...
    AddrInfo result;
    int error = ::getaddrinfo(host.c_str(), NULL, NULL, &result);
    if (error) return false;
    for (struct addrinfo *res = result; res != NULL; res = res->ai_next) {
    ...
   
    and adding an operator addrinfo*&() to the new AddrInfo?
    You probably also need to add
     if(ai) ... to the destructor as it's not documented what freeaddinfo does if the addrinfo struct pointer is zero
    Something like (untested):
   
    struct AddrInfo {
        ::addrinfo* ai;
        AddrInfo() : ai(0) {}
        operator ::addrinfo*&() {return ai;}
        ~AddrInfo() { if (ai) ::freeaddrinfo(ai); }
    };
   
    This would make the code just a touch more comprehensible IMO
   
    [Note also the the new RAII class really can't be copied, but could have move semantics (in C++11)]


- Andrew


On 2012-05-07 14:34:06, Alan Conway wrote:

>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/4992/
> -----------------------------------------------------------
>
> (Updated 2012-05-07 14:34:06)
>
>
> Review request for qpid, Andrew Stitcher and Steve Huston.
>
>
> Summary
> -------
>
> Need by the new HA work to avoid connections to self.
> - needs windows  implementation
> - doesn't cover ipv6, neither does other Url handling code at this point
>
>
> Diffs
> -----
>
>   /trunk/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp 1335016
>   /trunk/qpid/cpp/src/tests/CMakeLists.txt 1335016
>   /trunk/qpid/cpp/src/tests/Makefile.am 1335016
>   /trunk/qpid/cpp/src/tests/SystemInfo.cpp PRE-CREATION
>   /trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp 1335016
>   /trunk/qpid/cpp/include/qpid/sys/SystemInfo.h 1335016
>
> Diff: https://reviews.apache.org/r/4992/diff
>
>
> Testing
> -------
>
> New unit test/SystemInfo.cpp.
> make check passes
>
>
> Thanks,
>
> Alan
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Review Request: Added SystemInfo::isLocalHost to check if a host name refers to the local host.

Alan Conway
In reply to this post by Alan Conway

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

(Updated 2012-05-07 17:00:08.238194)


Review request for qpid, Andrew Stitcher and Steve Huston.


Changes
-------

Updated with astitcher's comments.


Summary
-------

Need by the new HA work to avoid connections to self.
- needs windows  implementation
- doesn't cover ipv6, neither does other Url handling code at this point


Diffs (updated)
-----

  /trunk/qpid/cpp/include/qpid/sys/SystemInfo.h 1335016
  /trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp 1335016
  /trunk/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp 1335016
  /trunk/qpid/cpp/src/tests/CMakeLists.txt 1335016
  /trunk/qpid/cpp/src/tests/Makefile.am 1335016
  /trunk/qpid/cpp/src/tests/SystemInfo.cpp PRE-CREATION

Diff: https://reviews.apache.org/r/4992/diff


Testing
-------

New unit test/SystemInfo.cpp.
make check passes


Thanks,

Alan

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Review Request: Added SystemInfo::isLocalHost to check if a host name refers to the local host.

astitcher

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

Ship it!


- Andrew


On 2012-05-07 17:00:08, Alan Conway wrote:

>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/4992/
> -----------------------------------------------------------
>
> (Updated 2012-05-07 17:00:08)
>
>
> Review request for qpid, Andrew Stitcher and Steve Huston.
>
>
> Summary
> -------
>
> Need by the new HA work to avoid connections to self.
> - needs windows  implementation
> - doesn't cover ipv6, neither does other Url handling code at this point
>
>
> Diffs
> -----
>
>   /trunk/qpid/cpp/include/qpid/sys/SystemInfo.h 1335016
>   /trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp 1335016
>   /trunk/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp 1335016
>   /trunk/qpid/cpp/src/tests/CMakeLists.txt 1335016
>   /trunk/qpid/cpp/src/tests/Makefile.am 1335016
>   /trunk/qpid/cpp/src/tests/SystemInfo.cpp PRE-CREATION
>
> Diff: https://reviews.apache.org/r/4992/diff
>
>
> Testing
> -------
>
> New unit test/SystemInfo.cpp.
> make check passes
>
>
> Thanks,
>
> Alan
>
>

Loading...