mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 08:11:08 +00:00
Update.
only if debug_level > 0. Add little performance improvements. Use TEMP_FAILURE_RETRY around write calls.
This commit is contained in:
parent
98e75a1c9c
commit
2370003639
@ -1,7 +1,8 @@
|
|||||||
2001-07-16 Ulrich Drepper <drepper@redhat.com>
|
2001-07-16 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* nscd/connections.c: Print messages caused by user application
|
* nscd/connections.c: Print messages caused by user application
|
||||||
only if debug_level > 0.
|
only if debug_level > 0. Add little performance improvements.
|
||||||
|
Use TEMP_FAILURE_RETRY around write calls.
|
||||||
* nscd/grpcache.c: Likewise.
|
* nscd/grpcache.c: Likewise.
|
||||||
* nscd/hstcache.c: Likewise.
|
* nscd/hstcache.c: Likewise.
|
||||||
* nscd/pwdcache.c: Likewise.
|
* nscd/pwdcache.c: Likewise.
|
||||||
|
@ -203,9 +203,10 @@ invalidate_cache (char *key)
|
|||||||
number = pwddb;
|
number = pwddb;
|
||||||
else if (strcmp (key, "group") == 0)
|
else if (strcmp (key, "group") == 0)
|
||||||
number = grpdb;
|
number = grpdb;
|
||||||
else if (strcmp (key, "hosts") == 0)
|
else if (__builtin_expect (strcmp (key, "hosts"), 0) == 0)
|
||||||
number = hstdb;
|
number = hstdb;
|
||||||
else return;
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
if (dbs[number].enabled)
|
if (dbs[number].enabled)
|
||||||
prune_cache (&dbs[number], LONG_MAX);
|
prune_cache (&dbs[number], LONG_MAX);
|
||||||
@ -216,11 +217,11 @@ invalidate_cache (char *key)
|
|||||||
static void
|
static void
|
||||||
handle_request (int fd, request_header *req, void *key, uid_t uid)
|
handle_request (int fd, request_header *req, void *key, uid_t uid)
|
||||||
{
|
{
|
||||||
if (debug_level > 0)
|
if (__builtin_expect (debug_level, 0) > 0)
|
||||||
dbg_log (_("handle_request: request received (Version = %d)"),
|
dbg_log (_("handle_request: request received (Version = %d)"),
|
||||||
req->version);
|
req->version);
|
||||||
|
|
||||||
if (req->version != NSCD_VERSION)
|
if (__builtin_expect (req->version, NSCD_VERSION) != NSCD_VERSION)
|
||||||
{
|
{
|
||||||
if (debug_level > 0)
|
if (debug_level > 0)
|
||||||
dbg_log (_("\
|
dbg_log (_("\
|
||||||
@ -229,12 +230,13 @@ cannot handle old request version %d; current version is %d"),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req->type >= GETPWBYNAME && req->type <= LASTDBREQ)
|
if (__builtin_expect (req->type, GETPWBYNAME) >= GETPWBYNAME
|
||||||
|
&& __builtin_expect (req->type, LASTDBREQ) <= LASTDBREQ)
|
||||||
{
|
{
|
||||||
struct hashentry *cached;
|
struct hashentry *cached;
|
||||||
struct database *db = &dbs[serv2db[req->type]];
|
struct database *db = &dbs[serv2db[req->type]];
|
||||||
|
|
||||||
if (debug_level > 0)
|
if (__builtin_expect (debug_level, 0) > 0)
|
||||||
{
|
{
|
||||||
if (req->type == GETHOSTBYADDR || req->type == GETHOSTBYADDRv6)
|
if (req->type == GETHOSTBYADDR || req->type == GETHOSTBYADDRv6)
|
||||||
{
|
{
|
||||||
@ -256,7 +258,7 @@ cannot handle old request version %d; current version is %d"),
|
|||||||
if (TEMP_FAILURE_RETRY (write (fd, db->disabled_iov->iov_base,
|
if (TEMP_FAILURE_RETRY (write (fd, db->disabled_iov->iov_base,
|
||||||
db->disabled_iov->iov_len))
|
db->disabled_iov->iov_len))
|
||||||
!= db->disabled_iov->iov_len
|
!= db->disabled_iov->iov_len
|
||||||
&& debug_level > 0)
|
&& __builtin_expect (debug_level, 0) > 0)
|
||||||
{
|
{
|
||||||
/* We have problems sending the result. */
|
/* We have problems sending the result. */
|
||||||
char buf[256];
|
char buf[256];
|
||||||
@ -278,7 +280,7 @@ cannot handle old request version %d; current version is %d"),
|
|||||||
/* Hurray it's in the cache. */
|
/* Hurray it's in the cache. */
|
||||||
if (TEMP_FAILURE_RETRY (write (fd, cached->packet, cached->total))
|
if (TEMP_FAILURE_RETRY (write (fd, cached->packet, cached->total))
|
||||||
!= cached->total
|
!= cached->total
|
||||||
&& debug_level > 0)
|
&& __builtin_expect (debug_level, 0) > 0)
|
||||||
{
|
{
|
||||||
/* We have problems sending the result. */
|
/* We have problems sending the result. */
|
||||||
char buf[256];
|
char buf[256];
|
||||||
@ -293,7 +295,7 @@ cannot handle old request version %d; current version is %d"),
|
|||||||
|
|
||||||
pthread_rwlock_unlock (&db->lock);
|
pthread_rwlock_unlock (&db->lock);
|
||||||
}
|
}
|
||||||
else if (debug_level > 0)
|
else if (__builtin_expect (debug_level, 0) > 0)
|
||||||
{
|
{
|
||||||
if (req->type == INVALIDATE)
|
if (req->type == INVALIDATE)
|
||||||
dbg_log ("\t%s (%s)", serv2str[req->type], (char *)key);
|
dbg_log ("\t%s (%s)", serv2str[req->type], (char *)key);
|
||||||
@ -425,7 +427,7 @@ nscd_run (void *p)
|
|||||||
char buf[256];
|
char buf[256];
|
||||||
uid_t uid = 0;
|
uid_t uid = 0;
|
||||||
|
|
||||||
if (fd < 0)
|
if (__builtin_expect (fd, 0) < 0)
|
||||||
{
|
{
|
||||||
dbg_log (_("while accepting connection: %s"),
|
dbg_log (_("while accepting connection: %s"),
|
||||||
strerror_r (errno, buf, sizeof (buf)));
|
strerror_r (errno, buf, sizeof (buf)));
|
||||||
@ -433,8 +435,9 @@ nscd_run (void *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now read the request. */
|
/* Now read the request. */
|
||||||
if (TEMP_FAILURE_RETRY (read (fd, &req, sizeof (req)))
|
if (__builtin_expect (TEMP_FAILURE_RETRY (read (fd, &req,
|
||||||
!= sizeof (req))
|
sizeof (req)))
|
||||||
|
!= sizeof (req), 0))
|
||||||
{
|
{
|
||||||
if (debug_level > 0)
|
if (debug_level > 0)
|
||||||
dbg_log (_("short read while reading request: %s"),
|
dbg_log (_("short read while reading request: %s"),
|
||||||
@ -469,7 +472,8 @@ nscd_run (void *p)
|
|||||||
/* It should not be possible to crash the nscd with a silly
|
/* It should not be possible to crash the nscd with a silly
|
||||||
request (i.e., a terribly large key). We limit the size
|
request (i.e., a terribly large key). We limit the size
|
||||||
to 1kb. */
|
to 1kb. */
|
||||||
if (req.key_len < 0 || req.key_len > 1024)
|
if (__builtin_expect (req.key_len, 1) < 0
|
||||||
|
|| __builtin_expect (req.key_len, 1) > 1024)
|
||||||
{
|
{
|
||||||
if (debug_level > 0)
|
if (debug_level > 0)
|
||||||
dbg_log (_("key length in request too long: %d"), req.key_len);
|
dbg_log (_("key length in request too long: %d"), req.key_len);
|
||||||
@ -481,8 +485,9 @@ nscd_run (void *p)
|
|||||||
/* Get the key. */
|
/* Get the key. */
|
||||||
char keybuf[req.key_len];
|
char keybuf[req.key_len];
|
||||||
|
|
||||||
if (TEMP_FAILURE_RETRY (read (fd, keybuf, req.key_len))
|
if (__builtin_expect (TEMP_FAILURE_RETRY (read (fd, keybuf,
|
||||||
!= req.key_len)
|
req.key_len))
|
||||||
|
!= req.key_len, 0))
|
||||||
{
|
{
|
||||||
if (debug_level > 0)
|
if (debug_level > 0)
|
||||||
dbg_log (_("short read while reading request key: %s"),
|
dbg_log (_("short read while reading request key: %s"),
|
||||||
|
@ -170,7 +170,7 @@ cache_addgr (struct database *db, int fd, request_header *req, void *key,
|
|||||||
memcpy (cp, buf, n);
|
memcpy (cp, buf, n);
|
||||||
|
|
||||||
/* Write the result. */
|
/* Write the result. */
|
||||||
written = write (fd, &data->resp, total);
|
written = TEMP_FAILURE_RETRY (write (fd, &data->resp, total));
|
||||||
|
|
||||||
/* Compute the timeout time. */
|
/* Compute the timeout time. */
|
||||||
t += db->postimeout;
|
t += db->postimeout;
|
||||||
@ -187,7 +187,7 @@ cache_addgr (struct database *db, int fd, request_header *req, void *key,
|
|||||||
pthread_rwlock_unlock (&db->lock);
|
pthread_rwlock_unlock (&db->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (written != total && debug_level > 0)
|
if (__builtin_expect (written != total, 0) && debug_level > 0)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
dbg_log (_("short write in %s: %s"), __FUNCTION__,
|
dbg_log (_("short write in %s: %s"), __FUNCTION__,
|
||||||
|
@ -200,7 +200,7 @@ cache_addhst (struct database *db, int fd, request_header *req, void *key,
|
|||||||
/* We write the dataset before inserting it to the database
|
/* We write the dataset before inserting it to the database
|
||||||
since while inserting this thread might block and so would
|
since while inserting this thread might block and so would
|
||||||
unnecessarily let the receiver wait. */
|
unnecessarily let the receiver wait. */
|
||||||
written = write (fd, data, total);
|
written = TEMP_FAILURE_RETRY (write (fd, data, total));
|
||||||
|
|
||||||
addr_list_type = (hst->h_length == NS_INADDRSZ
|
addr_list_type = (hst->h_length == NS_INADDRSZ
|
||||||
? GETHOSTBYADDR : GETHOSTBYADDRv6);
|
? GETHOSTBYADDR : GETHOSTBYADDRv6);
|
||||||
@ -272,7 +272,7 @@ cache_addhst (struct database *db, int fd, request_header *req, void *key,
|
|||||||
pthread_rwlock_unlock (&db->lock);
|
pthread_rwlock_unlock (&db->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (written != total && debug_level > 0)
|
if (__builtin_expect (written != total, 0) && debug_level > 0)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
dbg_log (_("short write in %s: %s"), __FUNCTION__,
|
dbg_log (_("short write in %s: %s"), __FUNCTION__,
|
||||||
|
@ -166,7 +166,7 @@ cache_addpw (struct database *db, int fd, request_header *req, void *key,
|
|||||||
/* We write the dataset before inserting it to the database
|
/* We write the dataset before inserting it to the database
|
||||||
since while inserting this thread might block and so would
|
since while inserting this thread might block and so would
|
||||||
unnecessarily let the receiver wait. */
|
unnecessarily let the receiver wait. */
|
||||||
written = write (fd, &data->resp, total);
|
written = TEMP_FAILURE_RETRY (write (fd, &data->resp, total));
|
||||||
|
|
||||||
/* Compute the timeout time. */
|
/* Compute the timeout time. */
|
||||||
t += db->postimeout;
|
t += db->postimeout;
|
||||||
@ -183,7 +183,7 @@ cache_addpw (struct database *db, int fd, request_header *req, void *key,
|
|||||||
pthread_rwlock_unlock (&db->lock);
|
pthread_rwlock_unlock (&db->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (written != total && debug_level > 0)
|
if (__builtin_expect (written != total, 0) && debug_level > 0)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
dbg_log (_("short write in %s: %s"), __FUNCTION__,
|
dbg_log (_("short write in %s: %s"), __FUNCTION__,
|
||||||
|
Loading…
Reference in New Issue
Block a user