~posulliv/drizzle/optimizer-style-cleanup

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Padraig O'Sullivan
  • Date: 2010-04-17 01:38:47 UTC
  • mfrom: (1237.9.238 bad-staging)
  • Revision ID: osullivan.padraig@gmail.com-20100417013847-ibjioqsfbmf5yg4g
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#include "drizzled/plugin/scheduler.h"
50
50
#include "drizzled/plugin/xa_resource_manager.h"
51
51
#include "drizzled/plugin/monitored_in_transaction.h"
 
52
#include "drizzled/replication_services.h" /* For ReplicationServices::evaluateRegisteredPlugins() */
52
53
#include "drizzled/probes.h"
53
54
#include "drizzled/session_list.h"
54
55
#include "drizzled/charset.h"
77
78
 
78
79
#include <errno.h>
79
80
#include <sys/stat.h>
80
 
#include "drizzled/my_getopt.h"
 
81
#include "drizzled/option.h"
81
82
#ifdef HAVE_SYSENT_H
82
83
#include <sysent.h>
83
84
#endif
347
348
/* Static variables */
348
349
 
349
350
static bool segfaulted;
350
 
#ifdef HAVE_STACK_TRACE_ON_SEGV
351
 
static bool opt_do_pstack;
352
 
#endif /* HAVE_STACK_TRACE_ON_SEGV */
353
351
int cleanup_done;
354
352
static char *drizzle_home_ptr, *pidfile_name_ptr;
355
353
static int defaults_argc;
376
374
extern "C" pthread_handler_t signal_hand(void *arg);
377
375
static void drizzle_init_variables(void);
378
376
static void get_options(int *argc,char **argv);
379
 
bool drizzled_get_one_option(int, const struct my_option *, char *);
 
377
int drizzled_get_one_option(int, const struct option *, char *);
380
378
static int init_thread_environment();
381
379
static const char *get_relative_path(const char *path);
382
380
static void fix_paths(string &progname);
528
526
  TableShare::cacheStop();
529
527
  set_var_free();
530
528
  free_charsets();
531
 
  ha_end();
532
529
  plugin::Registry &plugins= plugin::Registry::singleton();
533
530
  plugin_shutdown(plugins);
534
531
  xid_cache_free();
549
546
 
550
547
  if (print_message && server_start_time)
551
548
    errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
552
 
  /* Returns NULL on globerrs, we don't want to try to free that */
553
 
  //void *freeme=
554
 
  (void *)my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
555
 
  // TODO!!!! EPIC FAIL!!!! This sefaults if uncommented.
556
 
/*  if (freeme != NULL)
557
 
    free(freeme);  */
558
549
  (void) pthread_mutex_lock(&LOCK_thread_count);
559
550
  ready_to_exit=1;
560
551
  /* do the broadcast inside the lock to ensure that my_end() is not called */
970
961
  return 0;
971
962
}
972
963
 
973
 
static int show_open_tables(drizzle_show_var *var, char *buff)
974
 
{
975
 
  var->type= SHOW_LONG;
976
 
  var->value= buff;
977
 
  *((long *)buff)= (long)cached_open_tables();
978
 
  return 0;
979
 
}
980
 
 
981
 
static int show_table_definitions(drizzle_show_var *var, char *buff)
982
 
{
983
 
  var->type= SHOW_LONG;
984
 
  var->value= buff;
985
 
  *((long *)buff)= (long)cached_table_definitions();
986
 
  return 0;
987
 
}
988
 
 
989
 
static st_show_var_func_container
990
 
show_open_tables_cont= { &show_open_tables };
991
 
static st_show_var_func_container
992
 
show_table_definitions_cont= { &show_table_definitions };
993
 
static st_show_var_func_container
994
 
show_starttime_cont= { &show_starttime };
995
 
static st_show_var_func_container
996
 
show_flushstatustime_cont= { &show_flushstatustime };
 
964
static st_show_var_func_container show_starttime_cont= { &show_starttime };
 
965
 
 
966
static st_show_var_func_container show_flushstatustime_cont= { &show_flushstatustime };
997
967
 
998
968
/*
999
969
  Variables shown by SHOW STATUS in alphabetical order
1072
1042
  {"Key_writes",               (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG},
1073
1043
  {"Last_query_cost",          (char*) offsetof(system_status_var, last_query_cost), SHOW_DOUBLE_STATUS},
1074
1044
  {"Max_used_connections",     (char*) &max_used_connections,  SHOW_INT},
1075
 
  {"Open_table_definitions",   (char*) &show_table_definitions_cont, SHOW_FUNC},
1076
 
  {"Open_tables",              (char*) &show_open_tables_cont,       SHOW_FUNC},
1077
 
  {"Opened_tables",            (char*) offsetof(system_status_var, opened_tables), SHOW_LONG_STATUS},
1078
 
  {"Opened_table_definitions", (char*) offsetof(system_status_var, opened_shares), SHOW_LONG_STATUS},
1079
1045
  {"Questions",                (char*) offsetof(system_status_var, questions), SHOW_LONG_STATUS},
1080
1046
  {"Select_full_join",         (char*) offsetof(system_status_var, select_full_join_count), SHOW_LONG_STATUS},
1081
1047
  {"Select_full_range_join",   (char*) offsetof(system_status_var, select_full_range_join_count), SHOW_LONG_STATUS},
1159
1125
  current_pid= getpid();                /* Save for later ref */
1160
1126
  init_time();                          /* Init time-functions (read zone) */
1161
1127
 
1162
 
  if (init_errmessage())        /* Read error messages from file */
1163
 
    return 1;
1164
1128
  if (item_create_init())
1165
1129
    return 1;
1166
1130
  if (set_var_init())
1269
1233
  }
1270
1234
 
1271
1235
  /* Allow storage engine to give real error messages */
1272
 
  if (ha_init_errors())
1273
 
    return(1);
 
1236
  ha_init_errors();
1274
1237
 
1275
1238
  if (plugin_init(plugins, &defaults_argc, defaults_argv,
1276
1239
                  ((opt_help) ? true : false)))
1287
1250
  {
1288
1251
    int ho_error;
1289
1252
    char **tmp_argv= defaults_argv;
1290
 
    struct my_option no_opts[]=
 
1253
    struct option no_opts[]=
1291
1254
    {
1292
1255
      {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1293
1256
    };
1439
1402
};
1440
1403
 
1441
1404
 
1442
 
struct my_option my_long_options[] =
 
1405
struct option my_long_options[] =
1443
1406
{
1444
1407
  {"help", '?', N_("Display this help and exit."),
1445
1408
   (char**) &opt_help, (char**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1493
1456
   N_("Set the default time zone."),
1494
1457
   (char**) &default_tz_name, (char**) &default_tz_name,
1495
1458
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
1496
 
#ifdef HAVE_STACK_TRACE_ON_SEGV
1497
 
  {"enable-pstack", OPT_DO_PSTACK,
1498
 
   N_("Print a symbolic stack trace on failure."),
1499
 
   (char**) &opt_do_pstack, (char**) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0,
1500
 
   0, 0, 0, 0},
1501
 
#endif /* HAVE_STACK_TRACE_ON_SEGV */
1502
1459
  /* See how it's handled in get_one_option() */
1503
1460
  {"exit-info", 'T',
1504
1461
   N_("Used for debugging;  Use at your own risk!"),
1905
1862
}
1906
1863
 
1907
1864
 
1908
 
bool drizzled_get_one_option(int optid, const struct my_option *opt,
 
1865
int drizzled_get_one_option(int optid, const struct option *opt,
1909
1866
                             char *argument)
1910
1867
{
1911
1868
  switch(optid) {
1973
1930
      if (getaddrinfo(argument, NULL, &hints, &res_lst) != 0)
1974
1931
      {
1975
1932
          errmsg_printf(ERRMSG_LVL_ERROR, _("Can't start server: cannot resolve hostname!"));
1976
 
        exit(1);
 
1933
        return EXIT_ARGUMENT_INVALID;
1977
1934
      }
1978
1935
 
1979
1936
      if (res_lst->ai_next)
1980
1937
      {
1981
1938
          errmsg_printf(ERRMSG_LVL_ERROR, _("Can't start server: bind-address refers to "
1982
1939
                          "multiple interfaces!"));
1983
 
        exit(1);
 
1940
        return EXIT_ARGUMENT_INVALID;
1984
1941
      }
1985
1942
      freeaddrinfo(res_lst);
1986
1943
    }
2343
2300
  if (init_server_components(plugins))
2344
2301
    unireg_abort(1);
2345
2302
 
 
2303
  /**
 
2304
   * This check must be done after init_server_components for now
 
2305
   * because we don't yet have plugin dependency tracking...
 
2306
   *
 
2307
   * ReplicationServices::evaluateRegisteredPlugins() will print error messages to stderr
 
2308
   * via errmsg_printf().
 
2309
   *
 
2310
   * @todo
 
2311
   *
 
2312
   * not checking return since unireg_abort() hangs
 
2313
   */
 
2314
  ReplicationServices &replication_services= ReplicationServices::singleton();
 
2315
  (void) replication_services.evaluateRegisteredPlugins();
 
2316
 
2346
2317
  if (plugin::Listen::setup())
2347
2318
    unireg_abort(1);
2348
2319