Fixes for mbtask

This commit is contained in:
Michiel Broek 2006-02-15 19:56:26 +00:00
parent 17fda57677
commit fb9122255c
7 changed files with 69 additions and 87 deletions

View File

@ -9,6 +9,10 @@ v0.83.13 13-Feb-2006
mbcico: mbcico:
Added real error message for failed outgoing IP connections. Added real error message for failed outgoing IP connections.
mbtask:
Fixed startup problem on new installations.
Some code cleanup.
v0.83.12 06-Feb-2006 - 13-Feb-2006 v0.83.12 06-Feb-2006 - 13-Feb-2006

View File

@ -112,16 +112,9 @@ extern int ipmailers; /* TCP/IP mail sessions */
extern int tosswait; /* Toss wait timer */ extern int tosswait; /* Toss wait timer */
extern pid_t mypid; /* Pid of daemon */ extern pid_t mypid; /* Pid of daemon */
int G_Shutdown = FALSE; /* Global shutdown */ int G_Shutdown = FALSE; /* Global shutdown */
int T_Shutdown = FALSE; /* Shutdown threads */
int nodaemon = FALSE; /* Run in foreground */ int nodaemon = FALSE; /* Run in foreground */
extern time_t resettime; /* IBC reset time */ extern time_t resettime; /* IBC reset time */
int Run_IBC = TRUE; /* Run IBC server */
/*
* Global thread vaiables
*/
pthread_t pt_ping;
@ -797,13 +790,9 @@ void die(int onsig)
/* /*
* Disconnect chatservers * Disconnect chatservers
*/ */
if (Run_IBC)
ibc_shutdown(); ibc_shutdown();
/*
* Now stop the threads
*/
T_Shutdown = TRUE;
/* /*
* Free memory * Free memory
*/ */
@ -1052,6 +1041,7 @@ void start_scheduler(int port)
/* /*
* Setup IBC socket * Setup IBC socket
*/ */
if (Run_IBC) {
myaddr_in.sin_family = AF_INET; myaddr_in.sin_family = AF_INET;
myaddr_in.sin_addr.s_addr = INADDR_ANY; myaddr_in.sin_addr.s_addr = INADDR_ANY;
myaddr_in.sin_port = port; myaddr_in.sin_port = port;
@ -1070,6 +1060,7 @@ void start_scheduler(int port)
srand(getpid()); srand(getpid());
resettime = time(NULL) + (time_t)86400; resettime = time(NULL) + (time_t)86400;
}
/* /*
* The flag masterinit is set if a new config.data is created, this * The flag masterinit is set if a new config.data is created, this
@ -1173,7 +1164,8 @@ void scheduler(void)
do_cmd(buf); do_cmd(buf);
} }
} }
if (pfd[1].revents & POLLIN || pfd[1].revents & POLLERR || pfd[1].revents & POLLHUP || pfd[1].revents & POLLNVAL) { if ((pfd[1].revents & POLLIN || pfd[1].revents & POLLERR ||
pfd[1].revents & POLLHUP || pfd[1].revents & POLLNVAL) && Run_IBC) {
sl = sizeof(myaddr_in); sl = sizeof(myaddr_in);
memset(&clientaddr_in, 0, sizeof(struct sockaddr_in)); memset(&clientaddr_in, 0, sizeof(struct sockaddr_in));
memset(&crbuf, 0, sizeof(crbuf)); memset(&crbuf, 0, sizeof(crbuf));
@ -1199,7 +1191,9 @@ void scheduler(void)
/* /*
* Check all registered connections and semafore's * Check all registered connections and semafore's
*/ */
if (Run_IBC)
check_servers(); check_servers();
reg_check(); reg_check();
check_sema(); check_sema();
check_ports(); check_ports();
@ -1605,24 +1599,6 @@ int main(int argc, char **argv)
if (nodaemon) if (nodaemon)
printf("main config loaded\n"); printf("main config loaded\n");
if ((se = getservbyname("fido", "udp")) == NULL) {
fprintf(stderr, "IBC: no fido udp entry in /etc/services, cannot start Internet BBS Chat\n");
close(ping_isocket);
exit(MBERR_INIT_ERROR);
}
if (strlen(CFG.bbs_name) == 0) {
fprintf(stderr, "IBC: mbsetup 1.2.1 is empty, cannot start Internet BBS Chat\n");
close(ping_isocket);
exit(MBERR_INIT_ERROR);
}
if (strlen(CFG.myfqdn) == 0) {
fprintf(stderr, "IBC: mbsetup 1.2.10 is empty, cannot start Internet BBS Chat\n");
close(ping_isocket);
exit(MBERR_INIT_ERROR);
}
mypid = getpid(); mypid = getpid();
if (nodaemon) if (nodaemon)
printf("my pid is %d\n", mypid); printf("my pid is %d\n", mypid);
@ -1638,6 +1614,17 @@ int main(int argc, char **argv)
status_init(); status_init();
if ((se = getservbyname("fido", "udp")) == NULL) {
WriteError("IBC: no fido udp entry in /etc/services, cannot start Internet BBS Chat");
Run_IBC = FALSE;
} else if (strlen(CFG.bbs_name) == 0) {
WriteError("IBC: mbsetup 1.2.1 is empty, cannot start Internet BBS Chat");
Run_IBC = FALSE;
} else if (strlen(CFG.myfqdn) == 0) {
Run_IBC = FALSE;
WriteError("IBC: mbsetup 1.2.10 is empty, cannot start Internet BBS Chat");
}
memset(&task, 0, sizeof(task)); memset(&task, 0, sizeof(task));
memset(&reginfo, 0, sizeof(reginfo)); memset(&reginfo, 0, sizeof(reginfo));
memset(&calllist, 0, sizeof(calllist)); memset(&calllist, 0, sizeof(calllist));
@ -1718,7 +1705,6 @@ int main(int argc, char **argv)
} }
free(lockfile); free(lockfile);
Syslog('+', "Starting daemon with pid %d", frk); Syslog('+', "Starting daemon with pid %d", frk);
pthread_exit(NULL);
exit(MBERR_OK); exit(MBERR_OK);
} }
} }

View File

@ -401,12 +401,11 @@ void deinit_ping(void)
int rc; int rc;
if ((rc = close(ping_isocket))) { if ((rc = close(ping_isocket))) {
WriteError("$ping thread error socket close"); WriteError("$ping loop error socket close");
} }
ping_isocket = -1; ping_isocket = -1;
Syslog('+', "Ping thread stopped"); Syslog('+', "Ping loop stopped");
} }

View File

@ -71,6 +71,8 @@ extern chn_list *channels; /* Connected channels */
extern int usrchg; extern int usrchg;
extern int chnchg; extern int chnchg;
extern int srvchg; extern int srvchg;
extern int Run_IBC;
/* /*
@ -394,6 +396,11 @@ void chat_connect_r(char *data, char *buf)
Syslog('c', "CCON:%s", data); Syslog('c', "CCON:%s", data);
if (! Run_IBC) {
snprintf(buf, 200, "100:1,*** Chatserver not configured;");
return;
}
if (IsSema((char *)"upsalarm")) { if (IsSema((char *)"upsalarm")) {
snprintf(buf, 200, "100:1,*** Power failure, running on UPS;"); snprintf(buf, 200, "100:1,*** Power failure, running on UPS;");
return; return;

View File

@ -45,7 +45,6 @@ extern int sock; /* Server socket */
extern struct sockaddr_un from; /* From socket address */ extern struct sockaddr_un from; /* From socket address */
extern int fromlen; /* From address length */ extern int fromlen; /* From address length */
extern int logtrans; /* Log transactions */ extern int logtrans; /* Log transactions */
extern int T_Shutdown; /* Program shutdown */

View File

@ -1460,9 +1460,7 @@ int command_part(char *hostname, char *parameters)
} }
} }
// Syslog('r', "IBC: part input server=%s nick=%s", server, nick);
for (tmpu = users; tmpu; tmpu = tmpu->next) { for (tmpu = users; tmpu; tmpu = tmpu->next) {
// Syslog('r', "IBC: part test server=%s nick=%s name=%s", tmpu->server, tmpu->nick, tmpu->name);
if ((strcmp(tmpu->server, server) == 0) && ((strcmp(tmpu->nick, nick) == 0) || (strcmp(tmpu->name, nick) == 0))) { if ((strcmp(tmpu->server, server) == 0) && ((strcmp(tmpu->nick, nick) == 0) || (strcmp(tmpu->name, nick) == 0))) {
tmpu->channel[0] = '\0'; tmpu->channel[0] = '\0';
if (message) { if (message) {

View File

@ -46,7 +46,6 @@ unsigned int lcrc = 0, tcrc = 1;
int lcnt = 0, lchr; int lcnt = 0, lchr;
static char *pbuff = NULL; static char *pbuff = NULL;
pthread_mutex_t l_mutex = PTHREAD_MUTEX_INITIALIZER;
static char *mon[] = { static char *mon[] = {
@ -87,12 +86,6 @@ void Syslog(int grade, const char *format, ...)
time_t now; time_t now;
struct tm ptm; struct tm ptm;
if (pthread_mutex_lock(&l_mutex)) {
perror("");
printf("Syslog mutex_lock l_nutex failed\n");
return;
}
debug = isalpha(grade); debug = isalpha(grade);
va_start(va_ptr, format); va_start(va_ptr, format);
vsnprintf(outstr, 1024, format, va_ptr); vsnprintf(outstr, 1024, format, va_ptr);
@ -101,7 +94,6 @@ void Syslog(int grade, const char *format, ...)
tcrc = StringCRC32(outstr); tcrc = StringCRC32(outstr);
if (tcrc == lcrc) { if (tcrc == lcrc) {
lcnt++; lcnt++;
pthread_mutex_unlock(&l_mutex);
return; return;
} }
lcrc = tcrc; lcrc = tcrc;
@ -113,7 +105,6 @@ void Syslog(int grade, const char *format, ...)
umask(oldmask); umask(oldmask);
if (logfile == NULL) { if (logfile == NULL) {
printf("Can't open logfile \"%s\"\n", lname); printf("Can't open logfile \"%s\"\n", lname);
pthread_mutex_unlock(&l_mutex);
return; return;
} }
} }
@ -127,7 +118,6 @@ void Syslog(int grade, const char *format, ...)
if (!debug) { if (!debug) {
fclose(logfile); fclose(logfile);
} }
pthread_mutex_unlock(&l_mutex);
return; return;
} }
@ -169,7 +159,6 @@ void Syslog(int grade, const char *format, ...)
printf("Can't close logfile \"%s\"\n", CFG.debuglog); printf("Can't close logfile \"%s\"\n", CFG.debuglog);
lchr = grade; lchr = grade;
pthread_mutex_unlock(&l_mutex);
return; return;
} }