Buffer crash fix

This commit is contained in:
Thulinma 2010-11-08 03:12:24 +01:00
parent c4e1851f42
commit 981304acaf
2 changed files with 7 additions and 1 deletions

View file

@ -60,7 +60,7 @@ int main( int argc, char * argv[] ) {
int infile = fileno(stdin);
int poller = epoll_create(1);
struct epoll_event ev;
ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
ev.events = EPOLLIN;
ev.data.fd = infile;
epoll_ctl(poller, EPOLL_CTL_ADD, infile, &ev);
struct epoll_event events[1];

View file

@ -1,4 +1,5 @@
#include <unistd.h> //for read()
#include <fcntl.h>
struct FLV_Pack {
int len;
@ -47,6 +48,9 @@ bool ReadUntil(char * buffer, unsigned int count, unsigned int & sofar){
//resizes FLV_Pack data field bigger if data doesn't fit
// (does not auto-shrink for speed!)
bool FLV_GetPacket(FLV_Pack *& p){
int preflags = fcntl(fileno(stdin), F_GETFL, 0);
int postflags = preflags | O_NONBLOCK;
fcntl(fileno(stdin), F_SETFL, postflags);
static bool done = true;
static unsigned int sofar = 0;
if (!p){p = (FLV_Pack*)calloc(1, sizeof(FLV_Pack));}
@ -80,9 +84,11 @@ bool FLV_GetPacket(FLV_Pack *& p){
if ((p->data[0] == 0x09) && (((p->data[11] & 0xf0) >> 4) == 1)){p->isKeyframe = true;}
done = true;
sofar = 0;
fcntl(fileno(stdin), F_SETFL, preflags);
return true;
}
}
fcntl(fileno(stdin), F_SETFL, preflags);
return false;
}//FLV_GetPacket