MCPcopy Create free account
hub / github.com/acl-dev/acl / main_fiber_monitor_master

Function main_fiber_monitor_master

lib_fiber/cpp/src/fiber_server.cpp:376–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374#if !defined(_WIN32) && !defined(_WIN64)
375
376static void main_fiber_monitor_master(ACL_FIBER *fiber, void *ctx)
377{
378 ACL_VSTREAM *stat_stream = (ACL_VSTREAM *) ctx;
379 char buf[8192];
380 int ret, n = 0;
381
382 stat_stream->rw_timeout = -1;
383 ret = acl_vstream_read(stat_stream, buf, sizeof(buf));
384 acl_msg_info("%s(%d), %s: disconnect(%d) from acl_master, clients %lld",
385 __FILE__, __LINE__, __FUNCTION__, ret,
386 acl_atomic_clock_users(__clock));
387
388 /* must close listening as quickly as possible, so that acl_master
389 * can rebind the addr quickly.
390 */
391 acl_msg_info("%s(%d), %s: stopping listen ...",
392 __FILE__, __LINE__, __FUNCTION__);
393 main_stop_listen();
394 acl_msg_info("%s(%d), %s: stop listen ok",
395 __FILE__, __LINE__, __FUNCTION__);
396
397 /* the user's callback will be called here */
398 if (__service_preexit) {
399 while (true) {
400 acl_msg_info("%s(%d), %s: calling server_pre_exit ...",
401 __FILE__, __LINE__, __FUNCTION__);
402
403 if (__service_preexit(__service_ctx)) {
404 break;
405 }
406
407 acl_fiber_sleep(1);
408 }
409
410 acl_msg_info("%s(%d), %s: server_pre_exit ok",
411 __FILE__, __LINE__, __FUNCTION__);
412 }
413
414 while (!acl_var_fiber_quick_abort) {
415 if (acl_atomic_clock_users(__clock) <= 0) {
416 acl_msg_warn("%s(%d), %s: all clients closed!",
417 __FILE__, __LINE__, __FUNCTION__);
418 break;
419 }
420
421 acl_fiber_sleep(1);
422 n++;
423
424 if (acl_var_fiber_wait_limit > 0
425 && n >= acl_var_fiber_wait_limit) {
426
427 acl_msg_warn("%s(%d), %s: too long, clients: %lld",
428 __FILE__, __LINE__, __FUNCTION__,
429 acl_atomic_clock_users(__clock));
430 break;
431 }
432
433 acl_msg_info("%s(%d), %s: waiting %d, clients %lld",

Callers

nothing calls this directly

Calls 10

acl_vstream_readFunction · 0.85
acl_msg_infoFunction · 0.85
acl_atomic_clock_usersFunction · 0.85
main_stop_listenFunction · 0.85
acl_msg_warnFunction · 0.85
main_server_onexitFunction · 0.85
main_stop_serversFunction · 0.85
main_free_serversFunction · 0.85
main_server_exitFunction · 0.70
acl_fiber_sleepFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…