53 |
|
#include "s_log.h" |
54 |
|
#include "s_misc.h" |
55 |
|
#include "s_serv.h" /* try_connections */ |
56 |
– |
#include "s_stats.h" |
56 |
|
#include "send.h" |
57 |
|
#include "whowas.h" |
58 |
|
#include "modules.h" |
62 |
|
#include "balloc.h" |
63 |
|
#include "motd.h" |
64 |
|
#include "supported.h" |
65 |
+ |
#include "watch.h" |
66 |
|
|
67 |
|
/* Try and find the correct name to use with getrlimit() for setting the max. |
68 |
|
* number of files allowed to be open by this process. |
80 |
|
struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
81 |
|
struct ServerState_t server_state = { 0 }; |
82 |
|
struct logging_entry ConfigLoggingEntry = { 1, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0} }; |
83 |
+ |
struct ServerStatistics ServerStats; |
84 |
|
struct timeval SystemTime; |
85 |
|
struct Client me; /* That's me */ |
86 |
|
struct LocalUser meLocalUser; /* That's also part of me */ |
86 |
– |
unsigned long connect_id = 0; /* unique connect ID */ |
87 |
|
|
88 |
|
static unsigned long initialVMTop = 0; /* top of virtual memory at init */ |
89 |
|
const char *logFileName = LPATH; |
122 |
|
|
123 |
|
int rehashed_klines = 0; |
124 |
|
|
125 |
– |
/* |
126 |
– |
* get_vm_top - get the operating systems notion of the resident set size |
127 |
– |
*/ |
128 |
– |
#ifndef _WIN32 |
129 |
– |
static unsigned long |
130 |
– |
get_vm_top(void) |
131 |
– |
{ |
132 |
– |
/* |
133 |
– |
* NOTE: sbrk is not part of the ANSI C library or the POSIX.1 standard |
134 |
– |
* however it seems that everyone defines it. Calling sbrk with a 0 |
135 |
– |
* argument will return a pointer to the top of the process virtual |
136 |
– |
* memory without changing the process size, so this call should be |
137 |
– |
* reasonably safe (sbrk returns the new value for the top of memory). |
138 |
– |
* This code relies on the notion that the address returned will be an |
139 |
– |
* offset from 0 (NULL), so the result of sbrk is cast to a size_t and |
140 |
– |
* returned. We really shouldn't be using it here but... |
141 |
– |
*/ |
142 |
– |
|
143 |
– |
void *vptr = sbrk(0); |
144 |
– |
return((unsigned long)vptr); |
145 |
– |
} |
125 |
|
|
126 |
+ |
#ifndef _WIN32 |
127 |
|
/* |
128 |
|
* print_startup - print startup information |
129 |
|
*/ |
156 |
|
} |
157 |
|
#endif |
158 |
|
|
179 |
– |
/* |
180 |
– |
* get_maxrss - get the operating systems notion of the resident set size |
181 |
– |
*/ |
182 |
– |
unsigned long |
183 |
– |
get_maxrss(void) |
184 |
– |
{ |
185 |
– |
#ifdef _WIN32 |
186 |
– |
return (0); /* FIXME */ |
187 |
– |
#else |
188 |
– |
return (get_vm_top() - initialVMTop); |
189 |
– |
#endif |
190 |
– |
} |
191 |
– |
|
159 |
|
static int printVersion = 0; |
160 |
|
|
161 |
|
struct lgetopt myopts[] = { |
248 |
|
{ |
249 |
|
struct Client *client_p = ptr->data; |
250 |
|
assert(client_p->localClient->list_task); |
251 |
< |
safe_list_channels(client_p, client_p->localClient->list_task, 0, 0); |
251 |
> |
safe_list_channels(client_p, client_p->localClient->list_task, 0); |
252 |
|
} |
253 |
|
} |
254 |
|
|
347 |
|
initialize_server_capabs(void) |
348 |
|
{ |
349 |
|
add_capability("QS", CAP_QS, 1); |
383 |
– |
add_capability("LL", CAP_LL, 1); |
350 |
|
add_capability("EOB", CAP_EOB, 1); |
351 |
+ |
|
352 |
|
if (ServerInfo.sid != NULL) /* only enable TS6 if we have an SID */ |
353 |
|
add_capability("TS6", CAP_TS6, 0); |
354 |
+ |
|
355 |
|
add_capability("ZIP", CAP_ZIP, 0); |
356 |
|
add_capability("CLUSTER", CAP_CLUSTER, 1); |
357 |
|
#ifdef HALFOPS |
497 |
|
static void |
498 |
|
init_callbacks(void) |
499 |
|
{ |
500 |
< |
iorecv_cb = register_callback("iorecv", NULL); |
501 |
< |
iosend_cb = register_callback("iosend", NULL); |
500 |
> |
iorecv_cb = register_callback("iorecv", iorecv_default); |
501 |
> |
iosend_cb = register_callback("iosend", iosend_default); |
502 |
|
iorecvctrl_cb = register_callback("iorecvctrl", NULL); |
503 |
|
iosendctrl_cb = register_callback("iosendctrl", NULL); |
504 |
|
} |
518 |
|
|
519 |
|
/* Setup corefile size immediately after boot -kre */ |
520 |
|
setup_corefile(); |
553 |
– |
|
554 |
– |
/* set initialVMTop before we allocate any memory */ |
555 |
– |
initialVMTop = get_vm_top(); |
521 |
|
#endif |
522 |
|
|
523 |
|
/* save server boot time right away, so getrusage works correctly */ |
532 |
|
of Client list */ |
533 |
|
|
534 |
|
memset(&ServerInfo, 0, sizeof(ServerInfo)); |
535 |
+ |
memset(&ServerStats, 0, sizeof(ServerStats)); |
536 |
|
|
537 |
|
/* Initialise the channel capability usage counts... */ |
538 |
|
init_chcap_usage_counts(); |
604 |
|
init_client(); |
605 |
|
init_class(); |
606 |
|
init_whowas(); |
607 |
< |
init_stats(); |
607 |
> |
watch_init(); |
608 |
|
read_conf_files(1); /* cold start init conf files */ |
643 |
– |
initServerMask(); |
609 |
|
me.id[0] = '\0'; |
610 |
|
init_uid(); |
611 |
|
init_auth(); /* Initialise the auth code */ |
621 |
|
ilog(L_CRIT, "No server name specified in serverinfo block."); |
622 |
|
exit(EXIT_FAILURE); |
623 |
|
} |
624 |
+ |
|
625 |
|
strlcpy(me.name, ServerInfo.name, sizeof(me.name)); |
626 |
|
|
627 |
|
/* serverinfo{} description must exist. If not, error out.*/ |
631 |
|
"ERROR: No server description specified in serverinfo block."); |
632 |
|
exit(EXIT_FAILURE); |
633 |
|
} |
634 |
+ |
|
635 |
|
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
636 |
|
|
637 |
|
me.from = &me; |
694 |
|
eventAddIsh("check_splitmode", check_splitmode, NULL, 60); |
695 |
|
|
696 |
|
io_loop(); |
697 |
< |
return(0); |
697 |
> |
return 0; |
698 |
|
} |