??? wrote: > I ran the following source code in x86(glibc) and MIPS(uClibc). > In the x86, it has no problem. > In the MIPS, however, my program is aborted. > Is this a bug of gethostbyname_r() ? > I don't know why it is aborted. > > In the x86, following are printed. > > gethostname_r() with www.yahoo.com <http://www.yahoo.com/> > host_name : www-real.wa1.b.yahoo.com <http://www-real.wa1.b.yahoo.com> > gethostname_r() with cache.download.bluray.dreamworks.com > <http://cache.download.bluray.dreamworks.com> > host_name : dreamworks.cache.bdlive.hddvd.ddsnsbu.com > <http://dreamworks.cache.bdlive.hddvd.ddsnsbu.com> > gethostname_r() with www.yahoo.com <http://www.yahoo.com/> > host_name : www-real.wa1.b.yahoo.com <http://www-real.wa1.b.yahoo.com> > I'm alive..... > I'm alive..... > I'm alive..... > > In the MIPS, following are printed. > > gethostname_r() with www.yahoo.com <http://www.yahoo.com/> > host_name : www-real.wa1.b.yahoo.com <http://www-real.wa1.b.yahoo.com> > gethostname with cache.download.bluray.dreamworks.com > <http://cache.download.bluray.dreamworks.com> > gethostbyname_r:: Success > host_name : ./a.out > gethostname with www.yahoo.com <http://www.yahoo.com/> > Aborted > # > > ============================================== > #include <errno.h> > #include <stdio.h> > #include <sys/types.h> > #include <sys/socket.h> > #include <netinet/in.h> > #include <netdb.h> > #include <string.h> > #include <stdlib.h> > #include <ctype.h> > #include <unistd.h> > > #define TRUE 1 > #define FALSE 0 > int main(int argc, char **argv) > { > const char* hostname = "cache.download.bluray.dreamworks.com > <http://cache.download.bluray.dreamworks.com>"; > const char* hostname2 = "www.yahoo.com <http://www.yahoo.com/>"; > char buf[512], buf2[512]; > int ret, h_error=0, h_error2 = 0; > struct hostent res, res2, *hp = 0, *hp2 = 0; > printf("gethostname with %s, now.\n", hostname2); > ret = gethostbyname_r(hostname2, &res, buf, sizeof(buf), &hp, > &h_error); > if(0 != ret) > perror("gethostbyname_r:"); > > printf("host_name : %s\n", res.h_name); > > usleep(1000); > printf("gethostname_r() with %s\n", hostname); > ret = gethostbyname_r(hostname, &res2, buf2, sizeof(buf2), &hp2, > &h_error2); > if(0 != ret) > perror("gethostbyname_r:"); > > printf("host_name : %s\n", res2.h_name); > > usleep(1000); > > printf("gethostname_r() with %s\n", hostname2); > ret = gethostbyname_r(hostname2, &res, buf, sizeof(buf), &hp, > &h_error); > if(0 != ret) > perror("gethostbyname_r:"); > > printf("host_name : %s\n", hp->h_name); > > while(TRUE) { > printf("I'm alive.....\n\n"); > usleep(1000000); > } > } > -- > Don't Worry, Be Happy > > Hi, I'd suggest you to do a debug session to figure out where it is causing the abort.
Carmelo P.S. Please, post email in plain text, not hmtl. > ------------------------------------------------------------------------ > > _______________________________________________ > uClibc mailing list > [email protected] > http://lists.busybox.net/mailman/listinfo/uclibc _______________________________________________ uClibc mailing list [email protected] http://lists.busybox.net/mailman/listinfo/uclibc
