ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/ircd.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/ircd.c (file contents):
Revision 3239 by michael, Sun Mar 30 13:55:44 2014 UTC vs.
Revision 4133 by michael, Tue Jul 1 21:43:15 2014 UTC

# Line 25 | Line 25
25   */
26  
27   #include "stdinc.h"
28 < #include "s_user.h"
28 > #include "user.h"
29   #include "list.h"
30   #include "ircd.h"
31   #include "channel.h"
32 #include "channel_mode.h"
32   #include "client.h"
33   #include "event.h"
34   #include "fdlist.h"
35   #include "hash.h"
36   #include "irc_string.h"
37   #include "ircd_signal.h"
38 < #include "s_gline.h"
38 > #include "gline.h"
39   #include "motd.h"
40   #include "conf.h"
41   #include "hostmask.h"
43 #include "numeric.h"
44 #include "packet.h"
42   #include "parse.h"
43 < #include "irc_res.h"
43 > #include "res.h"
44   #include "restart.h"
45   #include "rng_mt.h"
46 < #include "s_auth.h"
46 > #include "auth.h"
47   #include "s_bsd.h"
48   #include "log.h"
49 < #include "s_misc.h"
53 < #include "s_serv.h"      /* try_connections */
49 > #include "server.h"      /* try_connections */
50   #include "send.h"
51   #include "whowas.h"
52   #include "modules.h"
53   #include "memory.h"
54   #include "mempool.h"
59 #include "hook.h"
55   #include "ircd_getopt.h"
61 #include "supported.h"
56   #include "watch.h"
57   #include "conf_db.h"
58   #include "conf_class.h"
# Line 68 | Line 62
62   GeoIP *geoip_ctx;
63   #endif
64  
71 /* /quote set variables */
72 struct SetOptions GlobalSetOptions;
73 struct Counter Count;
74 struct ServerState_t server_state;
65   struct ServerStatistics ServerStats;
66   struct timeval SystemTime;
67   struct Client me;             /* That's me */
# Line 88 | Line 78 | int doremotd = 0;
78   /* Set to zero because it should be initialized later using
79   * initialize_server_capabs
80   */
81 < int default_server_capabs = 0;
81 > unsigned int default_server_capabs;
82   unsigned int splitmode;
83   unsigned int splitchecking;
84   unsigned int split_users;
85   unsigned int split_servers;
86  
87 < /* Do klines the same way hybrid-6 did them, i.e. at the
88 < * top of the next io_loop instead of in the same loop as
89 < * the klines are being applied.
90 < *
91 < * This should fix strange CPU starvation as very indirectly reported.
92 < * (Why do you people not email bug reports? WHY? WHY?)
93 < *
94 < * - Dianora
95 < */
87 > static struct event event_cleanup_glines =
88 > {
89 >  .name = "cleanup_glines",
90 >  .handler = cleanup_glines,
91 >  .when = CLEANUP_GLINES_TIME
92 > };
93 >
94 > static struct event event_cleanup_tklines =
95 > {
96 >  .name = "cleanup_tklines",
97 >  .handler = cleanup_tklines,
98 >  .when = CLEANUP_TKLINES_TIME
99 > };
100 >
101 > static struct event event_try_connections =
102 > {
103 >  .name = "try_connections",
104 >  .handler = try_connections,
105 >  .when = STARTUP_CONNECTIONS_TIME
106 > };
107 >
108 > static struct event event_comm_checktimeouts =
109 > {
110 >  .name = "comm_checktimeouts",
111 >  .handler = comm_checktimeouts,
112 >  .when = 1
113 > };
114  
115 < int rehashed_klines = 0;
115 > static struct event event_save_all_databases =
116 > {
117 >  .name = "save_all_databases",
118 >  .handler = save_all_databases,
119 >  .when = DATABASE_UPDATE_TIMEOUT
120 > };
121 >
122 > struct event event_write_links_file =
123 > {
124 >  .name = "write_links_file",
125 >  .handler = write_links_file,
126 > };
127  
128  
129   /*
# Line 201 | Line 220 | io_loop(void)
220   {
221    while (1)
222    {
204    /*
205     * Maybe we want a flags word?
206     * ie. if (REHASHED_KLINES(global_flags))
207     * SET_REHASHED_KLINES(global_flags)
208     * CLEAR_REHASHED_KLINES(global_flags)
209     *
210     * - Dianora
211     */
212    if (rehashed_klines)
213    {
214      check_conf_klines();
215      rehashed_klines = 0;
216    }
217
223      if (listing_client_list.head)
224      {
225        dlink_node *ptr = NULL, *ptr_next = NULL;
226        DLINK_FOREACH_SAFE(ptr, ptr_next, listing_client_list.head)
227 <      {
223 <        struct Client *client_p = ptr->data;
224 <        assert(client_p->localClient->list_task);
225 <        safe_list_channels(client_p, client_p->localClient->list_task, 0);
226 <      }
227 >        safe_list_channels(ptr->data, 0);
228      }
229  
230 <    /* Run pending events, then get the number of seconds to the next
231 <     * event
231 <     */
232 <    while (eventNextTime() <= CurrentTime)
233 <      eventRun();
230 >    /* Run pending events */
231 >    event_run();
232  
233      comm_select();
234      exit_aborted_clients();
# Line 304 | Line 302 | initialize_server_capabs(void)
302    add_capability("TS6", CAP_TS6, 0);
303    add_capability("CLUSTER", CAP_CLUSTER, 1);
304    add_capability("SVS", CAP_SVS, 1);
305 < #ifdef HALFOPS
305 >  add_capability("CHW", CAP_CHW, 1);
306    add_capability("HOPS", CAP_HOPS, 1);
309 #endif
307   }
308  
309   /* write_pidfile()
# Line 430 | Line 427 | ssl_init(void)
427  
428    if ((ServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL)
429    {
430 <    const char *s;
430 >    const char *s = ERR_lib_error_string(ERR_get_error());
431  
432 <    fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n",
436 <            s = ERR_lib_error_string(ERR_get_error()));
432 >    fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
433      ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
434    }
435  
436    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
437 <  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
437 >  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_TLS_ROLLBACK_BUG);
438    SSL_CTX_set_verify(ServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
439                       always_accept_verify_cb);
440    SSL_CTX_set_session_id_context(ServerInfo.server_ctx, session_id, sizeof(session_id) - 1);
441  
442 + #if OPENSSL_VERSION_NUMBER >= 0x1000005FL && !defined(OPENSSL_NO_ECDH)
443 +  {
444 +    EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
445 +
446 +    if (key)
447 +    {
448 +      SSL_CTX_set_tmp_ecdh(ServerInfo.server_ctx, key);
449 +      EC_KEY_free(key);
450 +    }
451 +  }
452 +
453 +  SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
454 + #endif
455 +
456    if ((ServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
457    {
458 <    const char *s;
458 >    const char *s = ERR_lib_error_string(ERR_get_error());
459  
460 <    fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n",
451 <            s = ERR_lib_error_string(ERR_get_error()));
460 >    fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
461      ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
462    }
463  
464    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1);
465 <  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG|SSL_OP_ALL);
465 >  SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_TLS_ROLLBACK_BUG);
466    SSL_CTX_set_verify(ServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
467                       always_accept_verify_cb);
468   #endif /* HAVE_LIBCRYPTO */
# Line 465 | Line 474 | main(int argc, char *argv[])
474    /* Check to see if the user is running us as root, which is a nono */
475    if (geteuid() == 0)
476    {
477 <    fprintf(stderr, "Don't run ircd as root!!!\n");
477 >    fprintf(stderr, "ERROR: This server won't run as root/superuser\n");
478      return -1;
479    }
480  
# Line 481 | Line 490 | main(int argc, char *argv[])
490    me.localClient = &meLocalUser;
491    dlinkAdd(&me, &me.node, &global_client_list);  /* Pointer to beginning
492                                                     of Client list */
493 +  ConfigLoggingEntry.use_logging = 1;
494    ConfigFileEntry.dpath      = DPATH;
495    ConfigFileEntry.spath      = SPATH;
496    ConfigFileEntry.mpath      = MPATH;
# Line 520 | Line 530 | main(int argc, char *argv[])
530  
531    setup_signals();
532  
523  /* Init the event subsystem */
524  eventInit();
525
533    /* We need this to initialise the fd array before anything else */
534    fdlist_init();
535    log_set_file(LOG_TYPE_IRCD, 0, logFileName);
# Line 630 | Line 637 | main(int argc, char *argv[])
637  
638    ilog(LOG_TYPE_IRCD, "Server Ready");
639  
640 <  eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME);
641 <  eventAddIsh("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_TIME);
640 >  event_addish(&event_cleanup_glines, NULL);
641 >  event_addish(&event_cleanup_tklines, NULL);
642  
643    /* We want try_connections to be called as soon as possible now! -- adrian */
644    /* No, 'cause after a restart it would cause all sorts of nick collides */
645 <  eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
645 >  event_addish(&event_try_connections, NULL);
646  
647    /* Setup the timeout check. I'll shift it later :)  -- adrian */
648 <  eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1);
648 >  event_addish(&event_comm_checktimeouts, NULL);
649  
650 <  eventAddIsh("save_all_databases", save_all_databases, NULL, DATABASE_UPDATE_TIMEOUT);
650 >  event_addish(&event_save_all_databases, NULL);
651  
652    if (ConfigServerHide.links_delay > 0)
653 <    eventAddIsh("write_links_file", write_links_file, NULL, ConfigServerHide.links_delay);
653 >  {
654 >    event_write_links_file.when = ConfigServerHide.links_delay;
655 >    event_addish(&event_write_links_file, NULL);
656 >  }
657    else
658      ConfigServerHide.links_disabled = 1;
659  
660    if (splitmode)
661 <    eventAddIsh("check_splitmode", check_splitmode, NULL, 60);
661 >    event_addish(&splitmode_event, NULL);
662  
663    io_loop();
664    return 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)