]> jfr.im git - irc/rqf/shadowircd.git/blame - src/ircd.c
Fix an off by one error with zipstats processing
[irc/rqf/shadowircd.git] / src / ircd.c
CommitLineData
212380e3 1/*
b1d6fa8c 2 * charybdis: A slightly useful ircd.
212380e3 3 * ircd.c: Starts up and runs the ircd.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
b1d6fa8c
VY
7 * Copyright (C) 2002-2008 ircd-ratbox development team
8 * Copyright (C) 2005-2008 charybdis development team
212380e3 9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
b1d6fa8c 25 * $Id$
212380e3 26 */
27
7bab07d4 28#include "ratbox_lib.h"
212380e3 29#include "stdinc.h"
30#include "setup.h"
31#include "config.h"
212380e3 32#include "ircd.h"
33#include "channel.h"
34#include "class.h"
35#include "client.h"
36#include "common.h"
212380e3 37#include "hash.h"
13ae2f4b 38#include "match.h"
212380e3 39#include "ircd_signal.h"
212380e3 40#include "msg.h" /* msgtab */
41#include "hostmask.h"
42#include "numeric.h"
43#include "parse.h"
44#include "res.h"
45#include "restart.h"
46#include "s_auth.h"
212380e3 47#include "s_conf.h"
d3455e2c 48#include "logger.h"
212380e3 49#include "s_serv.h" /* try_connections */
50#include "s_user.h"
51#include "s_stats.h"
52#include "scache.h"
53#include "send.h"
54#include "supported.h"
55#include "whowas.h"
56#include "modules.h"
212380e3 57#include "hook.h"
58#include "ircd_getopt.h"
212380e3 59#include "newconf.h"
212380e3 60#include "reject.h"
61#include "s_conf.h"
62#include "s_newconf.h"
63#include "cache.h"
64#include "monitor.h"
212380e3 65#include "patchlevel.h"
66#include "serno.h"
8db00894 67#include "sslproc.h"
75818939 68#include "chmode.h"
001f5f67 69#include "privilege.h"
212380e3 70
b717a466 71/* /quote set variables */
7bab07d4 72struct SetOptions GlobalSetOptions;
b717a466
JT
73
74/* configuration set from ircd.conf */
75struct config_file_entry ConfigFileEntry;
76/* server info set from ircd.conf */
77struct server_info ServerInfo;
78/* admin info set from ircd.conf */
f0dd4837
VY
79struct admin_info AdminInfo;
80
b717a466 81struct Counter Count;
83251205
VY
82struct ServerStatistics ServerStats;
83
f0dd4837 84int maxconnections;
b717a466 85struct Client me; /* That's me */
f0dd4837
VY
86struct LocalUser meLocalUser; /* That's also part of me */
87
fd4535aa 88rb_dlink_list global_client_list;
b717a466 89
fd4535aa 90/* unknown/client pointer lists */
b717a466 91rb_dlink_list unknown_list; /* unknown clients ON this server only */
fd4535aa 92rb_dlink_list lclient_list; /* local clients only ON this server */
b717a466
JT
93rb_dlink_list serv_list; /* local servers to this server ONLY */
94rb_dlink_list global_serv_list; /* global servers on the network */
95rb_dlink_list local_oper_list; /* our opers, duplicated in lclient_list */
944de091
VY
96rb_dlink_list oper_list; /* network opers */
97
b717a466 98const char *logFileName = LPATH;
944de091
VY
99const char *pidFileName = PPATH;
100
f0dd4837 101char **myargv;
b717a466
JT
102int dorehash = 0;
103int dorehashbans = 0;
104int doremotd = 0;
105int kline_queued = 0;
106int server_state_foreground = 0;
107int opers_see_all_users = 0;
108int ssl_ok = 0;
109int zlib_ok = 1;
110
111int testing_conf = 0;
b5a93db8 112time_t startup_time;
b717a466 113
b5a93db8 114int default_server_capabs = CAP_MASK;
b717a466 115
b5a93db8
VY
116int splitmode;
117int splitchecking;
118int split_users;
119int split_servers;
120int eob_count;
8db00894 121
6972e25a
VY
122void
123ircd_shutdown(const char *reason)
124{
125 struct Client *target_p;
126 rb_dlink_node *ptr;
127
128 RB_DLINK_FOREACH(ptr, lclient_list.head)
129 {
130 target_p = ptr->data;
131
132 sendto_one(target_p, ":%s NOTICE %s :Server Terminating. %s",
133 me.name, target_p->name, reason);
134 }
135
136 RB_DLINK_FOREACH(ptr, serv_list.head)
137 {
138 target_p = ptr->data;
139
140 sendto_one(target_p, ":%s ERROR :Terminated by %s",
141 me.name, reason);
142 }
143
144 ilog(L_MAIN, "Server Terminating. %s", reason);
359dada2 145 close_logfiles();
6972e25a
VY
146
147 unlink(pidFileName);
148 exit(0);
149}
150
212380e3 151/*
152 * print_startup - print startup information
153 */
154static void
155print_startup(int pid)
156{
157 inotice("now running in %s mode from %s as pid %d ...",
158 !server_state_foreground ? "background" : "foreground",
159 ConfigFileEntry.dpath, pid);
160
161 /* let the parent process know the initialization was successful
162 * -- jilles */
163 if (!server_state_foreground)
164 write(0, ".", 1);
165 fclose(stdin);
166 fclose(stdout);
167 fclose(stderr);
168 open("/dev/null", O_RDWR);
169 dup2(0, 1);
170 dup2(0, 2);
171}
172
212380e3 173/*
174 * init_sys
175 *
176 * inputs - boot_daemon flag
177 * output - none
178 * side effects - if boot_daemon flag is not set, don't daemonize
179 */
180static void
181init_sys(void)
182{
b717a466
JT
183#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)
184 struct rlimit limit;
185
186 if(!getrlimit(RLIMIT_NOFILE, &limit))
187 {
188 maxconnections = limit.rlim_cur;
189 if(maxconnections <= MAX_BUFFER)
190 {
191 fprintf(stderr, "ERROR: Shell FD limits are too low.\n");
9b37ad07 192 fprintf(stderr, "ERROR: charybdis reserves %d FDs, shell limits must be above this\n", MAX_BUFFER);
b717a466
JT
193 exit(EXIT_FAILURE);
194 }
195 return;
196 }
197#endif /* RLIMIT_FD_MAX */
3fe90825 198 maxconnections = MAXCONNECTIONS;
212380e3 199}
200
201static int
202make_daemon(void)
203{
204 int pid;
205 int pip[2];
206 char c;
207
208 if (pipe(pip) < 0)
209 {
210 perror("pipe");
211 exit(EXIT_FAILURE);
212 }
213 dup2(pip[1], 0);
214 close(pip[1]);
215 if((pid = fork()) < 0)
216 {
217 perror("fork");
218 exit(EXIT_FAILURE);
219 }
220 else if(pid > 0)
221 {
222 close(0);
223 /* Wait for initialization to finish, successfully or
224 * unsuccessfully. Until this point the child may still
225 * write to stdout/stderr.
226 * -- jilles */
227 if (read(pip[0], &c, 1) > 0)
228 exit(EXIT_SUCCESS);
229 else
230 exit(EXIT_FAILURE);
231 }
232
233 close(pip[0]);
234 setsid();
235/* fclose(stdin);
236 fclose(stdout);
237 fclose(stderr); */
238
239 return 0;
240}
241
242static int printVersion = 0;
243
244struct lgetopt myopts[] = {
245 {"dlinefile", &ConfigFileEntry.dlinefile,
246 STRING, "File to use for dlines.conf"},
247 {"configfile", &ConfigFileEntry.configfile,
248 STRING, "File to use for ircd.conf"},
249 {"klinefile", &ConfigFileEntry.klinefile,
250 STRING, "File to use for kline.conf"},
251 {"xlinefile", &ConfigFileEntry.xlinefile,
252 STRING, "File to use for xline.conf"},
253 {"resvfile", &ConfigFileEntry.resvfile,
254 STRING, "File to use for resv.conf"},
255 {"logfile", &logFileName,
256 STRING, "File to use for ircd.log"},
257 {"pidfile", &pidFileName,
258 STRING, "File to use for process ID"},
259 {"foreground", &server_state_foreground,
260 YESNO, "Run in foreground (don't detach)"},
261 {"version", &printVersion,
262 YESNO, "Print version and exit"},
263 {"conftest", &testing_conf,
264 YESNO, "Test the configuration files and exit"},
265 {"help", NULL, USAGE, "Print this text"},
266 {NULL, NULL, STRING, NULL},
267};
268
212380e3 269static void
270check_rehash(void *unused)
271{
272 /*
273 * Check to see whether we have to rehash the configuration ..
274 */
275 if(dorehash)
276 {
277 rehash(1);
278 dorehash = 0;
279 }
280
281 if(dorehashbans)
282 {
283 rehash_bans(1);
284 dorehashbans = 0;
285 }
286
287 if(doremotd)
288 {
289 sendto_realops_snomask(SNO_GENERAL, L_ALL,
290 "Got signal SIGUSR1, reloading ircd motd file");
a822ef29 291 cache_user_motd();
212380e3 292 doremotd = 0;
293 }
294}
295
212380e3 296/*
297 * initalialize_global_set_options
298 *
299 * inputs - none
300 * output - none
301 * side effects - This sets all global set options needed
302 */
303static void
304initialize_global_set_options(void)
305{
306 memset(&GlobalSetOptions, 0, sizeof(GlobalSetOptions));
307 /* memset( &ConfigFileEntry, 0, sizeof(ConfigFileEntry)); */
308
b717a466
JT
309 GlobalSetOptions.maxclients = ServerInfo.default_max_clients;
310
311 if(GlobalSetOptions.maxclients > (maxconnections - MAX_BUFFER) || (GlobalSetOptions.maxclients <= 0))
3fe90825
VY
312 GlobalSetOptions.maxclients = maxconnections - MAX_BUFFER;
313
212380e3 314 GlobalSetOptions.autoconn = 1;
315
316 GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME;
317 GlobalSetOptions.spam_num = MAX_JOIN_LEAVE_COUNT;
318
319 if(ConfigFileEntry.default_floodcount)
320 GlobalSetOptions.floodcount = ConfigFileEntry.default_floodcount;
321 else
322 GlobalSetOptions.floodcount = 10;
323
324 split_servers = ConfigChannel.default_split_server_count;
325 split_users = ConfigChannel.default_split_user_count;
326
327 if(split_users && split_servers
328 && (ConfigChannel.no_create_on_split || ConfigChannel.no_join_on_split))
329 {
330 splitmode = 1;
331 splitchecking = 1;
332 }
333
334 GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
335
907468c4 336 rb_strlcpy(GlobalSetOptions.operstring,
212380e3 337 ConfigFileEntry.default_operstring,
338 sizeof(GlobalSetOptions.operstring));
907468c4 339 rb_strlcpy(GlobalSetOptions.adminstring,
212380e3 340 ConfigFileEntry.default_adminstring,
341 sizeof(GlobalSetOptions.adminstring));
342
343 /* memset( &ConfigChannel, 0, sizeof(ConfigChannel)); */
344
345 /* End of global set options */
346
347}
348
349/*
350 * initialize_server_capabs
351 *
352 * inputs - none
353 * output - none
354 */
355static void
356initialize_server_capabs(void)
357{
358 default_server_capabs &= ~CAP_ZIP;
359}
360
361
362/*
363 * write_pidfile
364 *
365 * inputs - filename+path of pid file
366 * output - none
367 * side effects - write the pid of the ircd to filename
368 */
369static void
370write_pidfile(const char *filename)
371{
372 FILE *fb;
373 char buff[32];
374 if((fb = fopen(filename, "w")))
375 {
376 unsigned int pid = (unsigned int) getpid();
377
38e6acdd 378 rb_snprintf(buff, sizeof(buff), "%u\n", pid);
212380e3 379 if((fputs(buff, fb) == -1))
380 {
381 ilog(L_MAIN, "Error writing %u to pid file %s (%s)",
382 pid, filename, strerror(errno));
383 }
384 fclose(fb);
385 return;
386 }
387 else
388 {
389 ilog(L_MAIN, "Error opening pid file %s", filename);
390 }
391}
392
393/*
394 * check_pidfile
395 *
396 * inputs - filename+path of pid file
397 * output - none
398 * side effects - reads pid from pidfile and checks if ircd is in process
399 * list. if it is, gracefully exits
400 * -kre
401 */
402static void
403check_pidfile(const char *filename)
404{
405 FILE *fb;
406 char buff[32];
407 pid_t pidfromfile;
408
409 /* Don't do logging here, since we don't have log() initialised */
410 if((fb = fopen(filename, "r")))
411 {
412 if(fgets(buff, 20, fb) != NULL)
413 {
414 pidfromfile = atoi(buff);
415 if(!kill(pidfromfile, 0))
416 {
417 printf("ircd: daemon is already running\n");
418 exit(-1);
419 }
420 }
421 fclose(fb);
422 }
423}
424
425/*
426 * setup_corefile
427 *
428 * inputs - nothing
429 * output - nothing
430 * side effects - setups corefile to system limits.
431 * -kre
432 */
433static void
434setup_corefile(void)
435{
436#ifdef HAVE_SYS_RESOURCE_H
437 struct rlimit rlim; /* resource limits */
438
439 /* Set corefilesize to maximum */
440 if(!getrlimit(RLIMIT_CORE, &rlim))
441 {
442 rlim.rlim_cur = rlim.rlim_max;
443 setrlimit(RLIMIT_CORE, &rlim);
444 }
445#endif
446}
447
b1d6fa8c
VY
448static void
449ircd_log_cb(const char *str)
450{
94c10015 451 ilog(L_MAIN, "libratbox reports: %s", str);
b1d6fa8c
VY
452}
453
454static void
455ircd_restart_cb(const char *str)
456{
2d9a60fe 457 inotice("libratbox has called the restart callback: %s", str);
b1d6fa8c
VY
458 restart(str);
459}
460
461/*
462 * Why EXIT_FAILURE here?
463 * Because if ircd_die_cb() is called it's because of a fatal
464 * error inside libcharybdis, and we don't know how to handle the
465 * exception, so it is logical to return a FAILURE exit code here.
466 * --nenolod
467 */
468static void
469ircd_die_cb(const char *str)
470{
471 if(str != NULL)
472 {
473 /* Try to get the message out to currently logged in operators. */
94c10015
VY
474 sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "libratbox has called the die callback..aborting: %s", str);
475 inotice("libratbox has called the die callback..aborting: %s", str);
b1d6fa8c 476 }
94c10015 477 else
2d9a60fe 478 inotice("libratbox has called the die callback..aborting");
b1d6fa8c
VY
479
480 unlink(pidFileName);
481 exit(EXIT_FAILURE);
482}
483
ccfe0e97
WP
484struct ev_entry *check_splitmode_ev = NULL;
485
8dd8b3e2
VY
486static int
487seed_with_urandom(void)
488{
489 unsigned int seed;
490 int fd;
491
492 fd = open("/dev/urandom", O_RDONLY);
493 if(fd >= 0)
494 {
495 if(read(fd, &seed, sizeof(seed)) == sizeof(seed))
496 {
497 close(fd);
498 srand(seed);
499 return 1;
500 }
501 }
502 return 0;
503}
504
505static void
506seed_with_clock(void)
507{
508 const struct timeval *tv;
509 rb_set_time();
510 tv = rb_current_time_tv();
511 srand(tv->tv_sec ^ (tv->tv_usec | (getpid() << 20)));
512}
513
514static void
515seed_random(void *unused)
516{
517 unsigned int seed;
518 if(rb_get_random(&seed, sizeof(seed)) == -1)
519 {
520 if(!seed_with_urandom())
521 seed_with_clock();
522 return;
523 }
524 srand(seed);
525}
526
212380e3 527/*
528 * main
529 *
530 * Initializes the IRCd.
531 *
532 * Inputs - number of commandline args, args themselves
533 * Outputs - none
534 * Side Effects - this is where the ircd gets going right now
535 */
536int
537main(int argc, char *argv[])
538{
539 int fd;
540
541 /* Check to see if the user is running us as root, which is a nono */
542 if(geteuid() == 0)
543 {
544 fprintf(stderr, "Don't run ircd as root!!!\n");
545 return -1;
546 }
547
9a7b24a6
VY
548 init_sys();
549
f43b492b
JT
550 ConfigFileEntry.dpath = DPATH;
551 ConfigFileEntry.configfile = CPATH; /* Server configuration file */
552 ConfigFileEntry.klinefile = KPATH; /* Server kline file */
553 ConfigFileEntry.dlinefile = DLPATH; /* dline file */
554 ConfigFileEntry.xlinefile = XPATH;
555 ConfigFileEntry.resvfile = RESVPATH;
556 ConfigFileEntry.connect_timeout = 30; /* Default to 30 */
557
558 umask(077); /* better safe than sorry --SRB */
9a7b24a6
VY
559
560 myargv = argv;
561 parseargs(&argc, &argv, myopts);
562
563 if(chdir(ConfigFileEntry.dpath))
564 {
565 fprintf(stderr, "Unable to chdir to %s: %s\n", ConfigFileEntry.dpath, strerror(errno));
566 exit(EXIT_FAILURE);
567 }
568
fd4535aa
VY
569 rb_set_time();
570
212380e3 571 /*
572 * Setup corefile size immediately after boot -kre
573 */
574 setup_corefile();
575
212380e3 576 memset(&me, 0, sizeof(me));
577 memset(&meLocalUser, 0, sizeof(meLocalUser));
578 me.localClient = &meLocalUser;
579
580 /* Make sure all lists are zeroed */
581 memset(&unknown_list, 0, sizeof(unknown_list));
582 memset(&lclient_list, 0, sizeof(lclient_list));
583 memset(&serv_list, 0, sizeof(serv_list));
584 memset(&global_serv_list, 0, sizeof(global_serv_list));
585 memset(&local_oper_list, 0, sizeof(local_oper_list));
586 memset(&oper_list, 0, sizeof(oper_list));
587
af81d5a0 588 rb_dlinkAddTail(&me, &me.node, &global_client_list);
212380e3 589
7bab07d4
VY
590 memset(&Count, 0, sizeof(Count));
591 memset(&ServerInfo, 0, sizeof(ServerInfo));
592 memset(&AdminInfo, 0, sizeof(AdminInfo));
593 memset(&ServerStats, 0, sizeof(struct ServerStatistics));
212380e3 594
595 /* Initialise the channel capability usage counts... */
596 init_chcap_usage_counts();
597
212380e3 598 if(printVersion)
599 {
7f980188 600 printf("ircd: version %s(%s)\n", ircd_version, serno);
b0ef251c 601 printf("ircd: %s\n", rb_lib_version());
212380e3 602 exit(EXIT_SUCCESS);
603 }
604
9a7b24a6 605
212380e3 606
607 setup_signals();
608
212380e3 609 if (testing_conf)
610 server_state_foreground = 1;
611
612 /* Make sure fd 0, 1 and 2 are in use -- jilles */
613 do
614 {
615 fd = open("/dev/null", O_RDWR);
616 } while (fd < 2 && fd != -1);
617 if (fd > 2)
618 close(fd);
619 else if (fd == -1)
620 exit(1);
621
622 /* Check if there is pidfile and daemon already running */
623 if(!testing_conf)
624 {
625 check_pidfile(pidFileName);
626
627 if(!server_state_foreground)
628 make_daemon();
629 inotice("starting %s ...", ircd_version);
7b52cd51 630 inotice("%s", rb_lib_version());
212380e3 631 }
632
633 /* Init the event subsystem */
15f1b609 634 rb_lib_init(ircd_log_cb, ircd_restart_cb, ircd_die_cb, !server_state_foreground, maxconnections, DNODE_HEAP_SIZE, FD_HEAP_SIZE);
348684d2 635 rb_linebuf_init(LINEBUF_HEAP_SIZE);
212380e3 636
2b454b76
VY
637 if(ConfigFileEntry.use_egd && (ConfigFileEntry.egdpool_path != NULL))
638 {
639 rb_init_prng(ConfigFileEntry.egdpool_path, RB_PRNG_EGD);
640 } else
641 rb_init_prng(NULL, RB_PRNG_DEFAULT);
642
2a64312f
VY
643 seed_random(NULL);
644
212380e3 645 init_main_logfile();
212380e3 646 newconf_init();
647 init_s_conf();
648 init_s_newconf();
649 init_hash();
650 clear_scache_hash_table(); /* server cache name table */
651 init_host_hash();
652 clear_hash_parse();
653 init_client();
212380e3 654 init_hook();
655 init_channels();
656 initclass();
657 initwhowas();
212380e3 658 init_reject();
659 init_cache();
660 init_monitor();
661 init_isupport();
662 load_all_modules(1);
663#ifndef STATIC_MODULES
664 load_core_modules(1);
665#endif
666 init_auth(); /* Initialise the auth code */
667 init_resolver(); /* Needs to be setup before the io loop */
001f5f67 668 privilegeset_set_new("default", "", 0);
212380e3 669
670 if (testing_conf)
671 fprintf(stderr, "\nBeginning config test\n");
672 read_conf_files(YES); /* cold start init conf files */
673 rehash_bans(0);
674#ifndef STATIC_MODULES
675
676 mod_add_path(MODULE_DIR);
677 mod_add_path(MODULE_DIR "/autoload");
678#endif
679
8db00894
VY
680 init_ssld();
681
212380e3 682 initialize_server_capabs(); /* Set up default_server_capabs */
683 initialize_global_set_options();
684
685 if(ServerInfo.name == NULL)
686 {
687 ierror("no server name specified in serverinfo block.");
688 return -1;
689 }
907468c4 690 rb_strlcpy(me.name, ServerInfo.name, sizeof(me.name));
212380e3 691
692 if(ServerInfo.sid[0] == '\0')
693 {
694 ierror("no server sid specified in serverinfo block.");
695 return -2;
696 }
697 strcpy(me.id, ServerInfo.sid);
698 init_uid();
699
700 /* serverinfo{} description must exist. If not, error out. */
701 if(ServerInfo.description == NULL)
702 {
703 ierror("no server description specified in serverinfo block.");
704 return -3;
705 }
907468c4 706 rb_strlcpy(me.info, ServerInfo.description, sizeof(me.info));
212380e3 707
b717a466
JT
708 if(ServerInfo.ssl_cert != NULL && ServerInfo.ssl_private_key != NULL)
709 {
710 /* just do the rb_setup_ssl_server to validate the config */
711 if(!rb_setup_ssl_server(ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params))
712 {
713 ilog(L_MAIN, "WARNING: Unable to setup SSL.");
714 ssl_ok = 0;
715 }
716 else
717 ssl_ok = 1;
8db00894
VY
718 }
719
212380e3 720 if (testing_conf)
721 {
722 fprintf(stderr, "\nConfig testing complete.\n");
723 fflush(stderr);
724 return 0; /* Why? We want the launcher to exit out. */
725 }
726
727 me.from = &me;
728 me.servptr = &me;
729 SetMe(&me);
730 make_server(&me);
9f6bbe3c 731 startup_time = rb_current_time();
212380e3 732 add_to_client_hash(me.name, &me);
733 add_to_id_hash(me.id, &me);
994544c2 734 me.serv->nameinfo = scache_connect(me.name, me.info, 0);
212380e3 735
af81d5a0 736 rb_dlinkAddAlloc(&me, &global_serv_list);
212380e3 737
738 construct_umodebuf();
75818939 739 construct_noparam_modes();
212380e3 740
741 check_class();
742 write_pidfile(pidFileName);
743 load_help();
744 open_logfiles();
745
746 ilog(L_MAIN, "Server Ready");
747
212380e3 748 /* We want try_connections to be called as soon as possible now! -- adrian */
749 /* No, 'cause after a restart it would cause all sorts of nick collides */
750 /* um. by waiting even longer, that just means we have even *more*
751 * nick collisions. what a stupid idea. set an event for the IO loop --fl
752 */
9e29fe51 753 rb_event_addish("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
42706093
VY
754 rb_event_addonce("try_connections_startup", try_connections, NULL, 2);
755 rb_event_add("check_rehash", check_rehash, NULL, 3);
8dd8b3e2 756 rb_event_addish("reseed_srand", seed_random, NULL, 300); /* reseed every 10 minutes */
212380e3 757
212380e3 758 if(splitmode)
42706093 759 check_splitmode_ev = rb_event_add("check_splitmode", check_splitmode, NULL, 5);
212380e3 760
212380e3 761 print_startup(getpid());
762
9b2fe0ba 763 rb_lib_loop(0);
212380e3 764
765 return 0;
766}