From 981304acaf05187427399e4405f6f55abe85649a Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 8 Nov 2010 03:12:24 +0100 Subject: [PATCH] Buffer crash fix --- Buffer/main.cpp | 2 +- util/flv.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Buffer/main.cpp b/Buffer/main.cpp index e60cc7ac..e81f80fa 100644 --- a/Buffer/main.cpp +++ b/Buffer/main.cpp @@ -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]; diff --git a/util/flv.cpp b/util/flv.cpp index 44185ffd..c04d977a 100644 --- a/util/flv.cpp +++ b/util/flv.cpp @@ -1,4 +1,5 @@ #include //for read() +#include 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