1
/* Copyright (C) 2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
#include <drizzled/server_includes.h>
17
#include <drizzled/gettext.h>
18
#include <drizzled/error.h>
19
#include <drizzled/plugin_scheduling.h>
20
#include <drizzled/serialize/serialize.h>
21
#include <drizzled/connect.h>
22
#include <drizzled/sql_parse.h>
23
#include <drizzled/session.h>
24
#include <drizzled/connect.h>
28
static bool isEnabled= true;
29
static bool init_dummy(void) {return 0;}
32
Simple scheduler that use the main thread to handle the request
35
This is only used for debugging, when starting mysqld with
36
--thread-handling=no-threads or --one-thread
38
When we enter this function, LOCK_thread_count is hold!
41
void handle_connection_in_main_thread(Session *session)
43
safe_mutex_assert_owner(&LOCK_thread_count);
44
(void) pthread_mutex_unlock(&LOCK_thread_count);
45
handle_one_connection((void*) session);
50
End connection, in case when we are using 'no-threads'
53
static bool end_thread(Session *session, bool)
55
unlink_session(session); /* locks LOCK_thread_count and deletes session */
56
pthread_mutex_unlock(&LOCK_thread_count);
58
return true; // Abort handle_one_connection
61
static int init(void *p)
63
scheduling_st* func= (scheduling_st *)p;
65
if (isEnabled == false)
73
func->add_connection= handle_connection_in_main_thread;
74
func->init_new_connection_thread= init_dummy;
75
func->end_thread= end_thread;
80
static int deinit(void *)
85
static DRIZZLE_SYSVAR_BOOL(enabled, isEnabled,
87
N_("Enable One Thread per Connection Scheduler"),
88
NULL, /* check func */
89
NULL, /* update func */
92
static struct st_mysql_sys_var* system_variables[]= {
93
DRIZZLE_SYSVAR(enabled),
97
mysql_declare_plugin(single_thread)
99
DRIZZLE_SCHEDULING_PLUGIN,
103
"Single Thread Scheduler",
105
init, /* Plugin Init */
106
deinit, /* Plugin Deinit */
107
NULL, /* status variables */
108
system_variables, /* system variables */
109
NULL /* config options */
111
mysql_declare_plugin_end;