From d874cf6cf9bc5758b1233066a72aa717fa89e552 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sun, 17 Jun 2007 05:31:28 +0000 Subject: [PATCH] cleanup testing analog git-svn-id: http://svn.openzap.org/svn/openzap/trunk@269 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/openzap/src/zap_io.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/openzap/src/zap_io.c b/libs/openzap/src/zap_io.c index 22bd482a9b..019592ad99 100644 --- a/libs/openzap/src/zap_io.c +++ b/libs/openzap/src/zap_io.c @@ -522,6 +522,7 @@ zap_status_t zap_channel_set_state(zap_channel_t *zchan, zap_channel_state_t sta ok = 0; switch(state) { case ZAP_CHANNEL_STATE_DOWN: + case ZAP_CHANNEL_STATE_BUSY: ok = 1; break; default: @@ -716,8 +717,10 @@ static zap_status_t zap_channel_reset(zap_channel_t *zchan) zap_status_t zap_channel_open_chan(zap_channel_t *zchan) { zap_status_t status = ZAP_FAIL; - - if ((status = zap_mutex_trylock(zchan->mutex)) != ZAP_SUCCESS) { + + assert(zchan != NULL); + + if (!zap_test_flag(zchan, ZAP_CHANNEL_READY) || (status = zap_mutex_trylock(zchan->mutex)) != ZAP_SUCCESS) { return status; } @@ -745,7 +748,7 @@ zap_status_t zap_channel_open(uint32_t span_id, uint32_t chan_id, zap_channel_t check = &globals.spans[span_id].channels[chan_id]; - if ((status = zap_mutex_trylock(check->mutex)) != ZAP_SUCCESS) { + if (!zap_test_flag(check, ZAP_CHANNEL_READY) || (status = zap_mutex_trylock(check->mutex)) != ZAP_SUCCESS) { goto done; }