Re: [Fwd: [FYI] Important bug fix commited]

Alexander Malysh <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Organization Centrium GmbH
Message-ID <[email protected]>
Hi,

sorry for delay...

On Sunday 28 September 2003 18:54, Andreas Fink wrote:
[snip]

> > Here is the quote from `man gethostbyname`:
> >        The functions gethostbyname() and gethostbyaddr() may return
> >        pointers to static data, which may be overwritten by later
> > calls.
> >        Copying the struct hostent does not suffice, since it contains
> >        pointers- a deep copy is required.
>
> from man gethostbyname on MacOS X:
>
> BUGS
>       These functions use static data storage; if the data is needed for
> future
>       use, it should be copied before any subsequent calls overwrite it.
>   Only
>       the Internet address format is currently understood.

it's the same as for all gethostbyname functions, these uses static data...

> in my eyes it should be sufficient to make a semaphore lock around the
> function, copy the data out and you're done.

yep, this means, "deep-copy". Just look into gwlib/protected.c, but if a
reentrant function supported, we avoid locking then.

> The struct returned on MacOS X is:
>
>      struct  hostent {
>               char    *h_name;        /* official name of host */
>               char    **h_aliases;    /* alias list */
>               int     h_addrtype;     /* host address type */
>               int     h_length;       /* length of address */
>               char    **h_addr_list;  /* list of addresses from name
> server */
>       };
>
> and the function calls are:
>
> struct hostent *	gethostbyname(const char *name);
> struct hostent *	gethostbyname2(const char *name, int af);
>
> > Commited version trying to use reentrant alternatives for
> > gethostbyname,
> > unfortunately it's not a POSIX functions and every OS have a different
> > call.
> > For now we have 3 types supported:
> > 	1) 6 params for call (Linux version)
> > 	2) 5 params for call (Solaris version)
> > 	3) no reentrant function at all , make a deep copy of hostent
> > pointers.
> >
> > gethostbyname_r with 3 params for call doesn't supported yet (deep copy
> >  used), because I can't test it (implementation should be simple).
> >
> > --
> > Best regards / Mit besten Grüßen aus Düsseldorf
> >
> > Dipl.-Ing.
> > Alexander Malysh
> > ___________________________________________
> >
> > Centrium GmbH
> > Vogelsanger Weg 80
> > 40470 Düsseldorf
> >
> > Fon: +49 (0211) 74 84 51 80
> > Fax: +49 (0211) 277 49 109
> >
> > email: [email protected]
> > web: www.centrium.de
> > msn: [email protected]
> > icq: 98063111
> > ___________________________________________
> >
> > Please avoid sending me Word or PowerPoint attachments.
> > See http://www.fsf.org/philosophy/no-word-attachments.html
>
> Andreas Fink
> Global Networks Switzerland AG
>
> ------------------------------------------------------------------
> Tel: +41-61-6666333  Fax: +41-61-6666334   Mobile: +41-79-2457333
> Global Networks, Inc. Clarastrasse 3, 4058 Basel, Switzerland
> Web: http://www.global-networks.ch/      [email protected]
> ------------------------------------------------------------------

-- 
Best regards / Mit besten Grüßen aus Düsseldorf

Dipl.-Ing.
Alexander Malysh
___________________________________

Centrium GmbH
Vogelsanger Weg 80
40470 Düsseldorf

Fon: +49 (0211) 74 84 51 80
Fax: +49 (0211) 277 49 109

email: a.malysh at centrium.de
web: http://www.centrium.de
msn: olek2002 at hotmail.com
icq: 98063111
___________________________________________

Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.