diff options
author | cinap_lenrek <cinap_lenrek@centraldogma> | 2011-09-02 14:12:39 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@centraldogma> | 2011-09-02 14:12:39 +0200 |
commit | 513bdcccdc023f17bd36a388d09f8a03a7a707a7 (patch) | |
tree | 6c9de21dee251a1f6554e8b62573557ef1e44d83 /sys/src/9/port/chan.c | |
parent | 9e65fced986d6dfcc3d00077c592ef5bc9138d0b (diff) |
chan: use chanpath() in chan DBG, do more checking in cclose and cclone
Diffstat (limited to 'sys/src/9/port/chan.c')
-rw-r--r-- | sys/src/9/port/chan.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/src/9/port/chan.c b/sys/src/9/port/chan.c index d21e9ac3a..28ac86e13 100644 --- a/sys/src/9/port/chan.c +++ b/sys/src/9/port/chan.c @@ -472,10 +472,10 @@ chanfree(Chan *c) void cclose(Chan *c) { - if(c->flag&CFREE) + if(c == nil || c->ref < 1 || c->flag&CFREE) panic("cclose %#p", getcallerpc(&c)); - DBG("cclose %p name=%s ref=%ld\n", c, c->path->s, c->ref); + DBG("cclose %p name=%s ref=%ld\n", c, chanpath(c), c->ref); if(decref(c)) return; @@ -503,10 +503,10 @@ void closeproc(void*); void ccloseq(Chan *c) { - if(c->flag&CFREE) - panic("cclose %#p", getcallerpc(&c)); + if(c == nil || c->ref < 1 || c->flag&CFREE) + panic("ccloseq %#p", getcallerpc(&c)); - DBG("ccloseq %p name=%s ref=%ld\n", c, c->path->s, c->ref); + DBG("ccloseq %p name=%s ref=%ld\n", c, chanpath(c), c->ref); if(decref(c)) return; @@ -822,6 +822,8 @@ cclone(Chan *c) Chan *nc; Walkqid *wq; + if(c == nil || c->ref < 1 || c->flag&CFREE) + panic("cclone: %#p", getcallerpc(&c)); wq = devtab[c->type]->walk(c, nil, nil, 0); if(wq == nil) error("clone failed"); |