[prev in list] [next in list] [prev in thread] [next in thread]
List: helix-server-cvs
Subject: [Server-cvs] log/tmplgpln outputs.cpp, 1.30, 1.31 outputs.h, 1.18, 1.19
From: tniu () helixcommunity ! org
Date: 2013-11-27 9:06:30
[Download RAW message or body]
Update of /cvsroot/server/log/tmplgpln
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv12639
Modified Files:
outputs.cpp outputs.h
Log Message:
Synopsis
========
This CR fix bug:
(HLXSRV-755) [RTSP Ingest]The error log couldn't be printed in time.
Branch : SERVER_15_1_0_RN, HEAD
Suggested Reviewer : Anyone
Description
===========
Repro (100%):
1. Setup some RTSP ingest sources on the server.
<List Name="RTSP_Ingest">
<Var GlobalEnable="1"/>
<Var InitialTimeout="10"/>
<Var SourceScanInterval="60"/>
<Var StreamTimeout="5"/>
<Var DebugLevel="0"/>
<List Name="Source1">
<Var StreamURL="rtsp://brianw2k12.qacn.com/broadcast/rbslive1"/>
<Var Enable="1"/>
<Var StreamName="rtspstream"/>
<Var Password="hms"/>
<Var UserName="hms"/>
</List>
...
</List>
2. Start all encoders for those sources 3. Disable the RTSP Ingest global enable 4. \
Check the rmerror.log
Platform: RHEL6
Actual:
only print the first item
INFO:19-Nov-2013 11:24:45.428 tmplgpln(10062): RTSP Ingest live feed "rtspstream2" \
deactivated.
Expected:
Should printed all connections deactivated log at the same time
INFO:19-Nov-2013 11:24:45.428 tmplgpln(10062): RTSP Ingest live feed "rtspstream2" \
deactivated. INFO:19-Nov-2013 11:24:46.835 tmplgpln(10062): RTSP Ingest live feed \
"rtspstream3" deactivated. INFO:19-Nov-2013 11:24:47.327 tmplgpln(10062): RTSP \
Ingest live feed "rtspstream4" deactivated. INFO:19-Nov-2013 11:24:47.525 \
tmplgpln(10062): RTSP Ingest live feed "rtspstream3test" deactivated. \
INFO:19-Nov-2013 11:24:56.757 tmplgpln(10062): RTSP Ingest live feed "rtspstream1" \
deactivated. INFO:19-Nov-2013 11:24:57.929 tmplgpln(10062): RTSP Ingest live feed \
"rtspstream1test" deactivated.
Root cause:
Write log to disk Until the time between first log and second log more than 1s, if no \
second log, no longer write these log to disk.
My solution:
Write log file every 1s to fflush().
Files Affected
==============
server/log/tmplgpln/outputs.cpp
server/log/tmplgpln/outputs.h
Test perform
================
Integration Tests:
N/A
Performance Tests:
N/A
QA Hints
========
None.
Terry Niu
Helix Server/Producer SDE
RealNetworks China
T: +86 (10) 5954 2763
M: +86 134 0102 7106
Index: outputs.cpp
===================================================================
RCS file: /cvsroot/server/log/tmplgpln/outputs.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- outputs.cpp 18 Oct 2013 10:39:40 -0000 1.30
+++ outputs.cpp 27 Nov 2013 09:06:27 -0000 1.31
@@ -236,6 +236,26 @@
// CTLFileOutput::CTLFileOutput
///////////////////////////////////////////////////////////////////////////////
+CTLFileOutput::CFFlushCallback::CFFlushCallback(CTLFileOutput* pOwner)
+ : m_pOwner(pOwner)
+{
+}
+
+CTLFileOutput::CFFlushCallback::~CFFlushCallback()
+{
+}
+
+STDMETHODIMP
+CTLFileOutput::CFFlushCallback::Func()
+{
+ if(m_pOwner)
+ {
+ m_pOwner->FlushFile();
+ }
+
+ return HXR_OK;
+}
+
CTLFileOutput::CTLFileOutput()
: CTLOutput()
, m_fp(NULL)
@@ -244,15 +264,13 @@
, m_pTSScheduler(NULL)
, m_pScheduler(NULL)
, m_ulRollTimeCallbackHandle(0)
+ , m_ulFFlushCallbackHandle(0)
, m_nRollTime(0)
, m_nRollSize(0)
, m_nByteCount(0)
, m_pContext(NULL)
, m_pFileMutex(NULL)
- , stLastTime(0)
- , stCurTime(0)
{
- time(&stLastTime);
}
@@ -268,13 +286,12 @@
, m_pTSScheduler(pTSScheduler)
, m_pScheduler(NULL)
, m_ulRollTimeCallbackHandle(0)
+ , m_ulFFlushCallbackHandle(0)
, m_nRollTime(0)
, m_nRollSize(0)
, m_nByteCount(0)
, m_pContext(NULL)
, m_pFileMutex(NULL)
- , stLastTime(0)
- , stCurTime(0)
{
// Only required for log rolling.
@@ -299,7 +316,6 @@
m_pszOutputName = new char[strlen(szOutputName) + 1];
strcpy(m_pszOutputName, szOutputName);
- time(&stLastTime);
}
@@ -313,13 +329,12 @@
, m_pTSScheduler(pTSScheduler)
, m_pScheduler(NULL)
, m_ulRollTimeCallbackHandle(0)
+ , m_ulFFlushCallbackHandle(0)
, m_nRollTime(0)
, m_nRollSize(0)
, m_nByteCount(0)
, m_pContext(NULL)
, m_pFileMutex(NULL)
- , stLastTime(0)
- , stCurTime(0)
{
m_szFilenameBase = new char[strlen(szFilename) + 1];
@@ -335,7 +350,6 @@
pTSScheduler->AddRef(); // addref for m_pTSScheduler
}
- time(&stLastTime);
}
@@ -356,6 +370,11 @@
m_pTSScheduler->Remove(m_ulRollTimeCallbackHandle);
}
+ if(m_ulFFlushCallbackHandle)
+ {
+ m_pTSScheduler->Remove(m_ulFFlushCallbackHandle);
+ }
+
HX_RELEASE(m_pFileMutex);
HX_RELEASE(m_pTSScheduler);
HX_RELEASE(m_pScheduler);
@@ -685,6 +704,51 @@
m_nByteCount = 0;
}
+void
+CTLFileOutput::FlushFile()
+{
+ m_ulFFlushCallbackHandle = 0;
+ if(m_fp != NULL)
+ {
+ const char* szErrorMsg = NULL;
+ UINT32 ulErrorCode = 0;
+ struct stat st;
+
+ if (fflush(m_fp) != 0)
+ {
+ ulErrorCode = errno;
+ szErrorMsg = strerror(ulErrorCode);
+ }
+ else if (m_szCurrentOpenFile)
+ {
+ if (stat(m_szCurrentOpenFile, &st) == 0)
+ {
+ m_nByteCount = st.st_size;
+ }
+ else
+ {
+ ulErrorCode = errno;
+ szErrorMsg = strerror(ulErrorCode);
+ }
+ }
+
+ if (szErrorMsg)
+ {
+ HX_VECTOR_DELETE(m_pszLastError);
+ m_pszLastError = new char[strlen(szErrorMsg) + 1];
+ strcpy(m_pszLastError, szErrorMsg);
+ m_ulLastErrorCode = ulErrorCode;
+ }
+ }
+
+ if(m_pTSScheduler)
+ {
+ CFFlushCallback* pCallback = new CFFlushCallback(this);
+ pCallback->AddRef();
+ m_ulFFlushCallbackHandle = m_pTSScheduler->RelativeEnter(pCallback, \
FLUSH_INTERVAL_TIME * 1000); + pCallback->Release();
+ }
+}
///////////////////////////////////////////////////////////////////////////////
// CTLFileOutput::OpenFile
@@ -749,6 +813,14 @@
return HXR_FAIL;
}
+ if(m_pTSScheduler)
+ {
+ CFFlushCallback* pCallback = new CFFlushCallback(this);
+ pCallback->AddRef();
+ m_ulFFlushCallbackHandle = m_pTSScheduler->RelativeEnter(pCallback, \
FLUSH_INTERVAL_TIME * 1000); + pCallback->Release();
+ }
+
return HXR_OK;
}
@@ -785,8 +857,6 @@
if (m_fp && !szErrorMsg)
{
- struct stat st;
-
replacePercent((char *)pOutput->GetBuffer(), pOutput->GetSize());
m_pFileMutex->Lock();
@@ -794,36 +864,11 @@
strlen((const char*)pOutput->GetBuffer()), m_fp);
m_pFileMutex->Unlock();
- double dDiffTime = 0;
- time(&stCurTime);
- dDiffTime = difftime(stCurTime, stLastTime);
-
if (nWritten <= 0)
{
ulErrorCode = errno;
szErrorMsg = strerror(ulErrorCode);
- }
- else if (dDiffTime >= FLUSH_INTERVAL_TIME)
- {
- time(&stLastTime);
- if (fflush(m_fp) != 0)
- {
- ulErrorCode = errno;
- szErrorMsg = strerror(ulErrorCode);
- }
- else if (m_szCurrentOpenFile)
- {
- if (stat(m_szCurrentOpenFile, &st) == 0)
- {
- m_nByteCount = st.st_size;
- }
- else
- {
- ulErrorCode = errno;
- szErrorMsg = strerror(ulErrorCode);
- }
- }
- }
+ }
}
if (szErrorMsg)
Index: outputs.h
===================================================================
RCS file: /cvsroot/server/log/tmplgpln/outputs.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- outputs.h 18 Oct 2013 10:39:40 -0000 1.18
+++ outputs.h 27 Nov 2013 09:06:27 -0000 1.19
@@ -130,6 +130,17 @@
{
protected:
+
+ class CFFlushCallback : public BaseCallback
+ {
+ public:
+ CFFlushCallback(CTLFileOutput* pOwner);
+ virtual ~CFFlushCallback();
+ // Callback Func
+ STDMETHOD(Func) (THIS);
+ private:
+ CTLFileOutput* m_pOwner;
+ };
FILE* m_fp;
@@ -144,12 +155,10 @@
INT32 m_nRollTime; // Time at which to roll-- in MINUTES.
INT32 m_nRollSize; // Size at which to roll-- in BYTES.
- time_t stLastTime;
- time_t stCurTime;
-
IHXThreadSafeScheduler* m_pTSScheduler;
IHXScheduler* m_pScheduler;
CallbackHandle m_ulRollTimeCallbackHandle;
+ CallbackHandle m_ulFFlushCallbackHandle;
HXTimeval m_StartTime;
@@ -185,6 +194,7 @@
BOOL WantToRotate(IHXBuffer *pOutput);
void Rotate();
+ void FlushFile();
HX_RESULT OpenFile();
virtual HX_RESULT Output(IHXBuffer* pOutput);
_______________________________________________
Server-cvs mailing list
Server-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/server-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic