aboutsummaryrefslogtreecommitdiff
path: root/nscd/connections.c
diff options
context:
space:
mode:
Diffstat (limited to 'nscd/connections.c')
-rw-r--r--nscd/connections.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/nscd/connections.c b/nscd/connections.c
index 63a01e3bb6..86069b237a 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -181,13 +181,28 @@ static int sock;
unsigned long int client_queued;
+ssize_t
+writeall (int fd, const void *buf, size_t len)
+{
+ size_t n = len;
+ ssize_t ret;
+ do
+ {
+ ret = TEMP_FAILURE_RETRY (write (fd, buf, n));
+ if (ret <= 0)
+ break;
+ buf = (const char *) buf + ret;
+ n -= ret;
+ }
+ while (n > 0);
+ return ret < 0 ? ret : len - n;
+}
+
+
/* Initialize database information structures. */
void
nscd_init (void)
{
- struct sockaddr_un sock_addr;
- size_t cnt;
-
/* Secure mode and unprivileged mode are incompatible */
if (server_user != NULL && secure_in_use)
{
@@ -204,7 +219,7 @@ nscd_init (void)
/* No configuration for this value, assume a default. */
nthreads = 2 * lastdb;
- for (cnt = 0; cnt < lastdb; ++cnt)
+ for (size_t cnt = 0; cnt < lastdb; ++cnt)
if (dbs[cnt].enabled)
{
pthread_rwlock_init (&dbs[cnt].lock, NULL);
@@ -500,6 +515,7 @@ cannot set socket to close on exec: %s; disabling paranoia mode"),
exit (1);
}
/* Bind a name to the socket. */
+ struct sockaddr_un sock_addr;
sock_addr.sun_family = AF_UNIX;
strcpy (sock_addr.sun_path, _PATH_NSCDSOCKET);
if (bind (sock, (struct sockaddr *) &sock_addr, sizeof (sock_addr)) < 0)
@@ -691,7 +707,7 @@ cannot handle old request version %d; current version is %d"),
if (cached != NULL)
{
/* Hurray it's in the cache. */
- if (TEMP_FAILURE_RETRY (write (fd, cached->data, cached->recsize))
+ if (writeall (fd, cached->data, cached->recsize)
!= cached->recsize
&& __builtin_expect (debug_level, 0) > 0)
{