Bug 22524

Summary: XMLHttpRequest needs to have the static defines made threadsafe.
Product: WebKit Reporter: David Levin <levin>
Component: XMLAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ap
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Removes the non-thread safe static initializations in XMLHttpRequest.cpp
none
Very minor adjustment to the last patch (-- moves one brace for style purposes).
none
Changed the static initialization to happen in the XHR constructor.
none
Another revision. I think it is close. ap: review+

Description David Levin 2008-11-26 20:41:45 PST
This is part of making XHR available to workers.
Comment 1 David Levin 2008-11-26 20:47:52 PST
Created attachment 25548 [details]
Removes the non-thread safe static initializations in  XMLHttpRequest.cpp
Comment 2 David Levin 2008-11-27 01:00:32 PST
Created attachment 25555 [details]
Very minor adjustment to the last patch (-- moves one brace for style purposes).
Comment 3 Alexey Proskuryakov 2008-11-27 07:33:42 PST
Hmm... The patch is executed perfectly, but I think that it may be over-engineered a bit. I don't see how having classes for each function helps - is it better than just protecting initialization parts of these functions with a mutex?
Comment 4 David Levin 2008-11-27 23:13:35 PST
Created attachment 25566 [details]
Changed the static initialization to happen in the XHR constructor.

I didn't like doing a mutex in the functions due to one of them being called inside of a loop.   As discussed, I've tried out a solution that initializes the static variables in the constructor.  I looked at a few ways of doing this.  The reason I put the variables in a struct and then initialized into a local static was to take advantage of AtomicallyInitializedStatic.

If this doesn't seem that great, one alternative I can think of is to create another macro like AtomicallyInitializedStatic (in threading.h) that allowed me to call a function inside of this same mutex.
Comment 5 David Levin 2008-11-28 01:14:29 PST
Created attachment 25568 [details]
Another revision.  I think it is close.
Comment 6 Alexey Proskuryakov 2008-11-28 01:22:58 PST
Comment on attachment 25568 [details]
Another revision.  I think it is close.

r=me
Comment 7 Alexey Proskuryakov 2008-11-28 02:24:35 PST
Committed revision 38827.

I made a slight tweak I didn't think about earlier: made the global const.