--- libmemcache-1.0.1/memcache.c 2004-12-07 19:20:11.000000000 +0000 +++ memcache.c 2004-12-07 23:16:47.000000000 +0000 @@ -773,7 +773,7 @@ mc_get_line(struct memcache *mc, struct return NULL; } - mc->buf = cp; + mc->buf = mc->cur = mc->start = cp; mc->read_cur = &mc->cur[mc->size]; mc->size *= 2; /* Note the change in buffer size */ } else { @@ -818,11 +818,19 @@ mc_get_line(struct memcache *mc, struct return NULL; } + /** + * If we got the same amount of data as we said was max, + * then we probably need to read more. Try it. + */ + if(rb == mc->size - (size_t)(mc->cur - mc->buf)) { + goto get_more_bits; + } + /* Search for a newline again, starting from where we read(2) * data in. Slight optimization over just starting the loop * over again since in most cases, we'll find a newline in the * newly read(2) chunk of data. */ - cp = memchr(mc->read_cur, (int)'\n', mc->size - (size_t)(mc->cur - mc->buf)); + cp = memchr(mc->cur, (int)'\n', mc->size - (size_t)(mc->cur - mc->buf)); if (cp == NULL) { /* We suck. Try again. This is nearly the same as a continue, * but saves us from doing an extra memchr(). */