* net.cc (cygwin_inet_ntoa): Rearrange previous patch to use
thread local buffer space when compiled thread safe. (cygwin_getprotobyname): Ditto. (cygwin_getprotobynumber): Ditto. (cygwin_getservbyname): Ditto. (cygwin_getservbyport): Ditto. (cygwin_gethostbyname): Ditto. (cygwin_gethostbyaddr): Ditto. Move near to cygwin_gethostbyname. * thread.h (struct _winsup_t): Add pointers for above used buffer space. * passwd.cc (getpwduid): Remove initializing passwd. (setpwent): Ditto. (endpwent): Ditto. (setpassent): Ditto.
This commit is contained in:
parent
0a047e8f32
commit
cb19ccf4b5
|
@ -1,3 +1,19 @@
|
||||||
|
Wed Aug 22 23:41:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* net.cc (cygwin_inet_ntoa): Rearrange previous patch to use
|
||||||
|
thread local buffer space when compiled thread safe.
|
||||||
|
(cygwin_getprotobyname): Ditto.
|
||||||
|
(cygwin_getprotobynumber): Ditto.
|
||||||
|
(cygwin_getservbyname): Ditto.
|
||||||
|
(cygwin_getservbyport): Ditto.
|
||||||
|
(cygwin_gethostbyname): Ditto.
|
||||||
|
(cygwin_gethostbyaddr): Ditto. Move near to cygwin_gethostbyname.
|
||||||
|
* thread.h (struct _winsup_t): Add pointers for above used buffer space.
|
||||||
|
* passwd.cc (getpwduid): Remove initializing passwd.
|
||||||
|
(setpwent): Ditto.
|
||||||
|
(endpwent): Ditto.
|
||||||
|
(setpassent): Ditto.
|
||||||
|
|
||||||
Wed Aug 22 13:41:09 2001 Christopher Faylor <cgf@cygnus.com>
|
Wed Aug 22 13:41:09 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* smallprint.c (console_printf): New function.
|
* smallprint.c (console_printf): New function.
|
||||||
|
|
|
@ -182,17 +182,21 @@ dump_protoent (struct protoent *p)
|
||||||
extern "C" char *
|
extern "C" char *
|
||||||
cygwin_inet_ntoa (struct in_addr in)
|
cygwin_inet_ntoa (struct in_addr in)
|
||||||
{
|
{
|
||||||
static char *buf = NULL;
|
#ifdef _MT_SAFE
|
||||||
|
#define ntoa_buf _reent_winsup ()->_ntoa_buf
|
||||||
|
#else
|
||||||
|
static char *ntoa_buf = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
char *res = inet_ntoa (in);
|
char *res = inet_ntoa (in);
|
||||||
if (buf)
|
if (ntoa_buf)
|
||||||
{
|
{
|
||||||
free (buf);
|
free (ntoa_buf);
|
||||||
buf = NULL;
|
ntoa_buf = NULL;
|
||||||
}
|
}
|
||||||
if (res)
|
if (res)
|
||||||
buf = strdup (res);
|
ntoa_buf = strdup (res);
|
||||||
return buf;
|
return ntoa_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exported as inet_addr: BSD 4.3 */
|
/* exported as inet_addr: BSD 4.3 */
|
||||||
|
@ -446,32 +450,36 @@ out:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MT_SAFE
|
||||||
|
#define protoent_buf _reent_winsup ()->_protoent_buf
|
||||||
|
#else
|
||||||
|
static struct protoent *protoent_buf = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* exported as getprotobyname: standards? */
|
/* exported as getprotobyname: standards? */
|
||||||
extern "C" struct protoent *
|
extern "C" struct protoent *
|
||||||
cygwin_getprotobyname (const char *p)
|
cygwin_getprotobyname (const char *p)
|
||||||
{
|
{
|
||||||
static struct protoent *res = NULL;
|
free_protoent_ptr (protoent_buf);
|
||||||
free_protoent_ptr (res);
|
protoent_buf = dup_protoent_ptr (getprotobyname (p));
|
||||||
res = dup_protoent_ptr (getprotobyname (p));
|
if (!protoent_buf)
|
||||||
if (!res)
|
|
||||||
set_winsock_errno ();
|
set_winsock_errno ();
|
||||||
|
|
||||||
dump_protoent (res);
|
dump_protoent (protoent_buf);
|
||||||
return res;
|
return protoent_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exported as getprotobynumber: standards? */
|
/* exported as getprotobynumber: standards? */
|
||||||
extern "C" struct protoent *
|
extern "C" struct protoent *
|
||||||
cygwin_getprotobynumber (int number)
|
cygwin_getprotobynumber (int number)
|
||||||
{
|
{
|
||||||
static struct protoent *res = NULL;
|
free_protoent_ptr (protoent_buf);
|
||||||
free_protoent_ptr (res);
|
protoent_buf = dup_protoent_ptr (getprotobynumber (number));
|
||||||
res = dup_protoent_ptr (getprotobynumber (number));
|
if (!protoent_buf)
|
||||||
if (!res)
|
|
||||||
set_winsock_errno ();
|
set_winsock_errno ();
|
||||||
|
|
||||||
dump_protoent (res);
|
dump_protoent (protoent_buf);
|
||||||
return res;
|
return protoent_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_socket *
|
fhandler_socket *
|
||||||
|
@ -927,32 +935,36 @@ out:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MT_SAFE
|
||||||
|
#define servent_buf _reent_winsup ()->_servent_buf
|
||||||
|
#else
|
||||||
|
static struct servent *servent_buf = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* exported as getservbyname: standards? */
|
/* exported as getservbyname: standards? */
|
||||||
extern "C" struct servent *
|
extern "C" struct servent *
|
||||||
cygwin_getservbyname (const char *name, const char *proto)
|
cygwin_getservbyname (const char *name, const char *proto)
|
||||||
{
|
{
|
||||||
static struct servent *p = NULL;
|
free_servent_ptr (servent_buf);
|
||||||
free_servent_ptr (p);
|
servent_buf = dup_servent_ptr (getservbyname (name, proto));
|
||||||
p = dup_servent_ptr (getservbyname (name, proto));
|
if (!servent_buf)
|
||||||
if (!p)
|
|
||||||
set_winsock_errno ();
|
set_winsock_errno ();
|
||||||
|
|
||||||
syscall_printf ("%x = getservbyname (%s, %s)", p, name, proto);
|
syscall_printf ("%x = getservbyname (%s, %s)", servent_buf, name, proto);
|
||||||
return p;
|
return servent_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exported as getservbyport: standards? */
|
/* exported as getservbyport: standards? */
|
||||||
extern "C" struct servent *
|
extern "C" struct servent *
|
||||||
cygwin_getservbyport (int port, const char *proto)
|
cygwin_getservbyport (int port, const char *proto)
|
||||||
{
|
{
|
||||||
static struct servent *p = NULL;
|
free_servent_ptr (servent_buf);
|
||||||
free_servent_ptr (p);
|
servent_buf = dup_servent_ptr (getservbyport (port, proto));
|
||||||
p = dup_servent_ptr (getservbyport (port, proto));
|
if (!servent_buf)
|
||||||
if (!p)
|
|
||||||
set_winsock_errno ();
|
set_winsock_errno ();
|
||||||
|
|
||||||
syscall_printf ("%x = getservbyport (%d, %s)", p, port, proto);
|
syscall_printf ("%x = getservbyport (%d, %s)", servent_buf, port, proto);
|
||||||
return p;
|
return servent_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
|
@ -1021,6 +1033,12 @@ out:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MT_SAFE
|
||||||
|
#define hostent_buf _reent_winsup ()->_hostent_buf
|
||||||
|
#else
|
||||||
|
static struct hostent *hostent_buf = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* exported as gethostbyname: standards? */
|
/* exported as gethostbyname: standards? */
|
||||||
extern "C" struct hostent *
|
extern "C" struct hostent *
|
||||||
cygwin_gethostbyname (const char *name)
|
cygwin_gethostbyname (const char *name)
|
||||||
|
@ -1048,20 +1066,38 @@ cygwin_gethostbyname (const char *name)
|
||||||
return &tmp;
|
return &tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct hostent *ptr = NULL;
|
free_hostent_ptr (hostent_buf);
|
||||||
free_hostent_ptr (ptr);
|
hostent_buf = dup_hostent_ptr (gethostbyname (name));
|
||||||
ptr = dup_hostent_ptr (gethostbyname (name));
|
if (!hostent_buf)
|
||||||
if (!ptr)
|
|
||||||
{
|
{
|
||||||
set_winsock_errno ();
|
set_winsock_errno ();
|
||||||
set_host_errno ();
|
set_host_errno ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug_printf ("h_name %s", ptr->h_name);
|
debug_printf ("h_name %s", hostent_buf->h_name);
|
||||||
h_errno = 0;
|
h_errno = 0;
|
||||||
}
|
}
|
||||||
return ptr;
|
return hostent_buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* exported as gethostbyaddr: standards? */
|
||||||
|
extern "C" struct hostent *
|
||||||
|
cygwin_gethostbyaddr (const char *addr, int len, int type)
|
||||||
|
{
|
||||||
|
free_hostent_ptr (hostent_buf);
|
||||||
|
hostent_buf = dup_hostent_ptr (gethostbyaddr (addr, len, type));
|
||||||
|
if (!hostent_buf)
|
||||||
|
{
|
||||||
|
set_winsock_errno ();
|
||||||
|
set_host_errno ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debug_printf ("h_name %s", hostent_buf->h_name);
|
||||||
|
h_errno = 0;
|
||||||
|
}
|
||||||
|
return hostent_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exported as accept: standards? */
|
/* exported as accept: standards? */
|
||||||
|
@ -1260,26 +1296,6 @@ cygwin_getsockname (int fd, struct sockaddr *addr, int *namelen)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exported as gethostbyaddr: standards? */
|
|
||||||
extern "C" struct hostent *
|
|
||||||
cygwin_gethostbyaddr (const char *addr, int len, int type)
|
|
||||||
{
|
|
||||||
static struct hostent *ptr = NULL;
|
|
||||||
free_hostent_ptr (ptr);
|
|
||||||
ptr = dup_hostent_ptr (gethostbyaddr (addr, len, type));
|
|
||||||
if (!ptr)
|
|
||||||
{
|
|
||||||
set_winsock_errno ();
|
|
||||||
set_host_errno ();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
debug_printf ("h_name %s", ptr->h_name);
|
|
||||||
h_errno = 0;
|
|
||||||
}
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* exported as listen: standards? */
|
/* exported as listen: standards? */
|
||||||
extern "C" int
|
extern "C" int
|
||||||
cygwin_listen (int fd, int backlog)
|
cygwin_listen (int fd, int backlog)
|
||||||
|
|
|
@ -376,36 +376,24 @@ getpwent (void)
|
||||||
extern "C" struct passwd *
|
extern "C" struct passwd *
|
||||||
getpwduid (uid_t)
|
getpwduid (uid_t)
|
||||||
{
|
{
|
||||||
if (passwd_state <= initializing)
|
|
||||||
read_etc_passwd ();
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
setpwent (void)
|
setpwent (void)
|
||||||
{
|
{
|
||||||
if (passwd_state <= initializing)
|
|
||||||
read_etc_passwd ();
|
|
||||||
|
|
||||||
pw_pos = 0;
|
pw_pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
endpwent (void)
|
endpwent (void)
|
||||||
{
|
{
|
||||||
if (passwd_state <= initializing)
|
|
||||||
read_etc_passwd ();
|
|
||||||
|
|
||||||
pw_pos = 0;
|
pw_pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
setpassent ()
|
setpassent ()
|
||||||
{
|
{
|
||||||
if (passwd_state <= initializing)
|
|
||||||
read_etc_passwd ();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,12 @@ struct _winsup_t
|
||||||
|
|
||||||
/* uinfo.cc */
|
/* uinfo.cc */
|
||||||
char _username[UNLEN + 1];
|
char _username[UNLEN + 1];
|
||||||
|
|
||||||
|
/* net.cc */
|
||||||
|
char *_ntoa_buf;
|
||||||
|
struct protoent *_protoent_buf;
|
||||||
|
struct servent *_servent_buf;
|
||||||
|
struct hostent *_hostent_buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue