aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2011-07-01 18:26:15 +0000
committerRob Austein <sra@hactrn.net>2011-07-01 18:26:15 +0000
commit0c86a2923e30ba5234c422a4f8053081a574774b (patch)
treec1bfe618b83017d771707bee771085aea56a0534
parent814810931ba41d49bb032cc3da5eae10bebb6017 (diff)
Clean up silly extra loop around subprocess read(), it didn't help anything
svn path=/rcynic-ng/rcynic.c; revision=3917
-rw-r--r--rcynic-ng/rcynic.c55
1 files changed, 24 insertions, 31 deletions
diff --git a/rcynic-ng/rcynic.c b/rcynic-ng/rcynic.c
index 7b8b2339..5cc61a65 100644
--- a/rcynic-ng/rcynic.c
+++ b/rcynic-ng/rcynic.c
@@ -1859,46 +1859,39 @@ static void rsync_mgr(const rcynic_ctx_t *rc)
if (n > 0) {
- int again = 1;
-
- while (again) {
- again = 0;
+ for (i = 0; (ctx = sk_rsync_ctx_t_value(rc->rsync_queue, i)) != NULL; ++i) {
+ if (ctx->fd <= 0 || !FD_ISSET(ctx->fd, &rfds))
+ continue;
- for (i = 0; (ctx = sk_rsync_ctx_t_value(rc->rsync_queue, i)) != NULL; ++i) {
- if (ctx->fd <= 0 || !FD_ISSET(ctx->fd, &rfds))
- continue;
+ assert(ctx->buflen < sizeof(ctx->buffer) - 1);
- assert(ctx->buflen < sizeof(ctx->buffer) - 1);
+ while ((n = read(ctx->fd, ctx->buffer + ctx->buflen, sizeof(ctx->buffer) - 1 - ctx->buflen)) > 0) {
+ ctx->buflen += n;
+ assert(ctx->buflen < sizeof(ctx->buffer));
+ ctx->buffer[ctx->buflen] = '\0';
- while ((n = read(ctx->fd, ctx->buffer + ctx->buflen, sizeof(ctx->buffer) - 1 - ctx->buflen)) > 0) {
- again = 1;
- ctx->buflen += n;
+ while ((s = strchr(ctx->buffer, '\n')) != NULL) {
+ *s++ = '\0';
+ do_one_rsync_log_line(rc, ctx);
+ assert(s > ctx->buffer && s < ctx->buffer + sizeof(ctx->buffer));
+ ctx->buflen -= s - ctx->buffer;
assert(ctx->buflen < sizeof(ctx->buffer));
+ if (ctx->buflen > 0)
+ memmove(ctx->buffer, s, ctx->buflen);
ctx->buffer[ctx->buflen] = '\0';
-
- while ((s = strchr(ctx->buffer, '\n')) != NULL) {
- *s++ = '\0';
- do_one_rsync_log_line(rc, ctx);
- assert(s > ctx->buffer && s < ctx->buffer + sizeof(ctx->buffer));
- ctx->buflen -= s - ctx->buffer;
- assert(ctx->buflen < sizeof(ctx->buffer));
- if (ctx->buflen > 0)
- memmove(ctx->buffer, s, ctx->buflen);
- ctx->buffer[ctx->buflen] = '\0';
- }
-
- if (ctx->buflen == sizeof(ctx->buffer) - 1) {
- ctx->buffer[sizeof(ctx->buffer) - 1] = '\0';
- do_one_rsync_log_line(rc, ctx);
- ctx->buflen = 0;
- }
}
- if (n == 0) {
- (void) close(ctx->fd);
- ctx->fd = -1;
+ if (ctx->buflen == sizeof(ctx->buffer) - 1) {
+ ctx->buffer[sizeof(ctx->buffer) - 1] = '\0';
+ do_one_rsync_log_line(rc, ctx);
+ ctx->buflen = 0;
}
}
+
+ if (n == 0) {
+ (void) close(ctx->fd);
+ ctx->fd = -1;
+ }
}
}