From 414cec2797337edb720dfcfc62e930db747c8f0d Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 7 Sep 2012 17:31:10 +0200 Subject: [PATCH] Fix CPU usage issues. --- src/conn_http_dynamic.cpp | 2 ++ src/conn_http_progressive.cpp | 2 ++ src/conn_rtmp.cpp | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/conn_http_dynamic.cpp b/src/conn_http_dynamic.cpp index a828ca05..993c9934 100644 --- a/src/conn_http_dynamic.cpp +++ b/src/conn_http_dynamic.cpp @@ -201,6 +201,8 @@ namespace Connector_HTTP{ fprintf(stderr, "Could not parse the following:\n%s\n", conn.Received().c_str()); #endif } + }else{ + usleep(10000);//sleep 10ms } if (ready4data){ if (!inited){ diff --git a/src/conn_http_progressive.cpp b/src/conn_http_progressive.cpp index c626a471..dad3b6d5 100644 --- a/src/conn_http_progressive.cpp +++ b/src/conn_http_progressive.cpp @@ -58,6 +58,8 @@ namespace Connector_HTTP{ fprintf(stderr, "Could not parse the following:\n%s\n", conn.Received().c_str()); #endif } + }else{ + usleep(10000);//sleep 10ms } if (ready4data){ if (!inited){ diff --git a/src/conn_rtmp.cpp b/src/conn_rtmp.cpp index d4c566da..35bea93f 100644 --- a/src/conn_rtmp.cpp +++ b/src/conn_rtmp.cpp @@ -76,10 +76,11 @@ int Connector_RTMP::Connector_RTMP(Socket::Connection conn){ bool firstrun = true; while (Socket.connected()){ - usleep(10000);//sleep 10ms to prevent high CPU usage if (Socket.spool() || firstrun){ firstrun = false; parseChunk(Socket.Received()); + }else{ + usleep(10000);//sleep 10ms to prevent high CPU usage } if (ready4data){ if (!inited){