Fix crashes due to static_instance.
- Initialize a needed critsect in the constructor of UdpSocket2ManagerWindows. - Don't return NULL when creating a static instance. TEST=voe_auto_test on Windows. Review URL: http://webrtc-codereview.appspot.com/324008 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1177 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
5a9c6f26ab
commit
6d609b59f3
@ -25,9 +25,10 @@ UdpSocket2ManagerWindows::UdpSocket2ManagerWindows()
|
|||||||
_id(-1),
|
_id(-1),
|
||||||
_stopped(false),
|
_stopped(false),
|
||||||
_init(false),
|
_init(false),
|
||||||
_pCrit(NULL),
|
_pCrit(CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_ioCompletionHandle(NULL),
|
_ioCompletionHandle(NULL),
|
||||||
_numActiveSockets(0)
|
_numActiveSockets(0),
|
||||||
|
_event(EventWrapper::Create())
|
||||||
{
|
{
|
||||||
_managerNumber = _numOfActiveManagers++;
|
_managerNumber = _numOfActiveManagers++;
|
||||||
|
|
||||||
@ -40,7 +41,6 @@ UdpSocket2ManagerWindows::UdpSocket2ManagerWindows()
|
|||||||
// if a UdpSocket2ManagerWindows() created and destroyed
|
// if a UdpSocket2ManagerWindows() created and destroyed
|
||||||
// without being initialized.
|
// without being initialized.
|
||||||
}
|
}
|
||||||
_event = EventWrapper::Create();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UdpSocket2ManagerWindows::~UdpSocket2ManagerWindows()
|
UdpSocket2ManagerWindows::~UdpSocket2ManagerWindows()
|
||||||
@ -87,10 +87,10 @@ UdpSocket2ManagerWindows::~UdpSocket2ManagerWindows()
|
|||||||
WSACleanup();
|
WSACleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(_pCrit)
|
}
|
||||||
{
|
if(_pCrit)
|
||||||
delete _pCrit;
|
{
|
||||||
}
|
delete _pCrit;
|
||||||
}
|
}
|
||||||
if(_event)
|
if(_event)
|
||||||
{
|
{
|
||||||
@ -164,11 +164,6 @@ bool UdpSocket2ManagerWindows::StartWorkerThreads()
|
|||||||
{
|
{
|
||||||
if(!_init)
|
if(!_init)
|
||||||
{
|
{
|
||||||
_pCrit = CriticalSectionWrapper::CreateCriticalSection();
|
|
||||||
if(_pCrit == NULL)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
_pCrit->Enter();
|
_pCrit->Enter();
|
||||||
|
|
||||||
_ioCompletionHandle = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL,
|
_ioCompletionHandle = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL,
|
||||||
|
@ -131,7 +131,6 @@ private:
|
|||||||
bool _init;
|
bool _init;
|
||||||
WebRtc_Word32 _numActiveSockets;
|
WebRtc_Word32 _numActiveSockets;
|
||||||
ListWrapper _workerThreadsList;
|
ListWrapper _workerThreadsList;
|
||||||
WebRtc_UWord32 _numOfWorkThreads;
|
|
||||||
EventWrapper* _event;
|
EventWrapper* _event;
|
||||||
|
|
||||||
HANDLE _ioCompletionHandle;
|
HANDLE _ioCompletionHandle;
|
||||||
|
@ -138,7 +138,6 @@ static T* GetStaticInstance(CountOperation count_operation) {
|
|||||||
delete static_cast<T*>(new_instance);
|
delete static_cast<T*>(new_instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
} else if (state == kDestroy) {
|
} else if (state == kDestroy) {
|
||||||
T* old_value = static_cast<T*> (InterlockedExchangePointer(
|
T* old_value = static_cast<T*> (InterlockedExchangePointer(
|
||||||
reinterpret_cast<void* volatile*>(&instance), NULL));
|
reinterpret_cast<void* volatile*>(&instance), NULL));
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
'../interface/scoped_ptr.h',
|
'../interface/scoped_ptr.h',
|
||||||
'../interface/scoped_refptr.h',
|
'../interface/scoped_refptr.h',
|
||||||
'../interface/sort.h',
|
'../interface/sort.h',
|
||||||
|
'../interface/static_instance.h',
|
||||||
'../interface/thread_wrapper.h',
|
'../interface/thread_wrapper.h',
|
||||||
'../interface/tick_util.h',
|
'../interface/tick_util.h',
|
||||||
'../interface/trace.h',
|
'../interface/trace.h',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user