Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#14433 closed (fixed)

Thread safety problem in contrib.sitemaps

Reported by: Gabriel Hurley Owned by: Gabriel Hurley
Component: Contrib apps Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Since sitemaps are global objects, setting self.request on the object is thread-unsafe. Reported here by Justin Bronn.

Attachments (1)

14433.diff (4.8 KB ) - added by Gabriel Hurley 14 years ago.
Restores thread-safety to contrib.sitemaps

Download all attachments as: .zip

Change History (7)

by Gabriel Hurley, 14 years ago

Attachment: 14433.diff added

Restores thread-safety to contrib.sitemaps

comment:1 by Gabriel Hurley, 14 years ago

Has patch: set
Status: newassigned

I believe this patch should restore thread safety by passing site as an argument rather than storing request on the Sitemap object. It is as backwards-compatible as possible, since prior to [13980] the get_urls method simply called Site.objects.get_current() directly, so this patch uses that behavior as a fallback for anyone who may have written custom view code which does not pass in a site as an argument.

comment:2 by Luke Plant, 14 years ago

Thanks Gabriel. I will commit with changes:

  • added tests for raising ImproperlyConfigured (and then added an import and some other logic that made the tests pass - hurray for TDD :-)
  • used keyword arguments in to Sitemap.get_urls() instead of positional, in django/contrib/sitemaps/views.py and django/contrib/gis/sitemaps/views.py

I am unable to run the GIS testsuite (see #14439), so I have not checked that the GIS sections are correct, but they look correct are (hopefully) trivial.

comment:3 by Luke Plant, 14 years ago

Resolution: fixed
Status: assignedclosed

(In [14141]) Fixed #14433 - replaced a thread-unsafe solution to #10235 introduced in [13980]

This patch also addresses sitemap code found in contrib/gis, which [13980]
did not.

Thanks to gabrielhurley for the initial patch.

Refs #10235, #14386

comment:4 by Luke Plant, 14 years ago

(In [14142]) [1.2.X] Fixed #14433 - replaced a thread-unsafe solution to #10235 introduced in [13980]

This patch also addresses sitemap code found in contrib/gis, which [13980]
did not.

Thanks to gabrielhurley for the initial patch.

Refs #10235, #14386

Backport of [14141] from trunk.

comment:5 by Gabriel Hurley, 14 years ago

I knew the patch wasn't finished, but I had to run out the door. I wanted to give Justin or someone else who could run the GIS suite a chance to look at it. All the same, thanks for wrapping it up Luke.

comment:6 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top