diff options
Diffstat (limited to 'nscd')
-rw-r--r-- | nscd/Makefile | 9 | ||||
-rw-r--r-- | nscd/connections.c | 28 | ||||
-rw-r--r-- | nscd/nscd.c | 6 | ||||
-rw-r--r-- | nscd/nscd_helper.c | 37 |
4 files changed, 44 insertions, 36 deletions
diff --git a/nscd/Makefile b/nscd/Makefile index e91c289a4f..0b35964e7b 100644 --- a/nscd/Makefile +++ b/nscd/Makefile @@ -1,4 +1,5 @@ -# Copyright (C) 1998,2000,2002,2003,2004,2005 Free Software Foundation, Inc. +# Copyright (C) 1998,2000,2002,2003,2004,2005,2006 +# Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -58,9 +59,6 @@ endif nscd-modules += selinux selinux-LIBS := -lselinux $(libaudit) -endif - -LDLIBS-nscd = $(selinux-LIBS) # The configure.in check for libselinux and its headers did not use # $SYSINCLUDES. The directory specified by --with-headers usually @@ -69,6 +67,9 @@ LDLIBS-nscd = $(selinux-LIBS) # system headers will be ok for this file. $(objpfx)nscd_stat.o: sysincludes = # nothing $(objpfx)selinux.o: sysincludes = # nothing +endif + +LDLIBS-nscd = $(selinux-LIBS) distribute := nscd.h nscd-client.h dbg_log.h \ $(addsuffix .c, $(filter-out xmalloc,$(all-nscd-modules))) \ diff --git a/nscd/connections.c b/nscd/connections.c index 1e3cd7557f..0426e6346f 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -1556,18 +1556,24 @@ main_loop_poll (void) /* We have a new incoming connection. Accept the connection. */ int fd = TEMP_FAILURE_RETRY (accept (sock, NULL, NULL)); - /* use the descriptor if we have not reached the limit. */ - if (fd >= 0 && firstfree < nconns) + /* Use the descriptor if we have not reached the limit. */ + if (fd >= 0) { - conns[firstfree].fd = fd; - conns[firstfree].events = POLLRDNORM; - starttime[firstfree] = now; - if (firstfree >= nused) - nused = firstfree + 1; - - do - ++firstfree; - while (firstfree < nused && conns[firstfree].fd != -1); + if (firstfree < nconns) + { + conns[firstfree].fd = fd; + conns[firstfree].events = POLLRDNORM; + starttime[firstfree] = now; + if (firstfree >= nused) + nused = firstfree + 1; + + do + ++firstfree; + while (firstfree < nused && conns[firstfree].fd != -1); + } + else + /* We cannot use the connection so close it. */ + close (fd); } --n; diff --git a/nscd/nscd.c b/nscd/nscd.c index 2941cbdc15..917163af78 100644 --- a/nscd/nscd.c +++ b/nscd/nscd.c @@ -491,10 +491,10 @@ write_pid (const char *file) return -1; fprintf (fp, "%d\n", getpid ()); - if (fflush (fp) || ferror (fp)) - return -1; + + int result = fflush (fp) || ferror (fp) ? -1 : 0; fclose (fp); - return 0; + return result; } diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index 8025168a5e..fd749446be 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -176,35 +176,40 @@ get_mapping (request_type type, const char *key, struct mapped_database *result = NO_MAPPING; #ifdef SCM_RIGHTS const size_t keylen = strlen (key) + 1; - char resdata[keylen]; int saved_errno = errno; int mapfd = -1; /* Send the request. */ - struct iovec iov[2]; - request_header req; + struct + { + request_header req; + char key[keylen]; + } reqdata; int sock = open_socket (); if (sock < 0) goto out; - req.version = NSCD_VERSION; - req.type = type; - req.key_len = keylen; - - iov[0].iov_base = &req; - iov[0].iov_len = sizeof (req); - iov[1].iov_base = (void *) key; - iov[1].iov_len = keylen; + reqdata.req.version = NSCD_VERSION; + reqdata.req.type = type; + reqdata.req.key_len = keylen; + memcpy (reqdata.key, key, keylen); - if (__builtin_expect (TEMP_FAILURE_RETRY (__writev (sock, iov, 2)) - != iov[0].iov_len + iov[1].iov_len, 0)) +# ifndef MSG_NOSIGNAL +# define MSG_NOSIGNAL 0 +# endif + if (__builtin_expect (TEMP_FAILURE_RETRY (__send (sock, &reqdata, + sizeof (reqdata), + MSG_NOSIGNAL)) + != sizeof (reqdata), 0)) /* We cannot even write the request. */ goto out_close2; /* Room for the data sent along with the file descriptor. We expect the key name back. */ +# define resdata reqdata.key + struct iovec iov[1]; iov[0].iov_base = resdata; iov[0].iov_len = keylen; @@ -231,11 +236,7 @@ get_mapping (request_type type, const char *key, if (wait_on_socket (sock) <= 0) goto out_close2; -# ifndef MSG_NOSIGNAL -# define MSG_NOSIGNAL 0 -# endif - if (__builtin_expect (TEMP_FAILURE_RETRY (__recvmsg (sock, &msg, - MSG_NOSIGNAL)) + if (__builtin_expect (TEMP_FAILURE_RETRY (__recvmsg (sock, &msg, 0)) != keylen, 0)) goto out_close2; |