This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problem with gethostid


Hi all,

I have some problems with gethostid functions. When I run it on some
nodes of my cluster I get the same return value although hostnames and
IP addresses are different. Here are the logs for 2 nodes (test
program is in the attach, as well as cygcheck output).

C:\Users\gribov.y>\\s-cw-head\pgas\a.exe
hostname = S-CW-NODE52
hostent:
h_name = S-CW-NODE52.XXX
address: 10.2.0.48
address: 192.168.80.1
address: 192.168.169.1
id = 364106303 15b3d23f

C:\Users\gribov.y>\\s-cw-head\pgas\a.exe
hostname = S-CW-NODE53
hostent:
h_name = S-CW-NODE53.XXX
address: 10.2.0.56
address: 192.168.93.1
address: 192.168.244.1
id = 364106303 15b3d23f

Note that ids are equal although IP addresses are clearly different.

Some details:
1) I have replaced my domain name with XXX.
2) I run my program outside of Cygwin environment (i.e. not in bash);
not sure whether it's important

Has anyone seen this before? This may be due to some misconfig of my
cluster but I'm not sure what I should check.

--
Best regards,
Yuri

Attachment: cygcheck.out
Description: Binary data

#include <stdlib.h>
#include <stdio.h>
#include <netdb.h>

int main(int argc, char **argv) {
    char tmp[128];
    struct in_addr  **pptr;
    FILE *hosts;

    if( argc > 1 && (hosts = fopen("/etc/hosts", "rb")) ) {
        printf("/etc/hosts:\n");
        while( !feof(hosts) ) {
            fgets(tmp, sizeof(tmp), hosts);
            printf("Next line: %s\n", tmp);
        }
        fclose(hosts);
    }

    gethostname(tmp, sizeof(tmp));
    printf("hostname = %s\n", tmp);

    struct hostent *e = gethostbyname(tmp);

    printf("hostent:\n");
    printf("h_name = %s\n", e->h_name);

    for(pptr = (struct in_addr **)e->h_addr_list; *pptr; ++pptr) {
        printf("address: %s\n", inet_ntoa(**pptr));
    }

    long id = gethostid();
    printf("id = %u %x\n", (unsigned)gethostid(), (unsigned)gethostid());

    return 0;
}
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]