~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <drizzled/server_includes.h>
 
20
#include "config.h"
21
21
#include <drizzled/configmake.h>
22
22
#include <drizzled/atomics.h>
23
23
 
46
46
#include "drizzled/plugin/client.h"
47
47
#include "drizzled/plugin/scheduler.h"
48
48
#include "drizzled/probes.h"
 
49
#include "drizzled/session_list.h"
49
50
 
50
51
#include <google/protobuf/stubs/common.h>
51
52
 
63
64
#ifdef HAVE_SYS_PRCTL_H
64
65
#include <sys/prctl.h>
65
66
#endif
 
67
#include <sys/socket.h>
66
68
 
67
69
#include <locale.h>
68
70
 
76
78
 
77
79
#define MAX_MEM_TABLE_SIZE SIZE_MAX
78
80
 
79
 
extern "C" {                                    // Because of SCO 3.2V4.2
80
81
#include <errno.h>
81
82
#include <sys/stat.h>
82
83
#include <mysys/my_getopt.h>
144
145
#endif /* __i386__ && HAVE_FPU_CONTROL_H && _FPU_DOUBLE */
145
146
}
146
147
 
147
 
} /* cplusplus */
148
 
 
149
148
#include <mysys/my_pthread.h>                   // For thr_setconcurency()
150
149
 
151
150
#include <drizzled/gettext.h>
159
158
 
160
159
/* Constants */
161
160
 
162
 
const string& drizzled_version()
163
 
{
164
 
  static const string DRIZZLED_VERSION(STRING_WITH_LEN(PANDORA_RELEASE_VERSION));
165
 
  return DRIZZLED_VERSION;
166
 
}
167
 
 
168
161
 
169
162
const char *show_comp_option_name[]= {"YES", "NO", "DISABLED"};
170
163
static const char *optimizer_switch_names[]=
195
188
};
196
189
 
197
190
const char *first_keyword= "first";
198
 
const char *binary_keyword= "BINARY";
199
191
const char * const DRIZZLE_CONFIG_NAME= "drizzled";
200
192
#define GET_HA_ROWS GET_ULL
201
193
 
264
256
uint32_t global_thread_id= 1UL;
265
257
pid_t current_pid;
266
258
 
 
259
extern const double log_10[309];
 
260
 
267
261
const double log_10[] = {
268
262
  1e000, 1e001, 1e002, 1e003, 1e004, 1e005, 1e006, 1e007, 1e008, 1e009,
269
263
  1e010, 1e011, 1e012, 1e013, 1e014, 1e015, 1e016, 1e017, 1e018, 1e019,
327
321
 
328
322
FILE *stderror_file=0;
329
323
 
330
 
vector<Session*> session_list;
331
 
 
332
324
struct system_variables global_system_variables;
333
325
struct system_variables max_system_variables;
334
326
struct system_status_var global_status_var;
438
430
 
439
431
  (void) pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
440
432
 
441
 
  for( vector<Session*>::iterator it= session_list.begin(); it != session_list.end(); ++it )
 
433
  for( vector<Session*>::iterator it= getSessionList().begin(); it != getSessionList().end(); ++it )
442
434
  {
443
435
    tmp= *it;
444
436
    tmp->killed= Session::KILL_CONNECTION;
470
462
  for (;;)
471
463
  {
472
464
    (void) pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
473
 
    if (session_list.empty())
 
465
    if (getSessionList().empty())
474
466
    {
475
467
      (void) pthread_mutex_unlock(&LOCK_thread_count);
476
468
      break;
477
469
    }
478
 
    tmp= session_list.front();
 
470
    tmp= getSessionList().front();
479
471
    /* Close before unlock, avoiding crash. See LP bug#436685 */
480
472
    tmp->client->close();
481
473
    (void) pthread_mutex_unlock(&LOCK_thread_count);
729
721
  Unlink session from global list of available connections and free session
730
722
 
731
723
  SYNOPSIS
732
 
    unlink_session()
 
724
    Session::unlink()
733
725
    session              Thread handler
734
726
 
735
727
  NOTES
736
728
    LOCK_thread_count is locked and left locked
737
729
*/
738
730
 
739
 
void unlink_session(Session *session)
 
731
void Session::unlink(Session *session)
740
732
{
741
733
  connection_count--;
742
734
 
745
737
  (void) pthread_mutex_lock(&LOCK_thread_count);
746
738
  pthread_mutex_lock(&session->LOCK_delete);
747
739
 
748
 
  session_list.erase(remove(session_list.begin(),
749
 
                     session_list.end(),
750
 
                     session));
 
740
  getSessionList().erase(remove(getSessionList().begin(),
 
741
                         getSessionList().end(),
 
742
                         session));
751
743
 
752
744
  delete session;
753
745
  (void) pthread_mutex_unlock(&LOCK_thread_count);
758
750
 
759
751
#ifdef THREAD_SPECIFIC_SIGPIPE
760
752
/**
761
 
  Aborts a thread nicely. Comes here on SIGPIPE.
762
753
 
763
754
  @todo
764
755
    One should have to fix that thr_alarm know about this thread too.
1270
1261
  /*
1271
1262
    Add server status variables to the dynamic list of
1272
1263
    status variables that is shown by SHOW STATUS.
1273
 
    Later, in plugin_init, and mysql_install_plugin
1274
 
    new entries could be added to that list.
 
1264
    Later, in plugin_init, new entries could be added to that list.
1275
1265
  */
1276
1266
  if (add_status_vars(status_vars))
1277
1267
    return 1; // an error was already reported
1392
1382
    return(1);
1393
1383
 
1394
1384
  if (plugin_init(plugins, &defaults_argc, defaults_argv,
1395
 
                  ((opt_help) ? PLUGIN_INIT_SKIP_INITIALIZATION : 0)))
 
1385
                  ((opt_help) ? true : false)))
1396
1386
  {
1397
1387
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize plugins."));
1398
1388
    unireg_abort(1);
1630
1620
 
1631
1621
    /* If we error on creation we drop the connection and delete the session. */
1632
1622
    if (session->schedule())
1633
 
      unlink_session(session);
 
1623
      Session::unlink(session);
1634
1624
  }
1635
1625
 
1636
1626
  /* (void) pthread_attr_destroy(&connection_attrib); */
2189
2179
  session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_SQL_NOTES);
2190
2180
  refresh_version= 1L;  /* Increments on each reload */
2191
2181
  global_thread_id= 1UL;
2192
 
  session_list.clear();
 
2182
  getSessionList().clear();
2193
2183
 
2194
2184
  /* Set directory paths */
2195
2185
  strncpy(language, LANGUAGE, sizeof(language)-1);
2403
2393
static const char *get_relative_path(const char *path)
2404
2394
{
2405
2395
  if (test_if_hard_path(path) &&
2406
 
      is_prefix(path,PREFIX) &&
 
2396
      (strncmp(path, PREFIX, strlen(PREFIX)) == 0) &&
2407
2397
      strcmp(PREFIX,FN_ROOTDIR))
2408
2398
  {
2409
2399
    if (strlen(PREFIX) < strlen(path))