#357 Player-2-2: HAVE_GETADDRINFO patch

closed
G Biggs
None
5
2008-10-07
2008-10-03
No

This is a proposal, this patch does not help with anything.

This patch adds #if HAVE_GETADDRINFO in every place where gethostbyname() is used, the way it was done in addr_util.c
Also this patch cleans the mess with AF_INET/PF_INET (afaik there's no guarantee both these constans are defined to be the same value on every OS in the world, so they should be used as mauals says)

Note that the way Player establishes TCP connections in many places eliminates use of IPv6. Currently it does socket() call then getaddrinfo()/gethostbyname() then connect(), while it should do something like this:
int sock = -1;
struct addrinfo * res, * res0'
snprintf(_port, sizeof _port, "%d", port);
if (!(getaddrinfo(host, _port, NULL, &res0)))
{
for (res = res0; res; res = (res->ai_next))
{
sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (sock < 0)
{
continue;
}
if (connect(sock, res->ai_addr, res->ai_addrlen) < 0)
{
close(sock);
sock = -1;
continue;
}
break;
}
}
if (res0) freeaddrinfo(res0);
if (sock < 0)
{
PLAYER_ERROR("Cannot connect remote host");
return FAIL;
}

Discussion

  • Paul Osmialowski

    • assigned_to: nobody --> gbiggs
     
  • Paul Osmialowski

    there is an error in this as it only works on my desktop PC (which is a coincidence I guess) and nowhere else. I'll place better version here today.

     
  • Paul Osmialowski

    File Added: HAVE_GETADDRINFO-20081004.patch

     
  • G Biggs

    G Biggs - 2008-10-06

    After applying this patch, any attempt to connect to a player server results in a broken pipe error on the client. I have not had time to investigate why yet (the connect call succeeds, the pipe is broken when it tries to send data through for the first time). Please have a look at your code and check it's correct.

     
  • Paul Osmialowski

    I've tested this on FC6, F8 and QNX and it worked for me. HAVE_GETADDRINFO changes were done accordingly to addr_util.c code. AF_INET/PF_INET changes were done accordingly to Linux manual. The problem with the patch is that it touches two problems (DNS operation and socket family). When you say your client is able to connect, I assume DNS operations are working well, the broken pipe problem may be caused by wrong socket family (or something else). That leads to my questions:
    1. What operating system is on either side? (Player client and server), as I tested it on Linux 2.6 and QNX 6.2 only
    2. What client did you use?
    3. Was this client compiled against the latest version of client library? (as my patch touches client.c file)
    I have some MacOSX machine with G4 CPU and fink installed on it, I'll try to compile Player with this patch on it today, but since this machine wasn't in use for long time I don't expect it will start from the first run. Also I'll present Player 2.2 for robotics students today and the classroom is equipped with machines running Debian Sarge, so they'll also check how it behaves on non-rpm distro.

     
  • Paul Osmialowski

    I did lots of tests on my students computers (different linuxes and one PowerBook G4 with macosx tiger and darwin ports) and none of them have problems with connecting clients with servers running on the same and remote boxes. I just can't repeat this broken pipe error. I need some more hints for my investigation.

     
  • G Biggs

    G Biggs - 2008-10-07

    Tracked the problem down to a missed chunk when the patch was applied.

     
  • G Biggs

    G Biggs - 2008-10-07
    • status: open --> closed
     
  • G Biggs

    G Biggs - 2008-10-07

    The changes have been made in SVN trunk.
    Thank you for your contribution.

     
  • G Biggs

    G Biggs - 2008-10-07

    I have applied most of this patch. I haven't applied it to the files in the nomad driver, as these appear to be supplied by the robot manufacturer.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks