From cc1fdf71380819eb990e206de19dbeb94a442249 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 8 Nov 2010 21:48:48 +0100 Subject: [PATCH] Revert --- util/flv_sock.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/util/flv_sock.cpp b/util/flv_sock.cpp index fe4912f1..426aa7bd 100644 --- a/util/flv_sock.cpp +++ b/util/flv_sock.cpp @@ -32,19 +32,22 @@ bool FLV_Isheader(char * header){ }//FLV_Isheader bool ReadUntil(char * buffer, unsigned int count, unsigned int & sofar, int sock){ - if (sofar >= count){return true;} - fprintf(stderr, "Reading %i/%i\n", sofar, count); - if (DDV_readycount(sock) >= count-sofar){ - bool r = DDV_read(buffer + sofar,count-sofar,sock); - sofar = count; - if (!r){ + if (sofar == count){return true;} + int r = DDV_iread(buffer + sofar,count-sofar,sock); + if (r < 0){ + if (errno != EWOULDBLOCK){ All_Hell_Broke_Loose = true; fprintf(stderr, "ReadUntil fail: %s. All Hell Broke Loose!\n", strerror(errno)); } - return r; - }else{ return false; } + sofar += r; + if (sofar == count){return true;} + if (sofar > count){ + All_Hell_Broke_Loose = true; + fprintf(stderr, "ReadUntil fail: %s. Read too much. All Hell Broke Loose!\n", strerror(errno)); + } + return false; } //gets a packet, storing in given FLV_Pack pointer. @@ -55,7 +58,7 @@ bool FLV_GetPacket(FLV_Pack *& p, int sock){ static bool done = true; static unsigned int sofar = 0; if (!p){p = (FLV_Pack*)calloc(1, sizeof(FLV_Pack));} - if (p->buf < 15){p->data = (char*)realloc(p->data, 5000); p->buf = 5000;} + if (p->buf < 15){p->data = (char*)realloc(p->data, 15); p->buf = 15;} if (done){ //read a header