# HG changeset patch # User Erik Quanstrom # Date 1331826884 -3600 # Node ID 3114b5af088bd60ecc17f00233c3b378141215d6 # Parent 9323f8fa6d56c87847052d79e05a0e44a329109b port/chan.c: fix locking issue. this was discovered as an occasional crash on plan 9 a few years ago. the problem is that the check is made outside the lock. change: reorganize as per charles comments. change: make pretty, embiggen the diff with plan 9. R=nixiedev, charles.forsyth, nemo.mbox CC=nix-dev http://codereview.appspot.com/5795071 Committer: Francisco J Ballesteros diff -r 9323f8fa6d56 -r 3114b5af088b sys/src/nix/port/chan.c --- a/sys/src/nix/port/chan.c Thu Mar 15 11:22:18 2012 +0100 +++ b/sys/src/nix/port/chan.c Thu Mar 15 16:54:44 2012 +0100 @@ -922,14 +922,16 @@ * mh->mount->to == c, so start at mh->mount->next */ rlock(&mh->lock); - for(f = mh->mount->next; f; f = f->next) - if((wq = ewalk(f->to, nil, names+nhave, ntry)) != nil) - break; + if(mh->mount){ + for(f = mh->mount->next; f != nil; f = f->next){ + if((wq = ewalk(f->to, nil, names+nhave, ntry)) != nil){ + dc = f->to->dev->dc; + devno = f->to->devno; + break; + } + } + } runlock(&mh->lock); - if(f != nil){ - dc = f->to->dev->dc; - devno = f->to->devno; - } } if(wq == nil){ cclose(c); @@ -1551,7 +1553,7 @@ goto Open; default: - panic("unknown namec access %d\n", amode); + panic("unknown namec access %d", amode); } /* place final element in genbuf for e.g. exec */