diff options
-rw-r--r-- | fnet/src/vespa/fnet/frt/rpcrequest.cpp | 5 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/frt/target.h | 2 | ||||
-rw-r--r-- | vespalib/src/tests/executor/threadstackexecutor_test.cpp | 4 | ||||
-rw-r--r-- | vespamalloc/src/tests/thread/thread.cpp | 4 |
4 files changed, 8 insertions, 7 deletions
diff --git a/fnet/src/vespa/fnet/frt/rpcrequest.cpp b/fnet/src/vespa/fnet/frt/rpcrequest.cpp index 9553a967413..6214970f2fa 100644 --- a/fnet/src/vespa/fnet/frt/rpcrequest.cpp +++ b/fnet/src/vespa/fnet/frt/rpcrequest.cpp @@ -128,8 +128,9 @@ FRT_RPCRequest::Recycle() void FRT_RPCRequest::SubRef() { - assert(_refcnt > 0); - if (_refcnt.fetch_sub(1) == 1) { + int oldVal = _refcnt.fetch_sub(1); + assert(oldVal > 1); + if (oldVal == 1) { Reset(); delete this; } diff --git a/fnet/src/vespa/fnet/frt/target.h b/fnet/src/vespa/fnet/frt/target.h index 00834417122..d00f906e982 100644 --- a/fnet/src/vespa/fnet/frt/target.h +++ b/fnet/src/vespa/fnet/frt/target.h @@ -29,7 +29,7 @@ public: FNET_Connection *GetConnection() const { return _conn; } - void AddRef() { _refcnt++; } + void AddRef() { _refcnt.fetch_add(1); } void SubRef() { if (_refcnt.fetch_sub(1) == 1) { delete this; diff --git a/vespalib/src/tests/executor/threadstackexecutor_test.cpp b/vespalib/src/tests/executor/threadstackexecutor_test.cpp index 3e092ef145f..db3c4628d2f 100644 --- a/vespalib/src/tests/executor/threadstackexecutor_test.cpp +++ b/vespalib/src/tests/executor/threadstackexecutor_test.cpp @@ -17,12 +17,12 @@ struct MyTask : public Executor::Task { static std::atomic<uint32_t> deleteCnt; MyTask(Gate &g, CountDownLatch &l) : gate(g), latch(l) {} void run() override { - runCnt++; + runCnt.fetch_add(1); latch.countDown(); gate.await(); } ~MyTask() { - deleteCnt++; + deleteCnt.fetch_add(1); } static void resetStats() { runCnt = 0; diff --git a/vespamalloc/src/tests/thread/thread.cpp b/vespamalloc/src/tests/thread/thread.cpp index 3a4fa366c38..b121f1e513b 100644 --- a/vespamalloc/src/tests/thread/thread.cpp +++ b/vespamalloc/src/tests/thread/thread.cpp @@ -54,11 +54,11 @@ void * just_wait(void * arg) { wait_info * info = (wait_info *) arg; pthread_mutex_lock(&info->_mutex); - info->_count++; + info->_count.fetch_add(1); pthread_cond_wait(&info->_cond, &info->_mutex); pthread_mutex_unlock(&info->_mutex); pthread_cond_signal(&info->_cond); - info->_count--; + info->_count.fetch_sub(1); return arg; } |