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