~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/main.cc

  • Committer: Monty Taylor
  • Date: 2010-11-08 18:26:08 UTC
  • mto: This revision was merged to the branch mainline in revision 1931.
  • Revision ID: mordred@inaugust.com-20101108182608-lci86acl7r53sbi3
Replaced auto_ptr with scoped_ptr.

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/cache.h"
52
51
#include "drizzled/internal/my_sys.h"
53
52
#include "drizzled/unireg.h"
54
53
#include "drizzled/drizzled.h"
233
232
 
234
233
  module::Registry &modules= module::Registry::singleton();
235
234
  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())))
336
337
  {
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
 
    }
 
338
    currentSession().release();
 
339
    currentSession().reset(session);
 
340
    transaction_services.sendStartupEvent(session);
 
341
    session->lockForDelete();
 
342
    delete session;
346
343
  }
347
344
 
348
345
 
351
348
     should be shutdown. */
352
349
  while ((client= plugin::Listen::getClient()) != NULL)
353
350
  {
354
 
    Session::shared_ptr session(new Session(client));
355
 
 
356
 
    if (not session)
 
351
    if (!(session= new Session(client)))
357
352
    {
358
353
      delete client;
359
354
      continue;
360
355
    }
361
356
 
362
357
    /* If we error on creation we drop the connection and delete the session. */
363
 
    if (Session::schedule(session))
 
358
    if (session->schedule())
364
359
      Session::unlink(session);
365
360
  }
366
361
 
367
362
  /* Send server shutdown event */
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
 
  }
 
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();
384
375
  COND_thread_count.notify_all();
385
376
 
386
377
  /* Wait until cleanup is done */
387
378
  {
388
 
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
389
 
    while (not ready_to_exit)
 
379
    boost::mutex::scoped_lock scopedLock(LOCK_thread_count);
 
380
    while (!ready_to_exit)
390
381
      COND_server_end.wait(scopedLock);
391
382
  }
392
383