~thomir-deactivatedaccount/drizzle/drizzle-fix-bug653747

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Brian Aker
  • Date: 2010-10-10 02:07:52 UTC
  • mfrom: (1827.2.3 staging)
  • Revision ID: brian@tangent.org-20101010020752-ktv73isay5dxtvp3
Merge in switch on table_share_instance inheritance.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include "drizzled/program_options/config_file.h"
35
35
#include <boost/thread/recursive_mutex.hpp>
36
36
#include <boost/thread/mutex.hpp>
37
 
#include <boost/thread/shared_mutex.hpp>
38
37
#include <boost/thread/condition_variable.hpp>
39
38
#include <boost/filesystem.hpp>
40
39
 
67
66
#include "drizzled/module/registry.h"
68
67
#include "drizzled/module/load_list.h"
69
68
 
70
 
#include "drizzled/plugin/event_observer.h"
71
 
 
72
69
#include <google/protobuf/stubs/common.h>
73
70
 
74
71
#if TIME_WITH_SYS_TIME
338
335
boost::mutex LOCK_global_system_variables;
339
336
boost::mutex LOCK_thread_count;
340
337
 
341
 
boost::condition_variable_any COND_refresh;
 
338
boost::condition_variable COND_refresh;
342
339
boost::condition_variable COND_thread_count;
343
340
pthread_t signal_thread;
344
341
boost::condition_variable COND_server_end;
435
432
 
436
433
  Session *tmp;
437
434
 
 
435
  LOCK_thread_count.lock(); // For unlink from list
 
436
 
 
437
  for( SessionList::iterator it= getSessionList().begin(); it != getSessionList().end(); ++it )
438
438
  {
439
 
    boost::mutex::scoped_lock scoped(LOCK_thread_count);
440
 
    for( SessionList::iterator it= getSessionList().begin(); it != getSessionList().end(); ++it )
441
 
    {
442
 
      tmp= *it;
443
 
      tmp->killed= Session::KILL_CONNECTION;
444
 
      tmp->scheduler->killSession(tmp);
445
 
      DRIZZLE_CONNECTION_DONE(tmp->thread_id);
446
 
      tmp->lockOnSys();
447
 
    }
 
439
    tmp= *it;
 
440
    tmp->killed= Session::KILL_CONNECTION;
 
441
    tmp->scheduler->killSession(tmp);
 
442
    DRIZZLE_CONNECTION_DONE(tmp->thread_id);
 
443
    tmp->lockOnSys();
448
444
  }
 
445
  LOCK_thread_count.unlock(); // For unlink from list
449
446
 
450
447
  if (connection_count)
451
448
    sleep(2);                                   // Give threads time to die
457
454
  */
458
455
  for (;;)
459
456
  {
460
 
    boost::mutex::scoped_lock scoped(LOCK_thread_count);
 
457
    LOCK_thread_count.lock(); // For unlink from list
461
458
    if (getSessionList().empty())
462
459
    {
 
460
      LOCK_thread_count.unlock();
463
461
      break;
464
462
    }
465
463
    tmp= getSessionList().front();
466
464
    /* Close before unlock, avoiding crash. See LP bug#436685 */
467
465
    tmp->client->close();
 
466
    LOCK_thread_count.unlock();
468
467
  }
469
468
}
470
469
 
 
470
/**
 
471
  cleanup all memory and end program nicely.
 
472
 
 
473
    If SIGNALS_DONT_BREAK_READ is defined, this function is called
 
474
    by the main thread. To get Drizzle to shut down nicely in this case
 
475
    (Mac OS X) we have to call exit() instead if pthread_exit().
 
476
 
 
477
  @note
 
478
    This function never returns.
 
479
*/
 
480
void unireg_end(void)
 
481
{
 
482
  clean_up(1);
 
483
  internal::my_thread_end();
 
484
#if defined(SIGNALS_DONT_BREAK_READ)
 
485
  exit(0);
 
486
#else
 
487
  pthread_exit(0);                              // Exit is in main thread
 
488
#endif
 
489
}
 
490
 
471
491
 
472
492
void unireg_abort(int exit_code)
473
493
{
624
644
 
625
645
  session->cleanup();
626
646
 
627
 
  boost::mutex::scoped_lock scoped(LOCK_thread_count);
 
647
  LOCK_thread_count.lock();
628
648
  session->lockForDelete();
629
649
 
630
650
  getSessionList().erase(remove(getSessionList().begin(),
631
651
                         getSessionList().end(),
632
652
                         session));
633
 
  if (unlikely(plugin::EventObserver::disconnectSession(*session)))
634
 
  {
635
 
    // We should do something about an error...
636
 
  }
637
653
 
638
654
  delete session;
 
655
  LOCK_thread_count.unlock();
639
656
}
640
657
 
641
658