if (io->input_source)
io->mainloop->cancel_io(io->mainloop, io->input_source);
- if (io->output_source && io->output_source != io->input_source)
+ if (io->output_source && (io->output_source != io->input_source))
io->mainloop->cancel_io(io->mainloop, io->output_source);
free(io);
static int do_read(struct ioline *l) {
ssize_t r;
size_t m, len;
- char *p, *e;
+ char *e;
assert(l);
if (!iochannel_is_readable(l->io))
e = memchr(l->rbuf+l->rbuf_index+l->rbuf_valid_length, '\n', r);
l->rbuf_valid_length += r;
- if (!e && l->rbuf_valid_length >= BUFFER_LIMIT)
+ if (!e &&l->rbuf_valid_length >= BUFFER_LIMIT)
e = l->rbuf+BUFFER_LIMIT-1;
+
+ if (e) {
+ char *p;
- *e = 0;
- p = l->rbuf+l->rbuf_index;
- m = strlen(p);
+ *e = 0;
+
+ p = l->rbuf+l->rbuf_index;
+ m = strlen(p);
- if (l->callback)
- l->callback(l, p, l->userdata);
+ if (l->callback)
+ l->callback(l, p, l->userdata);
- l->rbuf_index += m+1;
- l->rbuf_valid_length -= m+1;
+ l->rbuf_index += m+1;
+ l->rbuf_valid_length -= m+1;
- if (l->rbuf_valid_length == 0)
- l->rbuf_index = 0;
+ if (l->rbuf_valid_length == 0)
+ l->rbuf_index = 0;
+ }
return 0;
}
return;
fail:
+ l->dead = 1;
if (l->callback)
l->callback(l, NULL, l->userdata);
- l->dead = 1;
}
return -1;
}
- fprintf(stderr, "Requested %u bytes\n", bytes);
+ /*fprintf(stderr, "Requested %u bytes\n", bytes);*/
s->requested_bytes += bytes;
pstream_send_memblock(s->context->pstream, s->channel, 0, &chunk);
memblock_unref(chunk.memblock);
- fprintf(stderr, "Sent %u bytes\n", length);
+ /*fprintf(stderr, "Sent %u bytes\n", length);*/
if (length < s->requested_bytes)
s->requested_bytes -= length;
tagstruct_putu32(t, l);
pstream_send_tagstruct(s->connection->pstream, t);
- fprintf(stderr, "Requesting %u bytes\n", l);
+/* fprintf(stderr, "Requesting %u bytes\n", l);*/
}
/*** sinkinput callbacks ***/
assert(stream->sink_input);
sink_notify(stream->sink_input->sink);
- fprintf(stderr, "Recieved %u bytes.\n", chunk->length);
+ /*fprintf(stderr, "Recieved %u bytes.\n", chunk->length);*/
return 0;
}