From 3526bc5ece38669dec3139c21f83c02ed1e5ccf9 Mon Sep 17 00:00:00 2001 From: Alexey Khromov Date: Mon, 24 Jun 2024 23:23:24 +0300 Subject: [PATCH] Minor debug improvement --- source/bforce/daemon.c | 9 ++++++++- source/bforce/daemon_call.c | 17 ++++++++++++----- source/bforce/logger.c | 8 +++++++- source/bforce/nodelist.c | 5 ++++- source/bforce/sess_call.c | 10 ++++++++-- source/bforce/u_ftn.c | 6 ++++-- 6 files changed, 43 insertions(+), 12 deletions(-) diff --git a/source/bforce/daemon.c b/source/bforce/daemon.c index d50a839..0398c67 100644 --- a/source/bforce/daemon.c +++ b/source/bforce/daemon.c @@ -1011,9 +1011,16 @@ int daemon_run(const char *confname, const char *incname, bool quit) } if( max_modem > 0 ) + { + DEB((D_INFO,"daemon: daemon_modem_queue")); daemon_queue_do(&daemon_queues[MODEM_QUEUE]); - if( max_tcpip > 0 ) + } + + if( max_tcpip > 0 ) + { + DEB((D_INFO,"daemon: daemon_modem_queue")); daemon_queue_do(&daemon_queues[TCPIP_QUEUE]); + } (void)sleep(DAEMON_IDLE_SLEEP); break; diff --git a/source/bforce/daemon_call.c b/source/bforce/daemon_call.c index 4bf2ec6..fe18b80 100644 --- a/source/bforce/daemon_call.c +++ b/source/bforce/daemon_call.c @@ -54,7 +54,7 @@ static int daemon_call_branch(s_sysentry *syst, const char *lockdir, s_modemport s_bforce_opts opts; // TODO: add hiddenline round-robin - opts.hiddline=0; + opts.hiddline = 0; opts.runmode = MODE_CALL_DEFAULT; opts.ipproto = NULL; opts.phone = NULL; @@ -62,7 +62,7 @@ static int daemon_call_branch(s_sysentry *syst, const char *lockdir, s_modemport opts.inetd = 0; opts.connect = NULL; opts.device = NULL; - + DEB((D_DAEMON, "daemon_call: calling call_system from branch")); // log("doing call_system"); return call_system(syst->node.addr, &opts); } @@ -87,8 +87,11 @@ int daemon_call(s_sysentry *syst) /* * Check whether this node is allready locked */ - if( out_bsy_check(syst->node.addr) ) + if( out_bsy_check(syst->node.addr) ) + { + DEB((D_DAEMON, "daemon_call: node locked by .bsy file")); return 0; + } /* * Set state structure to make expressions works properly now @@ -101,6 +104,7 @@ int daemon_call(s_sysentry *syst) if( syst->tcpip == FALSE ) { + DEB((D_DAEMON, "daemon_call: tcpip false - prep modem line")); if( (p_lockdir = conf_string(cf_uucp_lock_directory)) == NULL ) p_lockdir = BFORCE_LOCK_DIR; @@ -110,7 +114,10 @@ int daemon_call(s_sysentry *syst) return 1; } } - + DEB((D_DAEMON, "call %s line %d via %s", + ftn_addrstr(abuf, syst->node.addr), syst->line, + syst->tcpip ? "TCP/IP" : modemport->name)); + log("call %s line %d via %s", ftn_addrstr(abuf, syst->node.addr), syst->line, syst->tcpip ? "TCP/IP" : modemport->name); @@ -138,7 +145,7 @@ int daemon_call(s_sysentry *syst) } /* Now we are in child process */ - + DEB((D_DAEMON, "daemon_call: fork success - calling...")); exit(daemon_call_branch(syst, p_lockdir, modemport)); } diff --git a/source/bforce/logger.c b/source/bforce/logger.c index f3599cf..d62d35b 100644 --- a/source/bforce/logger.c +++ b/source/bforce/logger.c @@ -106,11 +106,15 @@ int log_open(const char *logname, const char *ext, const char *tty) if( logname ) { + DEB((D_INFO,"log_open: Opening log file %s", logname)); + strnxcpy(log_name, logname, sizeof(log_name)); + // May be NULL, so check both if( tty && *tty ) strnxcpy(log_ttyname, tty, sizeof(log_ttyname)); + // May be NULL, so check both if( ext && *ext ) { strnxcpy(log_extension, ext, sizeof(log_extension)); @@ -142,7 +146,9 @@ int log_close(void) if( log_fp ) { - rc = fclose(log_fp); log_fp = NULL; + rc = fclose(log_fp); + DEB((D_INFO,"Closing log file.")); + log_fp = NULL; } return rc; diff --git a/source/bforce/nodelist.c b/source/bforce/nodelist.c index 8357dad..071c1d3 100644 --- a/source/bforce/nodelist.c +++ b/source/bforce/nodelist.c @@ -243,7 +243,7 @@ int nodelist_parsestring(s_node *node, char *str) strnxcpy(node->phone, argv[NODELIST_POSPHONE], sizeof(node->phone)); strnxcpy(node->flags, argv[NODELIST_POSFLAGS], sizeof(node->flags)); node->speed = atoi(argv[NODELIST_POSSPEED]); - + DEB((D_NODELIST, "nodelist: Parsed common values SYS: %s, ZYZ: %s, LOC: %s, PHONE: %s", node->name, node->sysop, node->location, node->phone)); /* * Replace all '_' by space character */ @@ -291,8 +291,11 @@ int nodelist_parsestring(s_node *node, char *str) node->do_ifcico = nodelist_checkflag(node->flags, "IFC") == 0; node->do_telnet = nodelist_checkflag(node->flags, "ITN") == 0; + //TODO: Add more INA flags to array nodelist_flagvalue(node->flags, "INA", node->host); + DEB((D_NODELIST, "nodelist: Parsed inet values IBN: %d, IFC: %d, ITN: %d, INA: %d", node->do_binkp, node->do_ifcico, node->do_telnet, node->host)); + return 0; } diff --git a/source/bforce/sess_call.c b/source/bforce/sess_call.c index b2e897f..4389e3d 100644 --- a/source/bforce/sess_call.c +++ b/source/bforce/sess_call.c @@ -771,7 +771,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts) gotoexit(BFERR_PHONE_UNKNOWN); } } - + DEB((D_EVENT,"sess_call: may use %d must use %d", call_mayuse, call_mustuse)); // snprintf(s, 299, "after IP check: may use %d must use %d", call_mayuse, call_mustuse); // log(s); @@ -807,29 +807,34 @@ int call_system(s_faddr addr, const s_bforce_opts *opts) // try allowed methods and break if rc == 0 rc = -1; - + if( rc && call_mayuse & CALL_STDIO ) { + DEB((D_EVENT,"sess_call: calling stdio")); rc = call_system_quiet(opts->connect, opts->inetd); } if( rc && call_mayuse & CALL_TCPIP_BINKP ) { + DEB((D_EVENT,"sess_call: calling binkp")); rc = call_system_tcpip(CALL_TCPIP_BINKP); } if( rc && call_mayuse & CALL_TCPIP_IFCICO ) { + DEB((D_EVENT,"sess_call: calling ifcico")); rc = call_system_tcpip(CALL_TCPIP_IFCICO); } if( rc && call_mayuse & CALL_TCPIP_TELNET ) { + DEB((D_EVENT,"sess_call: calling telnet")); rc = call_system_tcpip(CALL_TCPIP_TELNET); } if( rc && call_mayuse & CALL_MODEM ) { + DEB((D_EVENT,"sess_call: calling MODEM")); setproctitle("bforce calling %.32s, %.32s", ftn_addrstr(abuf, state.node.addr), state.node.phone); rc = -1; @@ -850,6 +855,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts) if( port_lock(p_lockdir, state.modemport) == 0 ) /* Successfuly locked port */ { + DEB((D_EVENT,"sess_call: call_system_modem running")); rc = call_system_modem(); port_unlock(p_lockdir, state.modemport); } diff --git a/source/bforce/u_ftn.c b/source/bforce/u_ftn.c index 2c595df..aed1368 100644 --- a/source/bforce/u_ftn.c +++ b/source/bforce/u_ftn.c @@ -189,7 +189,8 @@ static int ftn_addrparse_fido(s_faddr *addr, const char *s, bool wildcard) { strnxcpy(addr->domain, string_printable(p), sizeof(addr->domain)); } - + DEB((D_INFO,"u_ftn: Parsed ftn address z:%d, net:%d, node:%d, point:%d", + addr->zone, addr->net, addr->node, addr->point)); return badaddr; } @@ -325,7 +326,8 @@ int ftn_addrparse(s_faddr *addr, const char *s, bool wildcard) addr->net = DEFAULT_NET; addr->node = DEFAULT_NODE; addr->point = 0; - + + DEB((D_INFO, "u_ftn: parsing ftnaddr %s", s)); if( addr->inetform ) badaddr = ftn_addrparse_inet(addr, s, wildcard); else