68
68
#include "drizzled/module/load_list.h"
69
69
#include "drizzled/global_buffer.h"
71
#include "drizzled/definition/cache.h"
71
73
#include "drizzled/plugin/event_observer.h"
75
#include "drizzled/message/cache.h"
73
77
#include <google/protobuf/stubs/common.h>
75
79
#if TIME_WITH_SYS_TIME
335
339
SHOW_COMP_OPTION have_symlink;
337
341
/* Thread specific variables */
339
boost::mutex LOCK_open;
340
342
boost::mutex LOCK_global_system_variables;
341
boost::mutex LOCK_thread_count;
343
344
boost::condition_variable_any COND_refresh;
344
345
boost::condition_variable COND_thread_count;
440
441
statements and inform their clients that the server is about to die.
446
boost::mutex::scoped_lock scoped(LOCK_thread_count);
447
for( SessionList::iterator it= getSessionList().begin(); it != getSessionList().end(); ++it )
445
boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
446
session::Cache::List list= session::Cache::singleton().getCache();
448
for (session::Cache::List::iterator it= list.begin(); it != list.end(); ++it )
450
Session::shared_ptr tmp(*it);
450
452
tmp->setKilled(Session::KILL_CONNECTION);
451
tmp->scheduler->killSession(tmp);
453
tmp->scheduler->killSession(tmp.get());
452
454
DRIZZLE_CONNECTION_DONE(tmp->thread_id);
453
455
tmp->lockOnSys();
457
if (connection_count)
459
if (session::Cache::singleton().count())
458
460
sleep(2); // Give threads time to die
467
boost::mutex::scoped_lock scoped(LOCK_thread_count);
468
if (getSessionList().empty())
469
boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
470
session::Cache::List list= session::Cache::singleton().getCache();
472
tmp= getSessionList().front();
473
476
/* Close before unlock, avoiding crash. See LP bug#436685 */
474
tmp->client->close();
477
list.front()->client->close();
511
514
if (print_message && server_start_time)
512
515
errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
513
LOCK_thread_count.lock();
515
/* do the broadcast inside the lock to ensure that my_end() is not called */
516
COND_server_end.notify_all();
517
LOCK_thread_count.unlock();
517
boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
520
/* do the broadcast inside the lock to ensure that my_end() is not called */
521
COND_server_end.notify_all();
520
525
The following lines may never be executed as the main thread may have
621
626
Session::unlink()
622
627
session Thread handler
625
LOCK_thread_count is locked and left locked
628
void Session::unlink(Session *session)
630
void drizzled::Session::unlink(Session::shared_ptr &session)
630
632
connection_count.decrement();
632
634
session->cleanup();
634
boost::mutex::scoped_lock scoped(LOCK_thread_count);
635
session->lockForDelete();
636
boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
637
getSessionList().erase(remove(getSessionList().begin(),
638
getSessionList().end(),
640
638
if (unlikely(plugin::EventObserver::disconnectSession(*session)))
642
640
// We should do something about an error...
642
session::Cache::singleton().erase(session);
1044
1041
global_system_variables.transaction_message_threshold= in_transaction_message_threshold;
1047
static pair<string, string> parse_size_suffixes(string s)
1049
size_t equal_pos= s.find("=");
1050
if (equal_pos != string::npos)
1052
string arg_key(s.substr(0, equal_pos));
1053
string arg_val(s.substr(equal_pos+1));
1057
size_t size_suffix_pos= arg_val.find_last_of("kmgKMG");
1058
if (size_suffix_pos == arg_val.size()-1)
1060
char suffix= arg_val[size_suffix_pos];
1061
string size_val(arg_val.substr(0, size_suffix_pos));
1063
uint64_t base_size= boost::lexical_cast<uint64_t>(size_val);
1064
uint64_t new_size= 0;
1070
new_size= base_size * 1024;
1074
new_size= base_size * 1024 * 1024;
1078
new_size= base_size * 1024 * 1024 * 1024;
1081
return make_pair(arg_key,
1082
boost::lexical_cast<string>(new_size));
1087
/* Screw it, let the normal parser take over */
1091
return make_pair(string(""), string(""));
1094
static pair<string, string> parse_size_arg(string s)
1096
if (s.find("--") == 0)
1098
return parse_size_suffixes(s.substr(2));
1100
return make_pair(string(""), string(""));
1103
1044
static void process_defaults_files()
1105
1046
for (vector<string>::iterator iter= defaults_file_list.begin();
1205
1146
pid_file.replace_extension(".pid");
1207
1148
system_config_dir /= "drizzle";
1208
std::string system_config_file_drizzle("drizzled.cnf");
1210
1150
config_options.add_options()
1211
1151
("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1268
1208
N_("Pid file used by drizzled."))
1269
1209
("port-open-timeout", po::value<uint32_t>(&drizzled_bind_timeout)->default_value(0),
1270
1210
N_("Maximum time in seconds to wait for the port to become free. "))
1211
("replicate-query", po::value<bool>(&global_system_variables.replicate_query)->default_value(false)->zero_tokens(),
1212
N_("Include the SQL query in replicated protobuf messages."))
1271
1213
("secure-file-priv", po::value<fs::path>(&secure_file_priv)->notifier(expand_secure_file_priv),
1272
1214
N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1273
1215
"within specified directory"))
1422
1364
if (not vm["no-defaults"].as<bool>())
1366
fs::path system_config_file_drizzle(system_config_dir);
1367
system_config_file_drizzle /= "drizzled.cnf";
1424
1368
defaults_file_list.insert(defaults_file_list.begin(),
1425
system_config_file_drizzle);
1369
system_config_file_drizzle.file_string());
1427
1371
fs::path config_conf_d_location(system_config_dir);
1428
1372
config_conf_d_location /= "conf.d";
1430
1375
CachedDirectory config_conf_d(config_conf_d_location.file_string());
1431
1376
if (not config_conf_d.fail())
1501
1446
po::parsed_options final_parsed=
1502
1447
po::command_line_parser(unknown_options).style(style).
1503
options(full_options).extra_parser(parse_size_arg).run();
1448
options(full_options).extra_parser(dpo::parse_size_arg).run();
1505
1450
final_unknown_options=
1506
1451
po::collect_unrecognized(final_parsed.options, po::include_positional);
2191
2138
session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_SQL_NOTES);
2192
2139
refresh_version= 1L; /* Increments on each reload */
2193
2140
global_thread_id= 1UL;
2194
getSessionList().clear();
2141
session::Cache::singleton().getCache().clear();
2196
2143
/* Variables in libraries */
2197
2144
default_character_set_name= "utf8";