From 0215811dc2517e7213a3cd7423f94710b20b57d1 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 6 May 2008 12:51:19 -0400 Subject: libthread: fix no-receive nbrecv etc. bug (David Jeannot) --- src/libthread/channel.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/libthread') diff --git a/src/libthread/channel.c b/src/libthread/channel.c index 4fdf5e50..cd7750c0 100644 --- a/src/libthread/channel.c +++ b/src/libthread/channel.c @@ -363,8 +363,9 @@ chanrecvp(Channel *c) { void *v; - _chanop(c, CHANRCV, (void*)&v, 1); - return v; + if(_chanop(c, CHANRCV, (void*)&v, 1) > 0) + return v; + return nil; } int @@ -378,8 +379,9 @@ channbrecvp(Channel *c) { void *v; - _chanop(c, CHANRCV, (void*)&v, 0); - return v; + if(_chanop(c, CHANRCV, (void*)&v, 0) > 0) + return v; + return nil; } int @@ -393,8 +395,9 @@ chanrecvul(Channel *c) { ulong val; - _chanop(c, CHANRCV, &val, 1); - return val; + if(_chanop(c, CHANRCV, &val, 1) > 0) + return val; + return -1; } int @@ -408,7 +411,8 @@ channbrecvul(Channel *c) { ulong val; - _chanop(c, CHANRCV, &val, 0); - return val; + if(_chanop(c, CHANRCV, &val, 0) > 0) + return val; + return -1; } -- cgit v1.2.3