diff options
author | Natanael Copa <natanael.copa@gmail.com> | 2010-03-03 15:23:08 +0000 |
---|---|---|
committer | Natanael Copa <natanael.copa@gmail.com> | 2010-03-03 15:23:08 +0000 |
commit | d70ad9a3834f53f1fd87fecdc876f3a85100cde4 (patch) | |
tree | db17e43ec1d2734e2dd67a019e88ab782982363b /sircbot.c | |
parent | a1e0c57258e58a6a7b1a4700af72c04b2c221214 (diff) | |
download | sircbot-d70ad9a3834f53f1fd87fecdc876f3a85100cde4.tar.bz2 sircbot-d70ad9a3834f53f1fd87fecdc876f3a85100cde4.tar.xz |
avoid send a "join" flood
Diffstat (limited to 'sircbot.c')
-rw-r--r-- | sircbot.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -316,8 +316,12 @@ static int irc_loop(struct irc_session *sess, struct sircbot_channel *chan, now = time(NULL); /* wait atleast 5 secs before we join a channel */ for (i = 0; i < numchan; i++) - if ((now - chan[i].last_closetime) > 5) + if ((now - chan[i].last_closetime) > 5 + && chan[i].fd < 0) { + printf("DEBUG: joining %s\n", chan[i].name); + chan[i].last_closetime = now; irc_send(sess, "JOIN", chan[i].name); + } irc_reset_pollfds(sess, fds, chan, numchan); @@ -458,13 +462,13 @@ int main(int argc, char *argv[]) signal(SIGTERM, sighandler); openlog("sircbot",0, LOG_DAEMON); - while (!sigterm) { + while (1) { struct irc_session *s = irc_connect(server, port, nick, pass); char buf[256]; if (s == NULL) { log_err(server); - sleep(5); + sleep(10); continue; } @@ -473,6 +477,9 @@ int main(int argc, char *argv[]) /* reset fifos */ for (i = 0; i < argc; i++) close_fifo(&chan[i], 0); + if (sigterm) + break; + sleep(10); } unlink(pidfile); return 0; |