Hi Bruce, Thanks for the patch. It may be worth just grepping for os.mkdir to see if there are other potential race conditions that match this pattern and maybe fix them all in one sweep.
Dave On Tue, Mar 23, 2010 at 04:33, Bruce Duncan <[email protected]> wrote: > Hi, > > We are using dulwich in a project. It is good! > > Our daemon is threaded and we have managed to hit a race condition while > creating objects. I believe the attached patch fixes this. Please can > you apply it? > > Bruce > > In threaded programs, more than one thread can try to add the same object > at > the same time and this can cause os.mkdir to fail. > --- > dulwich/object_store.py | 5 ++++- > 1 files changed, 4 insertions(+), 1 deletions(-) > > diff --git a/dulwich/object_store.py b/dulwich/object_store.py > index ca26348..46832f5 100644 > --- a/dulwich/object_store.py > +++ b/dulwich/object_store.py > @@ -470,8 +470,11 @@ class DiskObjectStore(PackBasedObjectStore): > :param obj: Object to add > """ > dir = os.path.join(self.path, obj.id[:2]) > - if not os.path.isdir(dir): > + try: > os.mkdir(dir) > + except OSError, e: > + if e.errno != errno.EEXIST: > + raise > path = os.path.join(dir, obj.id[2:]) > if os.path.exists(path): > return # Already there, no need to write again > -- > 1.6.3.3 > > -- > CLX Compute Cluster Developer (http://clx.see.ed.ac.uk/) > AL116, Alrick Building, King's Buildings. 0131 6505637 > School of Engineering, University of Edinburgh > > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > > _______________________________________________ > Mailing list: > https://launchpad.net/~dulwich-users<https://launchpad.net/%7Edulwich-users> > Post to : [email protected] > Unsubscribe : > https://launchpad.net/~dulwich-users<https://launchpad.net/%7Edulwich-users> > More help : https://help.launchpad.net/ListHelp > >
_______________________________________________ Mailing list: https://launchpad.net/~dulwich-users Post to : [email protected] Unsubscribe : https://launchpad.net/~dulwich-users More help : https://help.launchpad.net/ListHelp

