aboutsummaryrefslogtreecommitdiff
path: root/nscd
diff options
context:
space:
mode:
Diffstat (limited to 'nscd')
-rw-r--r--nscd/connections.c22
-rw-r--r--nscd/nscd_getgr_r.c23
2 files changed, 28 insertions, 17 deletions
diff --git a/nscd/connections.c b/nscd/connections.c
index 582a6cf8f0..4cf397d201 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -427,8 +427,9 @@ gr_send_answer (int conn, struct group *grp)
struct iovec *vec;
size_t *len;
gr_response_header resp;
- size_t total_len;
+ size_t total_len, sum;
int nblocks;
+ size_t maxiov;
resp.version = NSCD_VERSION;
if (grp != NULL)
@@ -501,16 +502,21 @@ gr_send_answer (int conn, struct group *grp)
}
}
+#ifdef UIO_MAXIOV
+ maxiov = UIO_MAXIOV;
+#else
+ maxiov = sysconf (_SC_UIO_MAXIOV);
+#endif
+
/* Send all the data. */
- while (nblocks > UIO_MAXIOV)
+ sum = 0;
+ while (nblocks > maxiov)
{
- if (writev (sock[conn], vec, UIO_MAXIOV) != total_len)
- dbg_log (_("write incomplete on send group answer: %s"),
- strerror (errno));
- vec += UIO_MAXIOV;
- nblocks -= UIO_MAXIOV;
+ sum += writev (sock[conn], vec, maxiov);
+ vec += maxiov;
+ nblocks -= maxiov;
}
- if (writev (sock[conn], vec, nblocks) != total_len)
+ if (sum + writev (sock[conn], vec, nblocks) != total_len)
dbg_log (_("write incomplete on send group answer: %s"),
strerror (errno));
}
diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c
index 85ebb0dc60..ec4f5a1297 100644
--- a/nscd/nscd_getgr_r.c
+++ b/nscd/nscd_getgr_r.c
@@ -99,6 +99,8 @@ __nscd_getgr_r (const char *key, request_type type, struct group *resultbuf,
request_header req;
gr_response_header gr_resp;
ssize_t nbytes;
+ size_t maxiov;
+ size_t sum;
if (sock == -1)
{
@@ -232,18 +234,21 @@ __nscd_getgr_r (const char *key, request_type type, struct group *resultbuf,
*p++ = '\0';
}
- while (i > UIO_MAXIOV)
+#ifdef UIO_MAXIOV
+ maxiov = UIO_MAXIOV;
+#else
+ maxiov = sysconf (_SC_UIO_MAXIOV);
+#endif
+
+ sum = 0;
+ while (i > maxiov)
{
- if (__readv (sock, vec, UIO_MAXIOV) != total_len)
- {
- __close (sock);
- return -1;
- }
- vec += UIO_MAXIOV;
- i -= UIO_MAXIOV;
+ sum += __readv (sock, vec, maxiov);
+ vec += maxiov;
+ i -= maxiov;
}
- if (__readv (sock, vec, i) != total_len)
+ if (sum + __readv (sock, vec, i) != total_len)
{
__close (sock);
return -1;