1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; version 2 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
*/
|
|
19 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
20 |
#include <config.h> |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
21 |
|
22 |
#include <pthread.h> |
|
23 |
#include <signal.h> |
|
24 |
#include <sys/resource.h> |
|
25 |
#include <unistd.h> |
|
1786.3.1
by Monty Taylor
Initial working local catalog. |
26 |
#include <sys/stat.h> |
27 |
#include <sys/types.h> |
|
28 |
||
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
29 |
|
30 |
#if TIME_WITH_SYS_TIME
|
|
31 |
# include <sys/time.h>
|
|
32 |
# include <time.h>
|
|
33 |
#else
|
|
34 |
# if HAVE_SYS_TIME_H
|
|
35 |
# include <sys/time.h>
|
|
36 |
# else
|
|
37 |
# include <time.h>
|
|
38 |
# endif
|
|
39 |
#endif
|
|
40 |
||
1300.5.7
by Monty Taylor
Fixed Sun Studio issues. |
41 |
#if defined(HAVE_LOCALE_H)
|
42 |
# include <locale.h>
|
|
43 |
#endif
|
|
44 |
||
1791.3.5
by mordred
Now lets get the proper values into these bad boys. |
45 |
#include <boost/filesystem.hpp> |
1300.5.7
by Monty Taylor
Fixed Sun Studio issues. |
46 |
|
2148.7.12
by Brian Aker
Merge in header fixes. |
47 |
#include <drizzled/abort_exception.h> |
48 |
#include <drizzled/catalog/local.h> |
|
49 |
#include <drizzled/configmake.h> |
|
50 |
#include <drizzled/data_home.h> |
|
2104.3.3
by Brian Aker
Cleanup test flags for debug options on server startup |
51 |
#include <drizzled/debug.h> |
2148.7.12
by Brian Aker
Merge in header fixes. |
52 |
#include <drizzled/drizzled.h> |
53 |
#include <drizzled/errmsg_print.h> |
|
54 |
#include <drizzled/gettext.h> |
|
55 |
#include <drizzled/internal/my_sys.h> |
|
56 |
#include <drizzled/plugin.h> |
|
57 |
#include <drizzled/plugin/client.h> |
|
58 |
#include <drizzled/plugin/listen.h> |
|
59 |
#include <drizzled/plugin/monitored_in_transaction.h> |
|
60 |
#include <drizzled/pthread_globals.h> |
|
61 |
#include <drizzled/replication_services.h> |
|
62 |
#include <drizzled/session.h> |
|
63 |
#include <drizzled/session/cache.h> |
|
64 |
#include <drizzled/signal_handler.h> |
|
65 |
#include <drizzled/transaction_services.h> |
|
66 |
#include <drizzled/unireg.h> |
|
67 |
#include <drizzled/util/backtrace.h> |
|
2154.2.24
by Brian Aker
Merge in all changes for current_session, etc. |
68 |
#include <drizzled/current_session.h> |
2167.2.1
by Monty Taylor
C++-ize daemon.c. Our codebase is c++. |
69 |
#include <drizzled/daemon.h> |
2239.1.5
by Olaf van der Spek
Refactor includes |
70 |
#include <drizzled/diagnostics_area.h> |
2227.4.3
by Olaf van der Spek
Remove unnecessary statement.h include |
71 |
#include <drizzled/sql_base.h> |
2234.1.3
by Olaf van der Spek
Refactor includes |
72 |
#include <drizzled/sql_lex.h> |
2241.3.2
by Olaf van der Spek
Refactor Session::variables |
73 |
#include <drizzled/system_variables.h> |
2131.10.1
by Stewart Smith
add a very simple --daemon or -d option to drizzled using the exact same code as memcached to start as a daemon. |
74 |
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
75 |
using namespace drizzled; |
76 |
using namespace std; |
|
77 |
||
78 |
static pthread_t select_thread; |
|
79 |
static uint32_t thr_kill_signal; |
|
80 |
||
2131.10.1
by Stewart Smith
add a very simple --daemon or -d option to drizzled using the exact same code as memcached to start as a daemon. |
81 |
extern bool opt_daemon; |
82 |
||
1791.3.4
by mordred
Well, so handing pointers returned by std::string::c_str() is a bad idea anyway - but you certainly shouldn't do it in static initializers before you do all of your changes to the string. Sigh. |
83 |
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
84 |
/**
|
85 |
All global error messages are sent here where the first one is stored
|
|
86 |
for the client.
|
|
87 |
*/
|
|
2087.3.1
by Brian Aker
Entire convert over to time_t. |
88 |
static void my_message_sql(drizzled::error_t error, const char *str, myf MyFlags) |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
89 |
{
|
2281.4.2
by Olaf van der Spek
Prune |
90 |
Session* session= current_session; |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
91 |
/*
|
92 |
Put here following assertion when situation with EE_* error codes
|
|
93 |
will be fixed
|
|
94 |
*/
|
|
2281.4.2
by Olaf van der Spek
Prune |
95 |
if (session) |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
96 |
{
|
97 |
if (MyFlags & ME_FATALERROR) |
|
98 |
session->is_fatal_error= 1; |
|
99 |
||
100 |
/*
|
|
2137.1.13
by Brian Aker
Fix bad error in warnings/errors. |
101 |
@TODO There are two exceptions mechanism (Session and sp_rcontext),
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
102 |
this could be improved by having a common stack of handlers.
|
2281.4.2
by Olaf van der Spek
Prune |
103 |
|
2137.1.13
by Brian Aker
Fix bad error in warnings/errors. |
104 |
if (session->handle_error(error, str, DRIZZLE_ERROR::WARN_LEVEL_ERROR))
|
105 |
return;
|
|
2281.4.2
by Olaf van der Spek
Prune |
106 |
*/
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
107 |
|
108 |
/*
|
|
2227.4.8
by Olaf van der Spek
Session::lex() |
109 |
session->lex().current_select == 0 if lex structure is not inited
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
110 |
(not query command (COM_QUERY))
|
111 |
*/
|
|
2227.4.8
by Olaf van der Spek
Session::lex() |
112 |
if (! (session->lex().current_select && |
113 |
session->lex().current_select->no_error && !session->is_fatal_error)) |
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
114 |
{
|
2239.1.4
by Olaf van der Spek
Refactor includes |
115 |
if (! session->main_da().is_error()) // Return only first message |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
116 |
{
|
2087.3.1
by Brian Aker
Entire convert over to time_t. |
117 |
if (error == EE_OK) |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
118 |
error= ER_UNKNOWN_ERROR; |
2087.3.1
by Brian Aker
Entire convert over to time_t. |
119 |
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
120 |
if (str == NULL) |
121 |
str= ER(error); |
|
2087.3.1
by Brian Aker
Entire convert over to time_t. |
122 |
|
2239.1.4
by Olaf van der Spek
Refactor includes |
123 |
session->main_da().set_error_status(error, str); |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
124 |
}
|
125 |
}
|
|
126 |
||
127 |
if (!session->no_warnings_for_error && !session->is_fatal_error) |
|
128 |
{
|
|
129 |
/*
|
|
130 |
Suppress infinite recursion if there a memory allocation error
|
|
131 |
inside push_warning.
|
|
132 |
*/
|
|
133 |
session->no_warnings_for_error= true; |
|
134 |
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, error, str); |
|
135 |
session->no_warnings_for_error= false; |
|
136 |
}
|
|
2137.1.13
by Brian Aker
Fix bad error in warnings/errors. |
137 |
}
|
2104.3.3
by Brian Aker
Cleanup test flags for debug options on server startup |
138 |
|
2137.1.13
by Brian Aker
Fix bad error in warnings/errors. |
139 |
if (not session || MyFlags & ME_NOREFRESH) |
140 |
{
|
|
141 |
errmsg_printf(error::ERROR, "%s: %s",internal::my_progname,str); |
|
142 |
}
|
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
143 |
}
|
144 |
||
145 |
static void init_signals(void) |
|
146 |
{
|
|
147 |
sigset_t set; |
|
148 |
struct sigaction sa; |
|
149 |
||
2227.4.3
by Olaf van der Spek
Remove unnecessary statement.h include |
150 |
if (not (getDebug().test(debug::NO_STACKTRACE) || |
2104.3.3
by Brian Aker
Cleanup test flags for debug options on server startup |
151 |
getDebug().test(debug::CORE_ON_SIGNAL))) |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
152 |
{
|
153 |
sa.sa_flags = SA_RESETHAND | SA_NODEFER; |
|
154 |
sigemptyset(&sa.sa_mask); |
|
155 |
sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL); |
|
156 |
||
157 |
sa.sa_handler= drizzled_handle_segfault; |
|
158 |
sigaction(SIGSEGV, &sa, NULL); |
|
159 |
sigaction(SIGABRT, &sa, NULL); |
|
160 |
#ifdef SIGBUS
|
|
161 |
sigaction(SIGBUS, &sa, NULL); |
|
162 |
#endif
|
|
163 |
sigaction(SIGILL, &sa, NULL); |
|
164 |
sigaction(SIGFPE, &sa, NULL); |
|
165 |
}
|
|
166 |
||
2104.3.3
by Brian Aker
Cleanup test flags for debug options on server startup |
167 |
if (getDebug().test(debug::CORE_ON_SIGNAL)) |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
168 |
{
|
169 |
/* Change limits so that we will get a core file */
|
|
170 |
struct rlimit rl; |
|
171 |
rl.rlim_cur = rl.rlim_max = RLIM_INFINITY; |
|
172 |
if (setrlimit(RLIMIT_CORE, &rl) && global_system_variables.log_warnings) |
|
2126.3.3
by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch. |
173 |
errmsg_printf(error::WARN, |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
174 |
_("setrlimit could not change the size of core files " |
175 |
"to 'infinity'; We may not be able to generate a "
|
|
176 |
"core file on signals")); |
|
177 |
}
|
|
178 |
(void) sigemptyset(&set); |
|
1300.5.23
by Monty Taylor
Merged in revs removing depend on the plugin tree. |
179 |
ignore_signal(SIGPIPE); |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
180 |
sigaddset(&set,SIGPIPE); |
181 |
#ifndef IGNORE_SIGHUP_SIGQUIT
|
|
182 |
sigaddset(&set,SIGQUIT); |
|
183 |
sigaddset(&set,SIGHUP); |
|
184 |
#endif
|
|
185 |
sigaddset(&set,SIGTERM); |
|
186 |
||
187 |
/* Fix signals if blocked by parents (can happen on Mac OS X) */
|
|
188 |
sigemptyset(&sa.sa_mask); |
|
189 |
sa.sa_flags = 0; |
|
190 |
sa.sa_handler = drizzled_print_signal_warning; |
|
1300.5.23
by Monty Taylor
Merged in revs removing depend on the plugin tree. |
191 |
sigaction(SIGTERM, &sa, NULL); |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
192 |
sa.sa_flags = 0; |
193 |
sa.sa_handler = drizzled_print_signal_warning; |
|
1300.5.23
by Monty Taylor
Merged in revs removing depend on the plugin tree. |
194 |
sigaction(SIGHUP, &sa, NULL); |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
195 |
#ifdef SIGTSTP
|
196 |
sigaddset(&set,SIGTSTP); |
|
197 |
#endif
|
|
2104.3.3
by Brian Aker
Cleanup test flags for debug options on server startup |
198 |
if (getDebug().test(debug::ALLOW_SIGINT)) |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
199 |
{
|
1300.5.23
by Monty Taylor
Merged in revs removing depend on the plugin tree. |
200 |
sa.sa_flags= 0; |
201 |
sa.sa_handler= drizzled_end_thread_signal; |
|
202 |
sigaction(thr_kill_signal, &sa, NULL); |
|
203 |
||
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
204 |
// May be SIGINT
|
205 |
sigdelset(&set, thr_kill_signal); |
|
206 |
}
|
|
207 |
else
|
|
1608.1.2
by Brian Aker
Merge enum test |
208 |
{
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
209 |
sigaddset(&set,SIGINT); |
1608.1.2
by Brian Aker
Merge enum test |
210 |
}
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
211 |
sigprocmask(SIG_SETMASK,&set,NULL); |
212 |
pthread_sigmask(SIG_SETMASK,&set,NULL); |
|
1300.5.23
by Monty Taylor
Merged in revs removing depend on the plugin tree. |
213 |
return; |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
214 |
}
|
215 |
||
2017.2.1
by Brian Aker
Cleanup error messages around bad table definitions. |
216 |
static void GoogleProtoErrorThrower(google::protobuf::LogLevel level, |
217 |
const char* , |
|
218 |
int, const string& ) throw(const char *) |
|
1608.1.2
by Brian Aker
Merge enum test |
219 |
{
|
220 |
switch(level) |
|
221 |
{
|
|
222 |
case google::protobuf::LOGLEVEL_INFO: |
|
223 |
break; |
|
224 |
case google::protobuf::LOGLEVEL_WARNING: |
|
225 |
case google::protobuf::LOGLEVEL_ERROR: |
|
226 |
case google::protobuf::LOGLEVEL_FATAL: |
|
227 |
default: |
|
228 |
throw("error in google protocol buffer parsing"); |
|
229 |
}
|
|
230 |
}
|
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
231 |
|
232 |
int main(int argc, char **argv) |
|
233 |
{
|
|
234 |
#if defined(ENABLE_NLS)
|
|
235 |
# if defined(HAVE_LOCALE_H)
|
|
236 |
setlocale(LC_ALL, ""); |
|
237 |
# endif
|
|
2068.4.1
by Andrew Hutchings
Fix intl domain |
238 |
bindtextdomain("drizzle7", LOCALEDIR); |
239 |
textdomain("drizzle7"); |
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
240 |
#endif
|
241 |
||
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
242 |
module::Registry &modules= module::Registry::singleton(); |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
243 |
|
2385.3.9
by Olaf van der Spek
Move flush() into iocache |
244 |
drizzled::internal::my_progname= argv[0]; |
245 |
drizzled::internal::my_init(); |
|
246 |
||
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
247 |
/* nothing should come before this line ^^^ */
|
248 |
||
249 |
/* Set signal used to kill Drizzle */
|
|
250 |
thr_kill_signal= SIGINT; |
|
251 |
||
1608.1.2
by Brian Aker
Merge enum test |
252 |
google::protobuf::SetLogHandler(&GoogleProtoErrorThrower); |
253 |
||
1743.4.1
by LinuxJedi
Make sure unireg_abort shows the reason for the fail. |
254 |
/* Function generates error messages before abort */
|
1794.3.5
by Monty Taylor
Fixed temporoary dir sequencing. |
255 |
error_handler_hook= my_message_sql; |
2131.10.7
by Stewart Smith
partition the initialisation of variables and command line options into two phases: the first being the simple one (that we can get out the --daemon option for) and the second being loading plugins, pidfile setup etc. This makes --daemon do the pidfile correctly. |
256 |
|
2363.1.6
by Brian Aker
Add better error messages for issues on startup. |
257 |
/* init_common_variables must get basic settings such as data_home_dir and plugin_load_list. */
|
258 |
if (not init_variables_before_daemonizing(argc, argv)) |
|
259 |
{
|
|
260 |
unireg_abort << "init_variables_before_daemonizing() failed"; // Will do exit |
|
261 |
}
|
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
262 |
|
2392.1.1
by Brian Aker
Fixes for --help work. |
263 |
if (opt_daemon and was_help_requested() == false) |
2131.10.1
by Stewart Smith
add a very simple --daemon or -d option to drizzled using the exact same code as memcached to start as a daemon. |
264 |
{
|
2131.10.8
by Stewart Smith
using signal() instead of sigignore() as it's compatible with FreeBSD < 8.1 |
265 |
if (signal(SIGHUP, SIG_IGN) == SIG_ERR) |
2131.10.5
by Stewart Smith
small style fix |
266 |
{
|
2131.10.1
by Stewart Smith
add a very simple --daemon or -d option to drizzled using the exact same code as memcached to start as a daemon. |
267 |
perror("Failed to ignore SIGHUP"); |
268 |
}
|
|
2168.1.6
by Monty Taylor
Fixed an ICC warning. |
269 |
if (daemonize()) |
2131.10.5
by Stewart Smith
small style fix |
270 |
{
|
2363.1.6
by Brian Aker
Add better error messages for issues on startup. |
271 |
unireg_abort << "--daemon failed"; |
2131.10.1
by Stewart Smith
add a very simple --daemon or -d option to drizzled using the exact same code as memcached to start as a daemon. |
272 |
}
|
273 |
}
|
|
274 |
||
2363.1.6
by Brian Aker
Add better error messages for issues on startup. |
275 |
if (not init_variables_after_daemonizing(modules)) |
276 |
{
|
|
277 |
unireg_abort << "init_variables_after_daemonizing() failed"; // Will do exit |
|
278 |
}
|
|
279 |
||
2131.10.7
by Stewart Smith
partition the initialisation of variables and command line options into two phases: the first being the simple one (that we can get out the --daemon option for) and the second being loading plugins, pidfile setup etc. This makes --daemon do the pidfile correctly. |
280 |
|
1794.3.5
by Monty Taylor
Fixed temporoary dir sequencing. |
281 |
/*
|
282 |
init signals & alarm
|
|
283 |
After this we can't quit by a simple unireg_abort
|
|
284 |
*/
|
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
285 |
init_signals(); |
286 |
||
287 |
||
2363.1.8
by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation. |
288 |
select_thread= pthread_self(); |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
289 |
select_thread_in_use=1; |
290 |
||
2392.1.1
by Brian Aker
Fixes for --help work. |
291 |
if (was_help_requested() == false) |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
292 |
{
|
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
293 |
if (chdir(getDataHome().file_string().c_str())) |
1786.3.1
by Monty Taylor
Initial working local catalog. |
294 |
{
|
2363.1.6
by Brian Aker
Add better error messages for issues on startup. |
295 |
unireg_abort << "Data directory " << getDataHome().file_string() << " does not exist"; |
1786.3.1
by Monty Taylor
Initial working local catalog. |
296 |
}
|
2290.1.1
by Joseph Daly
Add server uuid |
297 |
|
298 |
ifstream old_uuid_file ("server.uuid"); |
|
299 |
if (old_uuid_file.is_open()) |
|
300 |
{
|
|
2363.1.6
by Brian Aker
Add better error messages for issues on startup. |
301 |
getline(old_uuid_file, server_uuid); |
2290.1.1
by Joseph Daly
Add server uuid |
302 |
old_uuid_file.close(); |
303 |
}
|
|
304 |
else
|
|
305 |
{
|
|
306 |
uuid_t uu; |
|
307 |
char uuid_string[37]; |
|
308 |
uuid_generate_random(uu); |
|
309 |
uuid_unparse(uu, uuid_string); |
|
310 |
ofstream new_uuid_file ("server.uuid"); |
|
311 |
new_uuid_file << uuid_string; |
|
312 |
new_uuid_file.close(); |
|
313 |
server_uuid= string(uuid_string); |
|
314 |
}
|
|
315 |
||
2363.1.6
by Brian Aker
Add better error messages for issues on startup. |
316 |
if (mkdir("local", 0700) == -1) |
1786.3.1
by Monty Taylor
Initial working local catalog. |
317 |
{
|
2363.1.6
by Brian Aker
Add better error messages for issues on startup. |
318 |
switch (errno) |
319 |
{
|
|
320 |
case EEXIST: |
|
321 |
break; |
|
322 |
||
323 |
case EACCES: |
|
324 |
{
|
|
325 |
char cwd[1024]; |
|
326 |
unireg_abort << "Could not create local catalog, permission denied in directory:" << getcwd(cwd, sizeof(cwd)); |
|
327 |
}
|
|
328 |
||
329 |
default: |
|
330 |
{
|
|
331 |
char cwd[1024]; |
|
332 |
unireg_abort << "Could not create local catalog, in directory:" << getcwd(cwd, sizeof(cwd)) << " system error was:" << strerror(errno); |
|
333 |
}
|
|
334 |
}
|
|
1786.3.1
by Monty Taylor
Initial working local catalog. |
335 |
}
|
2363.1.6
by Brian Aker
Add better error messages for issues on startup. |
336 |
|
337 |
if (chdir("local") == -1) |
|
1786.3.1
by Monty Taylor
Initial working local catalog. |
338 |
{
|
2363.1.6
by Brian Aker
Add better error messages for issues on startup. |
339 |
unireg_abort << "Local catalog does not exist, was unable to chdir() to " << getDataHome().file_string(); |
1786.3.1
by Monty Taylor
Initial working local catalog. |
340 |
}
|
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
341 |
|
2318.5.30
by Olaf van der Spek
Refactor |
342 |
setFullDataHome(boost::filesystem::system_complete(getDataHome())); |
343 |
errmsg_printf(error::INFO, "Data Home directory is : %s", getFullDataHome().native_file_string().c_str()); |
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
344 |
}
|
1786.3.1
by Monty Taylor
Initial working local catalog. |
345 |
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
346 |
if (server_id == 0) |
347 |
{
|
|
348 |
server_id= 1; |
|
349 |
}
|
|
350 |
||
2095.3.6
by Monty Taylor
Actually properly process module dependencies. w00t. |
351 |
try
|
352 |
{
|
|
2318.6.57
by Olaf van der Spek
Refactor |
353 |
init_server_components(modules); |
2095.3.6
by Monty Taylor
Actually properly process module dependencies. w00t. |
354 |
}
|
355 |
catch (abort_exception& ex) |
|
356 |
{
|
|
357 |
#if defined(DEBUG)
|
|
358 |
cout << _("Drizzle has receieved an abort event.") << endl; |
|
359 |
cout << _("In Function: ") << *::boost::get_error_info<boost::throw_function>(ex) << endl; |
|
360 |
cout << _("In File: ") << *::boost::get_error_info<boost::throw_file>(ex) << endl; |
|
361 |
cout << _("On Line: ") << *::boost::get_error_info<boost::throw_line>(ex) << endl; |
|
362 |
#endif
|
|
2363.1.6
by Brian Aker
Add better error messages for issues on startup. |
363 |
unireg_abort << "init_server_components() failed"; |
2095.3.6
by Monty Taylor
Actually properly process module dependencies. w00t. |
364 |
}
|
365 |
||
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
366 |
|
1471.3.2
by Monty Taylor
Merged in old drizzled-as-lib patch. |
367 |
/**
|
368 |
* This check must be done after init_server_components for now
|
|
369 |
* because we don't yet have plugin dependency tracking...
|
|
370 |
*
|
|
371 |
* ReplicationServices::evaluateRegisteredPlugins() will print error messages to stderr
|
|
372 |
* via errmsg_printf().
|
|
373 |
*
|
|
374 |
* @todo
|
|
375 |
*
|
|
376 |
* not checking return since unireg_abort() hangs
|
|
377 |
*/
|
|
2318.6.73
by Olaf van der Spek
Refactor |
378 |
(void) ReplicationServices::evaluateRegisteredPlugins(); |
1471.3.2
by Monty Taylor
Merged in old drizzled-as-lib patch. |
379 |
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
380 |
if (plugin::Listen::setup()) |
2363.1.6
by Brian Aker
Add better error messages for issues on startup. |
381 |
{
|
382 |
unireg_abort << "Failed plugin::Listen::setup()"; |
|
383 |
}
|
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
384 |
|
1300.5.17
by Monty Taylor
Merged trunk. |
385 |
assert(plugin::num_trx_monitored_objects > 0); |
2302.1.3
by Olaf van der Spek
New / make_shared doesn't return NULL |
386 |
drizzle_rm_tmp_tables(); |
387 |
errmsg_printf(error::INFO, _(ER(ER_STARTUP)), internal::my_progname, PANDORA_RELEASE_VERSION, COMPILATION_COMMENT); |
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
388 |
|
1819.4.1
by David Shrewsbury
Add server startup and shutdown events to the replication stream. |
389 |
/* Send server startup event */
|
390 |
{
|
|
2302.1.4
by Olaf van der Spek
Refactor |
391 |
Session::shared_ptr session= Session::make_shared(plugin::Listen::getNullClient(), catalog::local()); |
2318.6.22
by Olaf van der Spek
Refactor |
392 |
setCurrentSession(session.get()); |
2318.6.62
by Olaf van der Spek
Refactor |
393 |
TransactionServices::sendStartupEvent(*session); |
2302.1.4
by Olaf van der Spek
Refactor |
394 |
plugin_startup_window(modules, *session.get()); |
1819.4.1
by David Shrewsbury
Add server startup and shutdown events to the replication stream. |
395 |
}
|
396 |
||
2131.10.2
by Stewart Smith
wait until after the server has started up properly and about ready to receive connections before returning control if --daemon. Also make errors/logs on stderr still appear. |
397 |
if (opt_daemon) |
2363.1.7
by Brian Aker
This shifts the closing of the socket to after we know that no errors are going to occur. |
398 |
{
|
2131.10.2
by Stewart Smith
wait until after the server has started up properly and about ready to receive connections before returning control if --daemon. Also make errors/logs on stderr still appear. |
399 |
daemon_is_ready(); |
2363.1.7
by Brian Aker
This shifts the closing of the socket to after we know that no errors are going to occur. |
400 |
}
|
2040.7.2
by Monty Taylor
Revert unneeded change to the while loop. |
401 |
|
2227.4.3
by Olaf van der Spek
Remove unnecessary statement.h include |
402 |
/*
|
2039.6.3
by Brian Aker
Update for session to have a catalog object. |
403 |
Listen for new connections and start new session for each connection
|
2040.7.2
by Monty Taylor
Revert unneeded change to the while loop. |
404 |
accepted. The listen.getClient() method will return NULL when the server
|
2039.6.3
by Brian Aker
Update for session to have a catalog object. |
405 |
should be shutdown.
|
406 |
*/
|
|
2302.1.4
by Olaf van der Spek
Refactor |
407 |
while (plugin::Client* client= plugin::Listen::getClient()) |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
408 |
{
|
2281.4.5
by Olaf van der Spek
Prune & refactor |
409 |
Session::shared_ptr session= Session::make_shared(client, client->catalog()); |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
410 |
|
2040.7.2
by Monty Taylor
Revert unneeded change to the while loop. |
411 |
/* If we error on creation we drop the connection and delete the session. */
|
412 |
if (Session::schedule(session)) |
|
413 |
Session::unlink(session); |
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
414 |
}
|
415 |
||
1819.4.1
by David Shrewsbury
Add server startup and shutdown events to the replication stream. |
416 |
/* Send server shutdown event */
|
417 |
{
|
|
2302.1.4
by Olaf van der Spek
Refactor |
418 |
Session::shared_ptr session= Session::make_shared(plugin::Listen::getNullClient(), catalog::local()); |
2318.6.22
by Olaf van der Spek
Refactor |
419 |
setCurrentSession(session.get()); |
2318.6.62
by Olaf van der Spek
Refactor |
420 |
TransactionServices::sendShutdownEvent(*session.get()); |
1819.4.1
by David Shrewsbury
Add server startup and shutdown events to the replication stream. |
421 |
}
|
422 |
||
1932.3.4
by Brian Aker
Move counter lock so that ownership is held by session_list. |
423 |
{
|
2275.3.2
by Olaf van der Spek
Session Cache |
424 |
boost::mutex::scoped_lock scopedLock(session::Cache::mutex()); |
1932.3.4
by Brian Aker
Move counter lock so that ownership is held by session_list. |
425 |
select_thread_in_use= false; // For close_connections |
426 |
}
|
|
1689.2.5
by Brian Aker
Convert COND_thread_count to boost. |
427 |
COND_thread_count.notify_all(); |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
428 |
|
429 |
/* Wait until cleanup is done */
|
|
2282.1.2
by Olaf van der Spek
Session Cache |
430 |
session::Cache::shutdownSecond(); |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
431 |
|
432 |
clean_up(1); |
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
433 |
module::Registry::shutdown(); |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
434 |
internal::my_end(); |
1798.3.1
by Brian Aker
Remove native_handle usage. |
435 |
|
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
436 |
return 0; |
437 |
}
|
|
438 |