Fixes for mbtask
This commit is contained in:
parent
17fda57677
commit
fb9122255c
@ -9,6 +9,10 @@ v0.83.13 13-Feb-2006
|
||||
mbcico:
|
||||
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
|
||||
|
||||
|
@ -112,16 +112,9 @@ extern int ipmailers; /* TCP/IP mail sessions */
|
||||
extern int tosswait; /* Toss wait timer */
|
||||
extern pid_t mypid; /* Pid of daemon */
|
||||
int G_Shutdown = FALSE; /* Global shutdown */
|
||||
int T_Shutdown = FALSE; /* Shutdown threads */
|
||||
int nodaemon = FALSE; /* Run in foreground */
|
||||
extern time_t resettime; /* IBC reset time */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Global thread vaiables
|
||||
*/
|
||||
pthread_t pt_ping;
|
||||
int Run_IBC = TRUE; /* Run IBC server */
|
||||
|
||||
|
||||
|
||||
@ -797,12 +790,8 @@ void die(int onsig)
|
||||
/*
|
||||
* Disconnect chatservers
|
||||
*/
|
||||
ibc_shutdown();
|
||||
|
||||
/*
|
||||
* Now stop the threads
|
||||
*/
|
||||
T_Shutdown = TRUE;
|
||||
if (Run_IBC)
|
||||
ibc_shutdown();
|
||||
|
||||
/*
|
||||
* Free memory
|
||||
@ -1052,25 +1041,27 @@ void start_scheduler(int port)
|
||||
/*
|
||||
* Setup IBC socket
|
||||
*/
|
||||
myaddr_in.sin_family = AF_INET;
|
||||
myaddr_in.sin_addr.s_addr = INADDR_ANY;
|
||||
myaddr_in.sin_port = port;
|
||||
Syslog('+', "IBC: listen on %s, port %d", inet_ntoa(myaddr_in.sin_addr), ntohs(myaddr_in.sin_port));
|
||||
if (Run_IBC) {
|
||||
myaddr_in.sin_family = AF_INET;
|
||||
myaddr_in.sin_addr.s_addr = INADDR_ANY;
|
||||
myaddr_in.sin_port = port;
|
||||
Syslog('+', "IBC: listen on %s, port %d", inet_ntoa(myaddr_in.sin_addr), ntohs(myaddr_in.sin_port));
|
||||
|
||||
ibcsock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (ibcsock == -1) {
|
||||
WriteError("$IBC: can't create listen socket");
|
||||
die(MBERR_INIT_ERROR);
|
||||
ibcsock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (ibcsock == -1) {
|
||||
WriteError("$IBC: can't create listen socket");
|
||||
die(MBERR_INIT_ERROR);
|
||||
}
|
||||
|
||||
if (bind(ibcsock, (struct sockaddr *)&myaddr_in, sizeof(struct sockaddr_in)) == -1) {
|
||||
WriteError("$IBC: can't bind listen socket");
|
||||
die(MBERR_INIT_ERROR);
|
||||
}
|
||||
|
||||
srand(getpid());
|
||||
resettime = time(NULL) + (time_t)86400;
|
||||
}
|
||||
|
||||
if (bind(ibcsock, (struct sockaddr *)&myaddr_in, sizeof(struct sockaddr_in)) == -1) {
|
||||
WriteError("$IBC: can't bind listen socket");
|
||||
die(MBERR_INIT_ERROR);
|
||||
}
|
||||
|
||||
srand(getpid());
|
||||
resettime = time(NULL) + (time_t)86400;
|
||||
|
||||
/*
|
||||
* The flag masterinit is set if a new config.data is created, this
|
||||
* is true if mbtask is started the very first time. Then we run
|
||||
@ -1173,7 +1164,8 @@ void scheduler(void)
|
||||
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);
|
||||
memset(&clientaddr_in, 0, sizeof(struct sockaddr_in));
|
||||
memset(&crbuf, 0, sizeof(crbuf));
|
||||
@ -1199,7 +1191,9 @@ void scheduler(void)
|
||||
/*
|
||||
* Check all registered connections and semafore's
|
||||
*/
|
||||
check_servers();
|
||||
if (Run_IBC)
|
||||
check_servers();
|
||||
|
||||
reg_check();
|
||||
check_sema();
|
||||
check_ports();
|
||||
@ -1605,24 +1599,6 @@ int main(int argc, char **argv)
|
||||
if (nodaemon)
|
||||
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();
|
||||
if (nodaemon)
|
||||
printf("my pid is %d\n", mypid);
|
||||
@ -1638,6 +1614,17 @@ int main(int argc, char **argv)
|
||||
|
||||
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(®info, 0, sizeof(reginfo));
|
||||
memset(&calllist, 0, sizeof(calllist));
|
||||
@ -1718,7 +1705,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
free(lockfile);
|
||||
Syslog('+', "Starting daemon with pid %d", frk);
|
||||
pthread_exit(NULL);
|
||||
exit(MBERR_OK);
|
||||
}
|
||||
}
|
||||
|
@ -401,12 +401,11 @@ void deinit_ping(void)
|
||||
int rc;
|
||||
|
||||
if ((rc = close(ping_isocket))) {
|
||||
WriteError("$ping thread error socket close");
|
||||
WriteError("$ping loop error socket close");
|
||||
}
|
||||
ping_isocket = -1;
|
||||
|
||||
Syslog('+', "Ping thread stopped");
|
||||
Syslog('+', "Ping loop stopped");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -71,6 +71,8 @@ extern chn_list *channels; /* Connected channels */
|
||||
extern int usrchg;
|
||||
extern int chnchg;
|
||||
extern int srvchg;
|
||||
extern int Run_IBC;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -394,6 +396,11 @@ void chat_connect_r(char *data, char *buf)
|
||||
|
||||
Syslog('c', "CCON:%s", data);
|
||||
|
||||
if (! Run_IBC) {
|
||||
snprintf(buf, 200, "100:1,*** Chatserver not configured;");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsSema((char *)"upsalarm")) {
|
||||
snprintf(buf, 200, "100:1,*** Power failure, running on UPS;");
|
||||
return;
|
||||
|
@ -45,7 +45,6 @@ extern int sock; /* Server socket */
|
||||
extern struct sockaddr_un from; /* From socket address */
|
||||
extern int fromlen; /* From address length */
|
||||
extern int logtrans; /* Log transactions */
|
||||
extern int T_Shutdown; /* Program shutdown */
|
||||
|
||||
|
||||
|
||||
|
@ -38,25 +38,25 @@
|
||||
|
||||
|
||||
|
||||
extern int internet; /* Internet status */
|
||||
time_t scfg_time = (time_t)0; /* Servers config time */
|
||||
time_t now; /* Current time */
|
||||
ncs_list *ncsl = NULL; /* Neighbours list */
|
||||
srv_list *servers = NULL; /* Active servers */
|
||||
usr_list *users = NULL; /* Active users */
|
||||
chn_list *channels = NULL; /* Active channels */
|
||||
ban_list *banned = NULL; /* Banned users */
|
||||
nick_list *nicknames = NULL; /* Known nicknames */
|
||||
int callchg = FALSE; /* Is call state changed */
|
||||
int srvchg = FALSE; /* Is serverlist changed */
|
||||
int usrchg = FALSE; /* Is userlist changed */
|
||||
int chnchg = FALSE; /* Is channellist changed */
|
||||
int banchg = FALSE; /* Is banned users changed */
|
||||
int nickchg = FALSE; /* Is nicknames changed */
|
||||
time_t resettime; /* Time to reset all */
|
||||
int do_reset = FALSE; /* Reset init */
|
||||
int link_reset = FALSE; /* Reset one link */
|
||||
extern struct sockaddr_in clientaddr_in; /* IBC remote socket */
|
||||
extern int internet; /* Internet status */
|
||||
time_t scfg_time = (time_t)0; /* Servers config time */
|
||||
time_t now; /* Current time */
|
||||
ncs_list *ncsl = NULL; /* Neighbours list */
|
||||
srv_list *servers = NULL; /* Active servers */
|
||||
usr_list *users = NULL; /* Active users */
|
||||
chn_list *channels = NULL; /* Active channels */
|
||||
ban_list *banned = NULL; /* Banned users */
|
||||
nick_list *nicknames = NULL; /* Known nicknames */
|
||||
int callchg = FALSE; /* Is call state changed */
|
||||
int srvchg = FALSE; /* Is serverlist changed */
|
||||
int usrchg = FALSE; /* Is userlist changed */
|
||||
int chnchg = FALSE; /* Is channellist changed */
|
||||
int banchg = FALSE; /* Is banned users changed */
|
||||
int nickchg = FALSE; /* Is nicknames changed */
|
||||
time_t resettime; /* Time to reset all */
|
||||
int do_reset = FALSE; /* Reset init */
|
||||
int link_reset = FALSE; /* Reset one link */
|
||||
extern struct sockaddr_in clientaddr_in; /* IBC remote socket */
|
||||
|
||||
|
||||
#define PING_PONG_LOG 1
|
||||
@ -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) {
|
||||
// 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))) {
|
||||
tmpu->channel[0] = '\0';
|
||||
if (message) {
|
||||
|
@ -46,7 +46,6 @@ unsigned int lcrc = 0, tcrc = 1;
|
||||
int lcnt = 0, lchr;
|
||||
static char *pbuff = NULL;
|
||||
|
||||
pthread_mutex_t l_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
|
||||
static char *mon[] = {
|
||||
@ -87,12 +86,6 @@ void Syslog(int grade, const char *format, ...)
|
||||
time_t now;
|
||||
struct tm ptm;
|
||||
|
||||
if (pthread_mutex_lock(&l_mutex)) {
|
||||
perror("");
|
||||
printf("Syslog mutex_lock l_nutex failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
debug = isalpha(grade);
|
||||
va_start(va_ptr, format);
|
||||
vsnprintf(outstr, 1024, format, va_ptr);
|
||||
@ -101,7 +94,6 @@ void Syslog(int grade, const char *format, ...)
|
||||
tcrc = StringCRC32(outstr);
|
||||
if (tcrc == lcrc) {
|
||||
lcnt++;
|
||||
pthread_mutex_unlock(&l_mutex);
|
||||
return;
|
||||
}
|
||||
lcrc = tcrc;
|
||||
@ -113,7 +105,6 @@ void Syslog(int grade, const char *format, ...)
|
||||
umask(oldmask);
|
||||
if (logfile == NULL) {
|
||||
printf("Can't open logfile \"%s\"\n", lname);
|
||||
pthread_mutex_unlock(&l_mutex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -127,7 +118,6 @@ void Syslog(int grade, const char *format, ...)
|
||||
if (!debug) {
|
||||
fclose(logfile);
|
||||
}
|
||||
pthread_mutex_unlock(&l_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -169,7 +159,6 @@ void Syslog(int grade, const char *format, ...)
|
||||
printf("Can't close logfile \"%s\"\n", CFG.debuglog);
|
||||
|
||||
lchr = grade;
|
||||
pthread_mutex_unlock(&l_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user