48
48
#include "drizzled/gettext.h"
49
49
#include "drizzled/configmake.h"
50
50
#include "drizzled/session.h"
51
#include "drizzled/session/cache.h"
52
51
#include "drizzled/internal/my_sys.h"
53
52
#include "drizzled/unireg.h"
54
53
#include "drizzled/drizzled.h"
60
59
#include "drizzled/tztime.h"
61
60
#include "drizzled/signal_handler.h"
62
61
#include "drizzled/replication_services.h"
63
#include "drizzled/transaction_services.h"
65
#include "drizzled/util/backtrace.h"
67
63
using namespace drizzled;
68
64
using namespace std;
262
256
if (not opt_help)
264
if (chdir(getDataHome().file_string().c_str()))
258
if (chdir(getDataHome().c_str()))
266
260
errmsg_printf(ERRMSG_LVL_ERROR,
267
261
_("Data directory %s does not exist\n"),
268
getDataHome().file_string().c_str());
262
getDataHome().c_str());
271
265
if (mkdir("local", 0700))
277
271
errmsg_printf(ERRMSG_LVL_ERROR,
278
272
_("Local catalog %s/local does not exist\n"),
279
getDataHome().file_string().c_str());
273
getDataHome().c_str());
283
full_data_home= fs::system_complete(getDataHome());
276
/* TODO: This is a hack until we can properly support std::string in sys_var*/
277
char **data_home_ptr= getDatadirPtr();
278
fs::path full_data_home_path(fs::system_complete(fs::path(getDataHome())));
279
std::string full_data_home(full_data_home_path.file_string());
280
*data_home_ptr= new char[full_data_home.size()+1] ();
281
memcpy(*data_home_ptr, full_data_home.c_str(), full_data_home.size());
284
282
getDataHomeCatalog()= "./";
285
283
getDataHome()= "../";
330
328
PANDORA_RELEASE_VERSION, COMPILATION_COMMENT);
333
TransactionServices &transaction_services= TransactionServices::singleton();
335
/* Send server startup event */
339
if ((session= new Session(plugin::Listen::getNullClient())))
341
currentSession().release();
342
currentSession().reset(session);
343
transaction_services.sendStartupEvent(session);
349
331
/* Listen for new connections and start new session for each connection
350
332
accepted. The listen.getClient() method will return NULL when the server
351
333
should be shutdown. */
352
334
while ((client= plugin::Listen::getClient()) != NULL)
354
Session::shared_ptr session(new Session(client));
336
if (!(session= new Session(client)))
362
342
/* If we error on creation we drop the connection and delete the session. */
363
if (Session::schedule(session))
343
if (session->schedule())
364
344
Session::unlink(session);
367
/* Send server shutdown event */
371
if ((session= new Session(plugin::Listen::getNullClient())))
373
currentSession().release();
374
currentSession().reset(session);
375
transaction_services.sendShutdownEvent(session);
381
boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
382
select_thread_in_use= false; // For close_connections
347
LOCK_thread_count.lock();
348
select_thread_in_use=0; // For close_connections
349
LOCK_thread_count.unlock();
384
350
COND_thread_count.notify_all();
386
352
/* Wait until cleanup is done */
388
boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
389
while (not ready_to_exit)
354
boost::mutex::scoped_lock scopedLock(LOCK_thread_count);
355
while (!ready_to_exit)
390
356
COND_server_end.wait(scopedLock);