48
48
#include "drizzled/gettext.h"
49
49
#include "drizzled/configmake.h"
50
50
#include "drizzled/session.h"
51
#include "drizzled/session_list.h"
51
52
#include "drizzled/internal/my_sys.h"
52
53
#include "drizzled/unireg.h"
53
54
#include "drizzled/drizzled.h"
333
333
TransactionServices &transaction_services= TransactionServices::singleton();
335
335
/* Send server startup event */
336
if ((session= new Session(plugin::Listen::getNullClient())))
338
currentSession().release();
339
currentSession().reset(session);
340
transaction_services.sendStartupEvent(session);
341
session->lockForDelete();
339
if ((session= new Session(plugin::Listen::getNullClient())))
341
currentSession().release();
342
currentSession().reset(session);
343
transaction_services.sendStartupEvent(session);
348
351
should be shutdown. */
349
352
while ((client= plugin::Listen::getClient()) != NULL)
351
if (!(session= new Session(client)))
354
Session::shared_ptr session(new Session(client));
357
362
/* If we error on creation we drop the connection and delete the session. */
358
if (session->schedule())
363
if (Session::schedule(session))
359
364
Session::unlink(session);
362
367
/* Send server shutdown event */
363
if ((session= new Session(plugin::Listen::getNullClient())))
365
currentSession().release();
366
currentSession().reset(session);
367
transaction_services.sendShutdownEvent(session);
368
session->lockForDelete();
372
LOCK_thread_count.lock();
373
select_thread_in_use=0; // For close_connections
374
LOCK_thread_count.unlock();
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
375
384
COND_thread_count.notify_all();
377
386
/* Wait until cleanup is done */
379
boost::mutex::scoped_lock scopedLock(LOCK_thread_count);
380
while (!ready_to_exit)
388
boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
389
while (not ready_to_exit)
381
390
COND_server_end.wait(scopedLock);