#10472: RegexURLResolver.reverse() is not threadsafe
-----------------------------------------------+----------------------------
 Reporter:  tdterry                            |       Owner:  nobody    
   Status:  new                                |   Milestone:            
Component:  Uncategorized                      |     Version:  1.0       
 Keywords:  urlresolvers, reverse, threadsafe  |       Stage:  Unreviewed
Has_patch:  1                                  |  
-----------------------------------------------+----------------------------
 I have found an incomplete-initialization bug in
 `RegexURLResolver.reverse()` when running under Apache mpm_worker with
 mod_wsgi.

 `RegexURLResolver` objects are stored in process local memory using
 `...@memoize`.  The `_reverse_dict` is built on demand, so two threads trying
 to build it for the first time can run into an incomplete initialization.
 The attached patch changes `RegexURLResolver._get_reverse_dict()` to do an
 atomic set of `self._reverse_dict`, preventing multiple threads from
 seeing an inconsistent `_reverse_dict`.

 Testing requires a multi-threaded setup and a good load test. These are
 not available in the framework, so I have not included a specific test
 with the patch.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10472>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to