OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace-cog commits / 1155c68

Fix the barrier, again...
1155c68411bdfb043d9a27d5c6199318b37f931e
by Linas Vepstas <linasvepstas@gmail.com> · 2025-12-07T00:25:40.000Z

Changed files (1) +8 -12

opencog/persist/cog-storage/CogChannel.cc +8 -12
……@@ -388,22 +388,18 @@ void CogChannel<Client, Data>::reply_handler(const Msg& msg)
388388template<typename Client, typename Data>
389389void CogChannel<Client, Data>::barrier()
390390{
391 // Drain work queues.
392 _msg_buffer.barrier();
393
394 // Server can complete barrier only after it receives it on
395 // all of the open sockets; the random string is the uuid to
396 // disambiguate this barrier from any others that might get
397 // issued. The barrier is retired after all N of them are received.
391 // Generate a unique barrier ID
398392 static thread_local std::minstd_rand rng(std::random_device{}());
399393 uint64_t rnd = (uint64_t(rng()) << 32) | rng();
400394
401 std::lock_guard<std::mutex> lck(_sock_set_mtx);
395 // Build the barrier message. Each worker thread will send this,
396 // opening its socket if needed. Server completes when all N arrive.
402397 char msg[64];
403 snprintf(msg, sizeof(msg), "(cog-barrier %zu \"%016lx\")\n",
404 _open_socks.size(), rnd);
405 for (int sockfd : _open_socks)
406 send(sockfd, msg, strlen(msg), MSG_NOSIGNAL);
398 snprintf(msg, sizeof(msg), "(cog-barrier %u \"%016lx\")\n", NTHREADS, rnd);
399
400 Data dummy = Data();
401 Msg block{nullptr, nullptr, true, msg, dummy};
402 _msg_buffer.barrier(block);
407403}
408404
409405template<typename Client, typename Data>