mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-09 19:00:08 +00:00
Update.
2004-09-24 Ulrich Drepper <drepper@redhat.com> * nis/ypclnt.c (yp_bind_file): Optimize a bit. Minimal cleanups.
This commit is contained in:
parent
3f80a99b8f
commit
3900770ed3
@ -1,3 +1,7 @@
|
|||||||
|
2004-09-24 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* nis/ypclnt.c (yp_bind_file): Optimize a bit. Minimal cleanups.
|
||||||
|
|
||||||
2004-09-23 Andreas Jaeger <aj@suse.de>
|
2004-09-23 Andreas Jaeger <aj@suse.de>
|
||||||
|
|
||||||
* locale/weight.h (findidx): Remove static, it's not supported
|
* locale/weight.h (findidx): Remove static, it's not supported
|
||||||
|
23
nis/ypclnt.c
23
nis/ypclnt.c
@ -74,7 +74,7 @@ yp_bind_client_create (const char *domain, dom_binding *ysd,
|
|||||||
if (ysd->dom_client != NULL)
|
if (ysd->dom_client != NULL)
|
||||||
{
|
{
|
||||||
/* If the program exits, close the socket */
|
/* If the program exits, close the socket */
|
||||||
if (fcntl (ysd->dom_socket, F_SETFD, 1) == -1)
|
if (fcntl (ysd->dom_socket, F_SETFD, FD_CLOEXEC) == -1)
|
||||||
perror ("fcntl: F_SETFD");
|
perror ("fcntl: F_SETFD");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,23 +83,18 @@ yp_bind_client_create (const char *domain, dom_binding *ysd,
|
|||||||
static void
|
static void
|
||||||
yp_bind_file (const char *domain, dom_binding *ysd)
|
yp_bind_file (const char *domain, dom_binding *ysd)
|
||||||
{
|
{
|
||||||
struct ypbind_resp ypbr;
|
char path[sizeof (BINDINGDIR) + strlen (domain) + 3 * sizeof (unsigned) + 3];
|
||||||
char path[sizeof (BINDINGDIR) + strlen (domain) + 10];
|
|
||||||
struct iovec vec[2];
|
|
||||||
unsigned short port;
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
sprintf (path, "%s/%s.%d", BINDINGDIR, domain, YPBINDVERS);
|
snprintf (path, sizeof (path), "%s/%s.%u", BINDINGDIR, domain, YPBINDVERS);
|
||||||
fd = open (path, O_RDONLY);
|
int fd = open (path, O_RDONLY);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
/* We have a binding file and could save a RPC call */
|
/* We have a binding file and could save a RPC call. The file
|
||||||
vec[0].iov_base = &port;
|
contains a port number and the YPBIND_RESP record. The port
|
||||||
vec[0].iov_len = sizeof (port);
|
number (16 bits) can be ignored. */
|
||||||
vec[1].iov_base = &ypbr;
|
struct ypbind_resp ypbr;
|
||||||
vec[1].iov_len = sizeof (ypbr);
|
|
||||||
|
|
||||||
if (readv (fd, vec, 2) == sizeof (port) + sizeof (ypbr))
|
if (pread (fd, &ypbr, sizeof (ypbr), 2) == sizeof (ypbr))
|
||||||
yp_bind_client_create (domain, ysd, &ypbr);
|
yp_bind_client_create (domain, ysd, &ypbr);
|
||||||
|
|
||||||
close (fd);
|
close (fd);
|
||||||
|
Loading…
Reference in New Issue
Block a user