diff --git a/lib/sxmplv2.c b/lib/sxmplv2.c index 60ccecd..622125f 100644 --- a/lib/sxmplv2.c +++ b/lib/sxmplv2.c @@ -777,7 +777,15 @@ static void *__sxmpl_thread(void *b) gettimeofday(&beg, NULL); #endif memset(mhead, 0, sizeof(sxmplv2_head_t)); - rd = __conn_read(co, mhead, sizeof(sxmplv2_head_t)); + total_rd = 0; + while(total_rd != sizeof(sxmplv2_head_t)) { + total_rd += __conn_read(co, buf + total_rd, sizeof(sxmplv2_head_t) - total_rd); + if(total_rd == -1) { + co->flags |= SXMP_CLOSED; + break; + } + } + rd = total_rd; #ifdef _PERFPROFILE gettimeofday(&end, NULL); @@ -808,7 +816,7 @@ static void *__sxmpl_thread(void *b) #endif total_rd = 0; while(total_rd != mhead->payload_length) { - total_rd += __conn_read(co, bbuf + total_rd, mhead->payload_length); + total_rd += __conn_read(co, bbuf + total_rd, mhead->payload_length - total_rd); if(total_rd == -1) goto __sslproto_error; } rd = total_rd;