X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fjournal-remote-parse.c;h=239ff381975703c920b0a9ad6d1e2348fe3905c6;hb=1910cd0e05f7661986680e0a4472f4e857f90787;hp=c961844c443e7f08d86a0052602e78b73b907821;hpb=cc64d0175a3c2c974709e9962c00fbe04d74c43f;p=elogind.git diff --git a/src/journal/journal-remote-parse.c b/src/journal/journal-remote-parse.c index c961844c4..239ff3819 100644 --- a/src/journal/journal-remote-parse.c +++ b/src/journal/journal-remote-parse.c @@ -40,7 +40,7 @@ void source_free(RemoteSource *source) { static int get_line(RemoteSource *source, char **line, size_t *size) { ssize_t n, remain; - char *c; + char *c = NULL; char *newbuf = NULL; size_t newsize = 0; @@ -49,11 +49,17 @@ static int get_line(RemoteSource *source, char **line, size_t *size) { assert(source->filled <= source->size); assert(source->buf == NULL || source->size > 0); - c = memchr(source->buf, '\n', source->filled); + if (source->buf) + c = memchr(source->buf, '\n', source->filled); + if (c != NULL) goto docopy; resize: + if (source->fd < 0) + /* we have to wait for some data to come to us */ + return -EWOULDBLOCK; + if (source->size - source->filled < LINE_CHUNK) { // XXX: add check for maximum line length @@ -130,6 +136,10 @@ static int fill_fixed_size(RemoteSource *source, void **data, size_t size) { assert(data); while(source->filled < size) { + if (source->fd < 0) + /* we have to wait for some data to come to us */ + return -EWOULDBLOCK; + if (!GREEDY_REALLOC(source->buf, source->size, size)) return log_oom();