| | |
| | | #include "util.h" |
| | | #include <atomic> |
| | | |
| | | using namespace bhome::msg; |
| | | using namespace bhome_msg; |
| | | |
| | | namespace |
| | | { |
| | |
| | | const int proc_id_len, |
| | | const void *data, |
| | | const int data_len, |
| | | BHServerCallbackTag *tag) |
| | | void *src) |
| | | { |
| | | // printf("ServerProc: "); |
| | | // DEFER1(printf("\n");); |
| | |
| | | reply.set_data(" reply: " + request.data()); |
| | | std::string s(reply.SerializeAsString()); |
| | | // printf("%s", reply.data().c_str()); |
| | | BHServerCallbackReply(tag, s.data(), s.size()); |
| | | BHSendReply(src, s.data(), s.size()); |
| | | ++Status().nserved_; |
| | | } |
| | | } |
| | |
| | | MsgStatus last; |
| | | while (*run) { |
| | | auto &st = Status(); |
| | | std::this_thread::sleep_for(1s); |
| | | Sleep(1s, false); |
| | | printf("nreq: %8ld, spd %8ld | failed: %8ld | nsrv: %8ld, spd %8ld | nreply: %8ld, spd %8ld\n", |
| | | st.nrequest_.load(), st.nrequest_ - last.nrequest_, |
| | | st.nfailed_.load(), |
| | |
| | | auto hb = [](std::atomic<bool> *run) { |
| | | while (*run) { |
| | | Sleep(1s, false); |
| | | bool r = BHHeartBeatEasy(1000); |
| | | bool r = BHHeartbeatEasy(1000); |
| | | printf("heartbeat: %s\n", r ? "ok" : "failed"); |
| | | } |
| | | }; |
| | |
| | | |
| | | int same = 0; |
| | | int64_t last = 0; |
| | | while (last < nreq * ncli && same < 3) { |
| | | Sleep(1s); |
| | | while (last < nreq * ncli && same < 2) { |
| | | Sleep(1s, false); |
| | | auto cur = Status().nreply_.load(); |
| | | if (last == cur) { |
| | | ++same; |