From c64c54d8e75b9354dc49a7b6b2d326e7dd59eb37 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期四, 15 四月 2021 19:32:16 +0800 Subject: [PATCH] add api; fix send, socknode mem leak. --- box/center_main.cc | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/box/center_main.cc b/box/center_main.cc index 40aed56..5baa409 100644 --- a/box/center_main.cc +++ b/box/center_main.cc @@ -15,17 +15,40 @@ * * ===================================================================================== */ +#include "app_arg.h" #include "box.h" #include "center.h" #include "defs.h" #include "signalhandle.h" +#include <chrono> +#include <thread> +using namespace std::chrono_literals; int center_main(int argc, const char *argv[]) { + AppArg args(argc, argv); + if (args.Has("remove")) { + BHomeShm().Remove(); + return 0; + } + + bool run = true; + auto showStatus = [&]() { + auto init = BHomeShm().get_free_memory(); + uint64_t idx = 0; + while (run) { + std::this_thread::sleep_for(1s); + printf("%8d shared memory: avail : %ld / %ld\n", ++idx, BHomeShm().get_free_memory(), init); + } + }; + std::thread t(showStatus); + BHCenter center(BHomeShm()); center.Start(); + printf("center started ...\n"); WaitForSignals({SIGINT, SIGTERM}); - // BHomeShm().Remove(); // remove ? + run = false; + t.join(); return 0; } -- Gitblit v1.8.0