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