~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/main.cc

  • Committer: Lee Bieber
  • Date: 2010-11-18 15:33:33 UTC
  • mfrom: (1932.3.14 trunk)
  • Revision ID: kalebral@gmail.com-20101118153333-1onwy3lvwmxltqdn
Merge Brian - more session work and clean up

Show diffs side-by-side

added added

removed removed

Lines of Context:
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"
232
233
 
233
234
  module::Registry &modules= module::Registry::singleton();
234
235
  plugin::Client *client;
235
 
  Session *session;
236
236
 
237
237
  MY_INIT(argv[0]);             // init my_sys library & pthreads
238
238
  /* nothing should come before this line ^^^ */
333
333
  TransactionServices &transaction_services= TransactionServices::singleton();
334
334
 
335
335
  /* Send server startup event */
336
 
  if ((session= new Session(plugin::Listen::getNullClient())))
337
336
  {
338
 
    currentSession().release();
339
 
    currentSession().reset(session);
340
 
    transaction_services.sendStartupEvent(session);
341
 
    session->lockForDelete();
342
 
    delete session;
 
337
    Session *session;
 
338
 
 
339
    if ((session= new Session(plugin::Listen::getNullClient())))
 
340
    {
 
341
      currentSession().release();
 
342
      currentSession().reset(session);
 
343
      transaction_services.sendStartupEvent(session);
 
344
      delete session;
 
345
    }
343
346
  }
344
347
 
345
348
 
348
351
     should be shutdown. */
349
352
  while ((client= plugin::Listen::getClient()) != NULL)
350
353
  {
351
 
    if (!(session= new Session(client)))
 
354
    Session::shared_ptr session(new Session(client));
 
355
 
 
356
    if (not session)
352
357
    {
353
358
      delete client;
354
359
      continue;
355
360
    }
356
361
 
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);
360
365
  }
361
366
 
362
367
  /* Send server shutdown event */
363
 
  if ((session= new Session(plugin::Listen::getNullClient())))
364
 
  {
365
 
    currentSession().release();
366
 
    currentSession().reset(session);
367
 
    transaction_services.sendShutdownEvent(session);
368
 
    session->lockForDelete();
369
 
    delete session;
370
 
  }
371
 
 
372
 
  LOCK_thread_count.lock();
373
 
  select_thread_in_use=0;                       // For close_connections
374
 
  LOCK_thread_count.unlock();
 
368
  {
 
369
    Session *session;
 
370
 
 
371
    if ((session= new Session(plugin::Listen::getNullClient())))
 
372
    {
 
373
      currentSession().release();
 
374
      currentSession().reset(session);
 
375
      transaction_services.sendShutdownEvent(session);
 
376
      delete session;
 
377
    }
 
378
  }
 
379
 
 
380
  {
 
381
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
 
382
    select_thread_in_use= false;                        // For close_connections
 
383
  }
375
384
  COND_thread_count.notify_all();
376
385
 
377
386
  /* Wait until cleanup is done */
378
387
  {
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);
382
391
  }
383
392