| 115 | } |
| 116 | |
| 117 | static void handle_response(brpc::Controller* cntl, int64_t start_time, |
| 118 | bool sleep_on_error/*note*/) { |
| 119 | // TODO(gejun): some bthreads are starved when new bthreads are created |
| 120 | // continuously, which happens when server is down and RPC keeps failing. |
| 121 | // Sleep a while on error to avoid that now. |
| 122 | const int64_t end_time = butil::cpuwide_time_us(); |
| 123 | const int64_t elp = end_time - start_time; |
| 124 | if (!cntl->Failed()) { |
| 125 | g_latency_recorder << elp; |
| 126 | } else { |
| 127 | g_error_count << 1; |
| 128 | if (sleep_on_error) { |
| 129 | bthread_usleep(10000); |
| 130 | } |
| 131 | } |
| 132 | delete cntl; |
| 133 | } |
| 134 | |
| 135 | butil::atomic<int> g_thread_offset(0); |
| 136 |
no test coverage detected