Bug 22524 - XMLHttpRequest needs to have the static defines made threadsafe.
Summary: XMLHttpRequest needs to have the static defines made threadsafe.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: XML (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-26 20:41 PST by David Levin
Modified: 2008-11-28 02:24 PST (History)
1 user (show)

See Also:


Attachments
Removes the non-thread safe static initializations in XMLHttpRequest.cpp (9.42 KB, patch)
2008-11-26 20:47 PST, David Levin
no flags Details | Formatted Diff | Diff
Very minor adjustment to the last patch (-- moves one brace for style purposes). (9.42 KB, patch)
2008-11-27 01:00 PST, David Levin
no flags Details | Formatted Diff | Diff
Changed the static initialization to happen in the XHR constructor. (9.14 KB, patch)
2008-11-27 23:13 PST, David Levin
no flags Details | Formatted Diff | Diff
Another revision. I think it is close. (9.27 KB, patch)
2008-11-28 01:14 PST, David Levin
ap: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.