~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Monty Taylor
  • Date: 2011-02-12 21:49:59 UTC
  • mto: (2165.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110212214959-bve8sh4hu761y48m
Updated the windows build to be able to build from the command line and not to show warnings on strncpy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
 
22
22
#include <drizzled/configmake.h>
23
23
#include <drizzled/atomics.h>
76
76
#include <drizzled/tztime.h>
77
77
#include <drizzled/unireg.h>
78
78
#include <plugin/myisam/myisam.h>
79
 
#include <drizzled/typelib.h>
80
 
#include <drizzled/visibility.h>
 
79
 
 
80
#include "drizzled/visibility.h"
81
81
 
82
82
#include <google/protobuf/stubs/common.h>
83
83
 
102
102
 
103
103
#include <errno.h>
104
104
#include <sys/stat.h>
105
 
#include <drizzled/option.h>
 
105
#include "drizzled/option.h"
106
106
#ifdef HAVE_SYSENT_H
107
107
#include <sysent.h>
108
108
#endif
136
136
#include <sys/fpu.h>
137
137
#endif
138
138
 
139
 
#include <drizzled/internal/my_pthread.h>                       // For thr_setconcurency()
140
 
#include <drizzled/constrained_value.h>
 
139
#include "drizzled/internal/my_pthread.h"                       // For thr_setconcurency()
 
140
#include "drizzled/constrained_value.h"
141
141
 
142
142
#include <drizzled/gettext.h>
143
143
 
308
308
fs::path system_config_dir(SYSCONFDIR);
309
309
 
310
310
 
 
311
char system_time_zone[30];
 
312
char *default_tz_name;
 
313
DRIZZLED_API char glob_hostname[FN_REFLEN];
 
314
 
311
315
char *opt_tc_log_file;
312
316
const key_map key_map_empty(0);
313
317
key_map key_map_full(0);                        // Will be initialized later
357
361
 
358
362
DRIZZLED_API size_t transaction_message_threshold;
359
363
 
 
364
/* Function declarations */
 
365
bool drizzle_rm_tmp_tables();
 
366
 
360
367
static void drizzle_init_variables(void);
361
368
static void get_options();
362
369
static void fix_paths();
366
373
 
367
374
fs::path base_plugin_dir(PKGPLUGINDIR);
368
375
 
369
 
po::options_description config_options(_("Config File Options"));
370
 
po::options_description long_options(_("Kernel Options"));
371
 
po::options_description plugin_load_options(_("Plugin Loading Options"));
372
 
po::options_description plugin_options(_("Plugin Options"));
373
 
po::options_description initial_options(_("Config and Plugin Loading"));
374
 
po::options_description full_options(_("Kernel and Plugin Loading and Plugin"));
 
376
po::options_description config_options("Config File Options");
 
377
po::options_description long_options("Kernel Options");
 
378
po::options_description plugin_load_options("Plugin Loading Options");
 
379
po::options_description plugin_options("Plugin Options");
 
380
po::options_description initial_options("Config and Plugin Loading");
 
381
po::options_description full_options("Kernel and Plugin Loading and Plugin");
375
382
vector<string> unknown_options;
376
383
vector<string> defaults_file_list;
377
384
po::variables_map vm;
381
388
  return vm;
382
389
}
383
390
 
384
 
namespace
385
 
{
386
 
 
387
 
std::string &getGlobHostname()
388
 
{
389
 
  static std::string glob_hostname("localhost");
390
 
  return glob_hostname;
391
 
}
392
 
 
393
 
void setServerHostname(const std::string &hostname)
394
 
{
395
 
  getGlobHostname()= hostname;
396
 
}
397
 
}
398
 
 
399
 
const std::string &getServerHostname()
400
 
{
401
 
  return getGlobHostname();
402
 
}
403
391
 
404
392
/****************************************************************************
405
393
** Code to end drizzled
665
653
 
666
654
static void find_plugin_dir(string progname)
667
655
{
668
 
  fs::path full_progname(fs::system_complete(progname));
669
 
 
670
 
  fs::path progdir(full_progname.parent_path());
671
 
  if (progdir.filename() == ".libs")
672
 
  {
673
 
    progdir= progdir.parent_path();
674
 
  }
675
 
 
676
 
  if (fs::exists(progdir / "drizzled.lo") || fs::exists(progdir / "drizzled.o"))
 
656
  if (progname[0] != FN_LIBCHAR)
 
657
  {
 
658
    /* We have a relative path and need to find the absolute */
 
659
    char working_dir[FN_REFLEN];
 
660
    char *working_dir_ptr= working_dir;
 
661
    working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
 
662
    string new_path(working_dir);
 
663
    if (*(new_path.end()-1) != '/')
 
664
      new_path.push_back('/');
 
665
    if (progname[0] == '.' && progname[1] == '/')
 
666
      new_path.append(progname.substr(2));
 
667
    else
 
668
      new_path.append(progname);
 
669
    progname.swap(new_path);
 
670
  }
 
671
 
 
672
  /* Now, trim off the exe name */
 
673
  string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
 
674
  if (progdir.rfind(".libs/") != string::npos)
 
675
  {
 
676
    progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
 
677
  }
 
678
  string testlofile(progdir);
 
679
  testlofile.append("drizzled.lo");
 
680
  string testofile(progdir);
 
681
  testofile.append("drizzled.o");
 
682
  struct stat testfile_stat;
 
683
  if (not (stat(testlofile.c_str(), &testfile_stat) && stat(testofile.c_str(), &testfile_stat)))
677
684
  {
678
685
    /* We are in a source dir! Plugin dir is ../plugin/.libs */
679
 
    base_plugin_dir= progdir.parent_path();
 
686
    size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
 
687
    base_plugin_dir= progdir.substr(0,last_libchar_pos);
680
688
    base_plugin_dir /= "plugin";
681
689
    base_plugin_dir /= ".libs";
682
690
  }
1091
1099
  drizzle_init_variables();
1092
1100
 
1093
1101
  find_plugin_dir(argv[0]);
 
1102
  {
 
1103
    struct tm tm_tmp;
 
1104
    localtime_r(&server_start_time,&tm_tmp);
 
1105
    strncpy(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0],
 
1106
            sizeof(system_time_zone)-1);
1094
1107
 
 
1108
  }
1095
1109
  /*
1096
1110
    We set SYSTEM time zone as reasonable default and
1097
1111
    also for failure of my_tz_init() and bootstrap mode.
1100
1114
  */
1101
1115
  global_system_variables.time_zone= my_tz_SYSTEM;
1102
1116
 
1103
 
  char ret_hostname[FN_REFLEN];
1104
 
  if (gethostname(ret_hostname,sizeof(ret_hostname)) < 0)
 
1117
  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
1105
1118
  {
1106
 
    errmsg_printf(error::WARN,
1107
 
                  _("gethostname failed, using '%s' as hostname"),
1108
 
                  getServerHostname().c_str());
 
1119
    strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
 
1120
    errmsg_printf(error::WARN, _("gethostname failed, using '%s' as hostname"),
 
1121
                  glob_hostname);
1109
1122
    pid_file= "drizzle";
1110
1123
  }
1111
1124
  else
1112
1125
  {
1113
 
    setServerHostname(ret_hostname);
1114
 
    pid_file= getServerHostname();
 
1126
    pid_file= glob_hostname;
1115
1127
  }
1116
1128
  pid_file.replace_extension(".pid");
1117
1129
 
1305
1317
  po::value<uint64_t>(&global_system_variables.tmp_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_tmp_table_size),
1306
1318
  _("If an internal in-memory temporary table exceeds this size, Drizzle will"
1307
1319
     " automatically convert it to an on-disk MyISAM table."))
1308
 
  ("verbose", po::value<std::string>()->default_value(error::verbose_string())->notifier(&error::check_verbosity),
1309
 
  _("The stack size for each thread."))
1310
1320
  ;
1311
1321
 
1312
1322
  full_options.add(long_options);