[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-server-cvs
Subject:    [Server-cvs] engine/core workermgr.cpp,1.3.2.1,1.3.2.2
From:       dcollins () helixcommunity ! org
Date:       2012-01-31 2:41:20
[Download RAW message or body]

Update of /cvsroot/server/engine/core
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv25958/server/engine/core

Modified Files:
      Tag: SERVER_14_3
	workermgr.cpp 
Log Message:
Synopsis
========
Fixes 270134: CentOS: The server will crash while set the port range
    more than 100 in Transmitter section

Branches: SERVER_14_3_RN, SERVER_CURRENT_RN (HEAD)
Reviewer: Chytanya


Description
===========

Each worker thread was opening enough sockets to handle the full range
of ports listed in the PortRange setting.  This resulted in a lot more
ports being opened on multi-cpu/multi-core systems than expected.
For the specific use-case in the PR, the user's fd limit was exceeded,
resulting in failure at startup.

The solution in this diff is to divide-up the range so that each worker
only tries to use a subset of the total PortRange.  

This required that the number of workers, and the current worker ID,
be available in the Destinations class.  Determining the total number
of workers was complicated by the fact that we need this information
before we have launched all the streamer/worker threads.

The solution was to add a simple method to the IHXWorkerThreadManager
interface:

STDMETHOD_(UINT32, GetMaxWorkerLimit) (THIS_ UINT32 /*IN*/ ulWorkerType);

WorkerThreadManager simply returns *g_pNumStreamers.  The one limitation
is that this is not set at the time that the bdstplin manager thread
is initialized, but it doesn't really need it anyhow.  Only the workers
need to determine which subset of ports they should use.

While debugging, I noticed the rand() calls in this code were not actually
very random, resulting in ports being selected identially from different
worker threads, so I switched it to use the better random32() routine.


Files Affected
==============

server/engine/core/workermgr.cpp
server/engine/core/pub/workermgr.h
server/include/hxworker.h
server-restricted/broadcast/transport/bcng/send-local/bdstplin.cpp
server-restricted/broadcast/transport/bcng/common/brdcstcfg.cpp
server-restricted/broadcast/transport/bcng/common/dests.cpp
server-restricted/broadcast/transport/bcng/common/pub/brdcstcfg.h
server-restricted/broadcast/transport/bcng/common/pub/dests.h


Testing Performed
=================

Unit Tests:
- Verified relevant internal debug messages.

Integration Tests:
- Tested with udp/unicast and udp/multicast.
- Tested with a PortRange that was smaller than the number of workers.
- Tested with a PortRange of only one port.
- Tested with multiple feeds and verifying that using udp/unicast they were
  sent to different ports (and usually different worker threads) on the
  Receiver.
- Tests were all with rtpencoder feeds, from Helix Producer 14.

Leak Tests:
- N/A

Performance Tests:
- N/A

Platforms Tested: linux-rhel5-x86_64
Builds Verified: linux-rhel5-x86_64


QA Hints
========
* Only affects outbound UDP from the Transmitter.


Index: workermgr.cpp
===================================================================
RCS file: /cvsroot/server/engine/core/workermgr.cpp,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -d -r1.3.2.1 -r1.3.2.2
--- workermgr.cpp	10 Jan 2012 04:53:29 -0000	1.3.2.1
+++ workermgr.cpp	31 Jan 2012 02:41:17 -0000	1.3.2.2
@@ -45,6 +45,8 @@
 #include "streamer_info.h"
 #include "servsockimp.h"
 #include "servsked.h"
+#include "timeval.h"
+#include "globals.h"
 #include "workermgr.h"
 
 #ifdef _UNIX
@@ -272,6 +274,16 @@
     return HXR_OK;
 }
 
+/****************************************************************************
+ *  IHXWorkerThreadManager::GetMaxWorkerLimit                ref:  hxworker.h
+ *
+ *  Returns the maximum number of workers of a given type
+ */
+UINT32
+WorkerThreadManager::GetMaxWorkerLimit(UINT32       /*IN*/  ulWorkerType)
+{
+    return *g_pNumStreamers;
+}
 
 
 /****************************************************************************


_______________________________________________
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