~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/multi_thread/multi_thread.cc

  • Committer: Lee Bieber
  • Date: 2011-01-04 18:54:52 UTC
  • mfrom: (2053.1.2 build)
  • Revision ID: kalebral@gmail.com-20110104185452-hnf41sloyoeh2e3a
Merge Joe - fix bug 696397: innodb storing bin log offset in trx sys header
Merge Monty - provide general abort exception to work along side BOOST_THROW_EXCEPTION

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
#include "config.h"
17
 
#include <plugin/multi_thread/multi_thread.h>
18
 
#include "drizzled/pthread_globals.h"
19
 
#include <boost/program_options.hpp>
 
17
 
 
18
#include <iostream>
 
19
 
 
20
#include <drizzled/pthread_globals.h>
20
21
#include <drizzled/module/option_map.h>
21
22
#include <drizzled/errmsg_print.h>
22
 
#include "drizzled/session.h"
23
 
#include "drizzled/session/cache.h"
 
23
#include <drizzled/session.h>
 
24
#include <drizzled/session/cache.h>
 
25
#include <drizzled/abort_exception.h>
 
26
#include <drizzled/transaction_services.h>
 
27
#include <drizzled/gettext.h>
24
28
 
25
29
#include <boost/thread.hpp>
26
30
#include <boost/bind.hpp>
 
31
#include <boost/program_options.hpp>
 
32
 
 
33
#include "multi_thread.h"
27
34
 
28
35
namespace po= boost::program_options;
29
36
using namespace std;
44
51
{
45
52
  char stack_dummy;
46
53
  boost::this_thread::disable_interruption disable_by_default;
 
54
 
47
55
  Session::shared_ptr session(session::Cache::singleton().find(id));
48
56
 
49
 
  if (not session)
50
 
  {
51
 
    std::cerr << "Session killed before thread could execute\n";
52
 
    return;
53
 
  }
54
 
  session->pushInterrupt(&disable_by_default);
55
 
 
56
 
  if (drizzled::internal::my_thread_init())
57
 
  {
58
 
    session->disconnect(drizzled::ER_OUT_OF_RESOURCES);
59
 
    session->status_var.aborted_connects++;
60
 
  }
61
 
  else
62
 
  {
63
 
    boost::this_thread::at_thread_exit(&internal::my_thread_end);
64
 
 
65
 
    session->thread_stack= (char*) &stack_dummy;
66
 
    session->run();
67
 
  }
68
 
 
69
 
  killSessionNow(session);
 
57
  try
 
58
  {
 
59
 
 
60
    if (not session)
 
61
    {
 
62
      std::cerr << _("Session killed before thread could execute") << endl;
 
63
      return;
 
64
    }
 
65
    session->pushInterrupt(&disable_by_default);
 
66
 
 
67
    if (drizzled::internal::my_thread_init())
 
68
    {
 
69
      session->disconnect(drizzled::ER_OUT_OF_RESOURCES);
 
70
      session->status_var.aborted_connects++;
 
71
    }
 
72
    else
 
73
    {
 
74
      boost::this_thread::at_thread_exit(&internal::my_thread_end);
 
75
 
 
76
      session->thread_stack= (char*) &stack_dummy;
 
77
      session->run();
 
78
    }
 
79
 
 
80
    killSessionNow(session);
 
81
  }
 
82
  catch (abort_exception& ex)
 
83
  {
 
84
    cout << _("Drizzle has receieved an abort event.") << endl;
 
85
    cout << _("In Function: ") << *::boost::get_error_info<boost::throw_function>(ex) << endl;
 
86
    cout << _("In File: ") << *::boost::get_error_info<boost::throw_file>(ex) << endl;
 
87
    cout << _("On Line: ") << *::boost::get_error_info<boost::throw_line>(ex) << endl;
 
88
 
 
89
    TransactionServices::singleton().sendShutdownEvent(session.get());
 
90
  }
70
91
  // @todo remove hard spin by disconnection the session first from the
71
92
  // thread.
72
93
  while (not session.unique()) {}