static gboolean RpcInStart(RpcChannel *chan) { gboolean ret = TRUE; BackdoorChannel *bdoor = chan->_private; if (bdoor->outStarted) { /* Already started. Make sure both channels are in sync and return. */ ASSERT(bdoor->in == NULL || bdoor->inStarted); return ret; } else { ASSERT(bdoor->in == NULL || !bdoor->inStarted); } if (bdoor->in != NULL) { ret = RpcIn_start(bdoor->in, RPCIN_MAX_DELAY, RpcChannel_Error, chan); } if (ret) { ret = RpcOut_start(bdoor->out); if (!ret) { RpcIn_stop(bdoor->in); } } bdoor->inStarted = (bdoor->in != NULL); bdoor->outStarted = TRUE; return ret; }
void RpcChannel_Shutdown(RpcChannel *chan) { if (chan != NULL) { g_static_mutex_free(&chan->outLock); } if (chan != NULL && chan->funcs != NULL && chan->funcs->shutdown != NULL) { if (chan->in != NULL) { if (chan->inStarted) { RpcIn_stop(chan->in); } chan->inStarted = FALSE; RpcIn_Destruct(chan->in); chan->in = NULL; } else { ASSERT(!chan->inStarted); } if (chan->mainCtx != NULL) { g_main_context_unref(chan->mainCtx); } chan->funcs->shutdown(chan); } }
static void RpcInStop(RpcChannel *chan) { BackdoorChannel *bdoor = chan->_private; g_static_mutex_lock(&bdoor->outLock); if (bdoor->out != NULL) { if (bdoor->outStarted) { RpcOut_stop(bdoor->out); } bdoor->outStarted = FALSE; } else { ASSERT(!bdoor->outStarted); } g_static_mutex_unlock(&bdoor->outLock); if (bdoor->in != NULL) { if (bdoor->inStarted) { RpcIn_stop(bdoor->in); } bdoor->inStarted = FALSE; } else { ASSERT(!bdoor->inStarted); } }
static gboolean BkdoorChannelStart(RpcChannel *chan) { gboolean ret = TRUE; BackdoorChannel *bdoor = chan->_private; ret = chan->in == NULL || chan->inStarted; if (ret) { ret = RpcOut_start(bdoor->out); if (!ret) { if (chan->inStarted) { RpcIn_stop(chan->in); chan->inStarted = FALSE; } } } chan->outStarted = ret; return ret; }
void RpcChannel_Stop(RpcChannel *chan) { g_return_if_fail(chan != NULL); g_return_if_fail(chan->funcs != NULL); g_return_if_fail(chan->funcs->stop != NULL); g_static_mutex_lock(&chan->outLock); chan->funcs->stop(chan); if (chan->in != NULL) { if (chan->inStarted) { RpcIn_stop(chan->in); } chan->inStarted = FALSE; } else { ASSERT(!chan->inStarted); } g_static_mutex_unlock(&chan->outLock); }