mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-18 14:40:06 +00:00
* nscd/nscd_getgr_r.c (nscd_getgr_r): Optimize a bit: use simpler
read mechanism when there are no group members and avoid no-op read syscall in this case.
This commit is contained in:
parent
f7140274a4
commit
43d3e6bd92
@ -1,5 +1,9 @@
|
|||||||
2007-10-13 Ulrich Drepper <drepper@redhat.com>
|
2007-10-13 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* nscd/nscd_getgr_r.c (nscd_getgr_r): Optimize a bit: use simpler
|
||||||
|
read mechanism when there are no group members and avoid no-op
|
||||||
|
read syscall in this case.
|
||||||
|
|
||||||
[BZ #3242]
|
[BZ #3242]
|
||||||
* nscd/nscd_helper.c (wait_on_socket): Take timeout as parameter.
|
* nscd/nscd_helper.c (wait_on_socket): Take timeout as parameter.
|
||||||
(__readall): If reading failed due to EAGAIN error wait a bit
|
(__readall): If reading failed due to EAGAIN error wait a bit
|
||||||
|
@ -189,6 +189,16 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
|
|||||||
|
|
||||||
/* Read the length information, group name, and password. */
|
/* Read the length information, group name, and password. */
|
||||||
if (gr_name == NULL)
|
if (gr_name == NULL)
|
||||||
|
{
|
||||||
|
/* Handle a simple, usual case: no group members. */
|
||||||
|
if (__builtin_expect (gr_resp.gr_mem_cnt == 0, 1))
|
||||||
|
{
|
||||||
|
size_t n = gr_resp.gr_name_len + gr_resp.gr_passwd_len;
|
||||||
|
if (__builtin_expect (__readall (sock, resultbuf->gr_name, n)
|
||||||
|
!= (ssize_t) n, 0))
|
||||||
|
goto out_close;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* Allocate array to store lengths. */
|
/* Allocate array to store lengths. */
|
||||||
if (lensize == 0)
|
if (lensize == 0)
|
||||||
@ -211,6 +221,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
|
|||||||
if (__builtin_expect (n != total_len, 0))
|
if (__builtin_expect (n != total_len, 0))
|
||||||
goto out_close;
|
goto out_close;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
/* We already have the data. Just copy the group name and
|
/* We already have the data. Just copy the group name and
|
||||||
password. */
|
password. */
|
||||||
@ -251,6 +262,10 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
||||||
|
/* If there are no group members TOTAL_LEN is zero. */
|
||||||
|
if (total_len > 0)
|
||||||
|
{
|
||||||
if (gr_name == NULL)
|
if (gr_name == NULL)
|
||||||
{
|
{
|
||||||
size_t n = __readall (sock, resultbuf->gr_mem[0], total_len);
|
size_t n = __readall (sock, resultbuf->gr_mem[0], total_len);
|
||||||
@ -284,6 +299,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
|
|||||||
*result = resultbuf;
|
*result = resultbuf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* The `errno' to some value != ERANGE. */
|
/* The `errno' to some value != ERANGE. */
|
||||||
|
Loading…
Reference in New Issue
Block a user