| 2246 | } |
| 2247 | |
| 2248 | void Socket::DebugSocket(std::ostream& os, SocketId id) { |
| 2249 | SocketUniquePtr ptr; |
| 2250 | int ret = AddressFailedAsWell(id, &ptr); |
| 2251 | if (ret < 0) { |
| 2252 | os << "SocketId=" << id << " is invalid or recycled"; |
| 2253 | return; |
| 2254 | } else if (ret > 0) { |
| 2255 | // NOTE: Printing a broken socket w/o HC is informational for |
| 2256 | // debugging referential issues. |
| 2257 | // if (ptr->_health_check_interval_s <= 0) { |
| 2258 | // // Sockets without HC will soon be destroyed |
| 2259 | // os << "Invalid SocketId=" << id; |
| 2260 | // return; |
| 2261 | // } |
| 2262 | os << "# This is a broken Socket\n"; |
| 2263 | } |
| 2264 | const uint64_t vref = ptr->versioned_ref(); |
| 2265 | size_t npipelined = 0; |
| 2266 | size_t idsizes[4]; |
| 2267 | size_t nidsize = 0; |
| 2268 | { |
| 2269 | BAIDU_SCOPED_LOCK(ptr->_pipeline_mutex); |
| 2270 | if (ptr->_pipeline_q) { |
| 2271 | npipelined = ptr->_pipeline_q->size(); |
| 2272 | } |
| 2273 | } |
| 2274 | { |
| 2275 | BAIDU_SCOPED_LOCK(ptr->_id_wait_list_mutex); |
| 2276 | if (bthread::get_sizes) { |
| 2277 | nidsize = bthread::get_sizes( |
| 2278 | &ptr->_id_wait_list, idsizes, arraysize(idsizes)); |
| 2279 | } |
| 2280 | } |
| 2281 | const int preferred_index = ptr->preferred_index(); |
| 2282 | SharedPart* sp = ptr->GetSharedPart(); |
| 2283 | os << "version=" << VersionOfVRef(vref); |
| 2284 | if (sp) { |
| 2285 | os << "\nshared_part={\n ref_count=" << sp->ref_count() |
| 2286 | << "\n socket_pool="; |
| 2287 | SocketPool* pool = sp->socket_pool.load(butil::memory_order_consume); |
| 2288 | if (pool) { |
| 2289 | os << '['; |
| 2290 | std::vector<SocketId> pooled_sockets; |
| 2291 | pool->ListSockets(&pooled_sockets, 0); |
| 2292 | for (size_t i = 0; i < pooled_sockets.size(); ++i) { |
| 2293 | if (i) { |
| 2294 | os << ' '; |
| 2295 | } |
| 2296 | os << pooled_sockets[i]; |
| 2297 | } |
| 2298 | os << "]\n numfree=" |
| 2299 | << pool->_numfree.load(butil::memory_order_relaxed) |
| 2300 | << "\n numinflight=" |
| 2301 | << pool->_numinflight.load(butil::memory_order_relaxed); |
| 2302 | } else { |
| 2303 | os << "null"; |
| 2304 | } |
| 2305 | os << "\n creator_socket=" << sp->creator_socket_id |
nothing calls this directly
no test coverage detected