Commit e4c79c13 authored by Owen Rudge's avatar Owen Rudge Committed by Alexandre Julliard

wsdapi: Add critical section around notification sinks.

parent e69f0974
...@@ -97,6 +97,7 @@ static ULONG WINAPI IWSDiscoveryPublisherImpl_Release(IWSDiscoveryPublisher *ifa ...@@ -97,6 +97,7 @@ static ULONG WINAPI IWSDiscoveryPublisherImpl_Release(IWSDiscoveryPublisher *ifa
HeapFree(GetProcessHeap(), 0, sink); HeapFree(GetProcessHeap(), 0, sink);
} }
DeleteCriticalSection(&This->notification_sink_critical_section);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
...@@ -148,7 +149,9 @@ static HRESULT WINAPI IWSDiscoveryPublisherImpl_RegisterNotificationSink(IWSDisc ...@@ -148,7 +149,9 @@ static HRESULT WINAPI IWSDiscoveryPublisherImpl_RegisterNotificationSink(IWSDisc
sink->notificationSink = pSink; sink->notificationSink = pSink;
IWSDiscoveryPublisherNotify_AddRef(pSink); IWSDiscoveryPublisherNotify_AddRef(pSink);
EnterCriticalSection(&impl->notification_sink_critical_section);
list_add_tail(&impl->notificationSinks, &sink->entry); list_add_tail(&impl->notificationSinks, &sink->entry);
LeaveCriticalSection(&impl->notification_sink_critical_section);
if ((!impl->publisherStarted) && (!init_networking(impl))) if ((!impl->publisherStarted) && (!init_networking(impl)))
return E_FAIL; return E_FAIL;
...@@ -168,6 +171,8 @@ static HRESULT WINAPI IWSDiscoveryPublisherImpl_UnRegisterNotificationSink(IWSDi ...@@ -168,6 +171,8 @@ static HRESULT WINAPI IWSDiscoveryPublisherImpl_UnRegisterNotificationSink(IWSDi
return E_INVALIDARG; return E_INVALIDARG;
} }
EnterCriticalSection(&impl->notification_sink_critical_section);
LIST_FOR_EACH_ENTRY(sink, &impl->notificationSinks, struct notificationSink, entry) LIST_FOR_EACH_ENTRY(sink, &impl->notificationSinks, struct notificationSink, entry)
{ {
if (sink->notificationSink == pSink) if (sink->notificationSink == pSink)
...@@ -176,10 +181,13 @@ static HRESULT WINAPI IWSDiscoveryPublisherImpl_UnRegisterNotificationSink(IWSDi ...@@ -176,10 +181,13 @@ static HRESULT WINAPI IWSDiscoveryPublisherImpl_UnRegisterNotificationSink(IWSDi
list_remove(&sink->entry); list_remove(&sink->entry);
HeapFree(GetProcessHeap(), 0, sink); HeapFree(GetProcessHeap(), 0, sink);
LeaveCriticalSection(&impl->notification_sink_critical_section);
return S_OK; return S_OK;
} }
} }
LeaveCriticalSection(&impl->notification_sink_critical_section);
/* Notification sink is not registered */ /* Notification sink is not registered */
return E_FAIL; return E_FAIL;
} }
...@@ -391,6 +399,7 @@ HRESULT WINAPI WSDCreateDiscoveryPublisher(IWSDXMLContext *pContext, IWSDiscover ...@@ -391,6 +399,7 @@ HRESULT WINAPI WSDCreateDiscoveryPublisher(IWSDXMLContext *pContext, IWSDiscover
return ret; return ret;
} }
InitializeCriticalSection(&obj->notification_sink_critical_section);
list_init(&obj->notificationSinks); list_init(&obj->notificationSinks);
*ppPublisher = &obj->IWSDiscoveryPublisher_iface; *ppPublisher = &obj->IWSDiscoveryPublisher_iface;
......
...@@ -48,6 +48,7 @@ typedef struct IWSDiscoveryPublisherImpl { ...@@ -48,6 +48,7 @@ typedef struct IWSDiscoveryPublisherImpl {
IWSDXMLContext *xmlContext; IWSDXMLContext *xmlContext;
DWORD addressFamily; DWORD addressFamily;
struct list notificationSinks; struct list notificationSinks;
CRITICAL_SECTION notification_sink_critical_section;
BOOL publisherStarted; BOOL publisherStarted;
HANDLE thread_handles[MAX_WSD_THREADS]; HANDLE thread_handles[MAX_WSD_THREADS];
int num_thread_handles; int num_thread_handles;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment