Title: [101825] trunk/Source/WebCore
- Revision
- 101825
- Author
- da...@apple.com
- Date
- 2011-12-02 10:34:37 -0800 (Fri, 02 Dec 2011)
Log Message
[Mac] Form stream data structures still not threadsafe
https://bugs.webkit.org/show_bug.cgi?id=73674
Reviewed by Anders Carlsson.
* platform/network/mac/FormDataStreamMac.mm:
(WebCore::streamFieldsMapMutex): Added.
(WebCore::associateStreamWithResourceHandle): Use streamFieldsMapMutex.
(WebCore::formCreate): Ditto.
(WebCore::formFinalize): Ditto.
(WebCore::httpBodyFromStream): Ditto.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (101824 => 101825)
--- trunk/Source/WebCore/ChangeLog 2011-12-02 18:31:40 UTC (rev 101824)
+++ trunk/Source/WebCore/ChangeLog 2011-12-02 18:34:37 UTC (rev 101825)
@@ -1,3 +1,17 @@
+2011-12-02 Darin Adler <da...@apple.com>
+
+ [Mac] Form stream data structures still not threadsafe
+ https://bugs.webkit.org/show_bug.cgi?id=73674
+
+ Reviewed by Anders Carlsson.
+
+ * platform/network/mac/FormDataStreamMac.mm:
+ (WebCore::streamFieldsMapMutex): Added.
+ (WebCore::associateStreamWithResourceHandle): Use streamFieldsMapMutex.
+ (WebCore::formCreate): Ditto.
+ (WebCore::formFinalize): Ditto.
+ (WebCore::httpBodyFromStream): Ditto.
+
2011-12-02 Joshua Bell <jsb...@chromium.org>
IndexedDB: Rename "multientry" to "multiEntry" per spec change
Modified: trunk/Source/WebCore/platform/network/mac/FormDataStreamMac.mm (101824 => 101825)
--- trunk/Source/WebCore/platform/network/mac/FormDataStreamMac.mm 2011-12-02 18:31:40 UTC (rev 101824)
+++ trunk/Source/WebCore/platform/network/mac/FormDataStreamMac.mm 2011-12-02 18:34:37 UTC (rev 101825)
@@ -56,7 +56,12 @@
namespace WebCore {
-// We need to use NSMapTable instead of HashMap since this needs to be accessed from more than one thread.
+static Mutex& streamFieldsMapMutex()
+{
+ DEFINE_STATIC_LOCAL(Mutex, staticMutex, ());
+ return staticMutex;
+}
+
static NSMapTable *streamFieldsMap()
{
static NSMapTable *streamFieldsMap = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 1);
@@ -79,8 +84,11 @@
if (!stream)
return;
- if (!NSMapGet(streamFieldsMap(), stream))
- return;
+ {
+ MutexLocker locker(streamFieldsMapMutex());
+ if (!NSMapGet(streamFieldsMap(), stream))
+ return;
+ }
ASSERT(!getStreamResourceHandleMap().contains((CFReadStreamRef)stream));
getStreamResourceHandleMap().set((CFReadStreamRef)stream, resourceHandle);
@@ -247,6 +255,7 @@
for (size_t i = 0; i < size; ++i)
newInfo->remainingElements.append(newInfo->formData->elements()[size - i - 1]);
+ MutexLocker locker(streamFieldsMapMutex());
ASSERT(!NSMapGet(streamFieldsMap(), stream));
NSMapInsertKnownAbsent(streamFieldsMap(), stream, newInfo);
@@ -264,6 +273,8 @@
{
FormStreamFields* form = static_cast<FormStreamFields*>(context);
+ MutexLocker locker(streamFieldsMapMutex());
+
ASSERT(form->formStream == stream);
ASSERT(NSMapGet(streamFieldsMap(), stream) == context);
@@ -496,6 +507,7 @@
FormData* httpBodyFromStream(NSInputStream* stream)
{
+ MutexLocker locker(streamFieldsMapMutex());
FormStreamFields* formStream = static_cast<FormStreamFields*>(NSMapGet(streamFieldsMap(), stream));
if (!formStream)
return 0;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes