Commit 9b2efcc7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1b236e16
......@@ -289,30 +289,30 @@ StreamID _WatchLink::_nextReqID() {
}
tuple</*rxq*/chan<rxPkt>, error> _WatchLink::_sendReq(context::Context ctx, const string &req) {
_WatchLink *wlink = this;
_WatchLink& wlink = *this;
// XXX errctx?
StreamID stream = wlink->_nextReqID();
StreamID stream = wlink._nextReqID();
auto rxq = makechan<rxPkt>(1);
wlink->_rxmu.lock();
if (wlink->_rxdown) {
wlink->_rxmu.unlock();
wlink._rxmu.lock();
if (wlink._rxdown) {
wlink._rxmu.unlock();
return make_tuple(nil, ErrLinkDown);
}
if (wlink->_rxtab.has(stream)) {
wlink->_rxmu.unlock();
if (wlink._rxtab.has(stream)) {
wlink._rxmu.unlock();
panic("BUG: to-be-sent stream is present in rxtab");
}
wlink->_rxtab[stream] = rxq;
wlink->_rxmu.unlock();
wlink._rxtab[stream] = rxq;
wlink._rxmu.unlock();
error err = wlink->_send(stream, req);
error err = wlink._send(stream, req);
if (err != nil) {
// remove rxq from rxtab
wlink->_rxmu.lock();
wlink->_rxtab.erase(stream);
wlink->_rxmu.unlock();
wlink._rxmu.lock();
wlink._rxtab.erase(stream);
wlink._rxmu.unlock();
// no need to drain rxq - it was created with cap=1
rxq = nil;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment