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