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