static void call (void *arg) { struct call_args *a = arg; char szDestAddr[FTN_ADDR_SZ + 1]; #if defined(WITH_PERL) && defined(HAVE_THREADS) void *cperl; #endif #if defined(WITH_PERL) && defined(HAVE_THREADS) cperl = perl_init_clone(a->config); #endif if (bsy_add (&a->node->fa, F_CSY, a->config)) { call0 (a->node, a->config); bsy_remove (&a->node->fa, F_CSY, a->config); } else { ftnaddress_to_str (szDestAddr, &a->node->fa); Log (4, "%s busy, skipping", szDestAddr); } #if defined(WITH_PERL) && defined(HAVE_THREADS) perl_done_clone(cperl); #endif unlock_config_structure(a->config, 0); free (arg); rel_grow_handles(-6); #ifdef HAVE_THREADS threadsafe(--n_clients); PostSem(&eothread); if (poll_flag) PostSem(&wakecmgr); _endthread(); #elif defined(DOS) || defined(DEBUGCHILD) --n_clients; #endif }
static void serv (void *arg) { int h = *(int *) arg; BINKD_CONFIG *config; #if defined(WITH_PERL) && defined(HAVE_THREADS) void *cperl; #endif #if defined(HAVE_FORK) && !defined(HAVE_THREADS) && !defined(DEBUGCHILD) int curfd; pidcmgr = 0; for (curfd=0; curfd<sockfd_used; curfd++) soclose(sockfd[curfd]); #endif config = lock_current_config(); #if defined(WITH_PERL) && defined(HAVE_THREADS) cperl = perl_init_clone(config); #endif protocol (h, h, NULL, NULL, NULL, NULL, NULL, config); Log (5, "downing server..."); #if defined(WITH_PERL) && defined(HAVE_THREADS) perl_done_clone(cperl); #endif del_socket(h); soclose (h); free (arg); unlock_config_structure(config, 0); rel_grow_handles (-6); #ifdef HAVE_THREADS threadsafe(--n_servers); PostSem(&eothread); ENDTHREAD(); #elif defined(DOS) || defined(DEBUGCHILD) --n_servers; #endif }
void clientmgr (void *arg) { int status; BINKD_CONFIG *config = NULL; #if defined(WITH_PERL) && defined(HAVE_THREADS) void *cperl = NULL; #endif UNUSED_ARG(arg); #ifdef HAVE_FORK pidcmgr = 0; pidCmgr = (int) getpid(); blocksig(); signal (SIGCHLD, sighandler); #elif HAVE_THREADS pidcmgr = PID(); #endif config = lock_current_config(); #if defined(WITH_PERL) && defined(HAVE_THREADS) if (server_flag) cperl = perl_init_clone(config); #endif setproctitle ("client manager"); Log (4, "clientmgr started"); for (;;) { if (config != current_config) { #if defined(WITH_PERL) && defined(HAVE_THREADS) if (server_flag && cperl) perl_done_clone(cperl); #endif if (config) unlock_config_structure(config, 0); config = lock_current_config(); #if defined(WITH_PERL) && defined(HAVE_THREADS) if (server_flag) cperl = perl_init_clone(config); #endif } status = do_client(config); if (status != 0 || binkd_exit) break; if ( #ifdef HAVE_THREADS !server_flag && #endif !poll_flag) checkcfg(); } Log (5, "downing clientmgr..."); #if defined(WITH_PERL) && defined(HAVE_THREADS) if (server_flag && cperl) perl_done_clone(cperl); #endif unlock_config_structure(config, 0); unblocksig(); #ifdef HAVE_THREADS pidcmgr = 0; PostSem(&eothread); if (binkd_exit) _endthread(); #endif exit (0); }