~aarti-pai/drizzle/temporal

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: aarti
  • Date: 2009-01-27 23:18:42 UTC
  • mfrom: (790.4.12 testable)
  • Revision ID: aarti@piggy.tangent.org-20090127231842-jou4wkt95c4tuofw
MergedĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#include <drizzled/function/time/get_format.h>
45
45
#include <drizzled/errmsg.h>
46
46
#include <drizzled/unireg.h>
 
47
#include <drizzled/plugin_scheduling.h>
47
48
 
48
49
#include "drizzled/temporal_format_match.h" /* For init_temporal_matching() */
49
50
 
253
254
static char *default_collation_name;
254
255
static char *default_storage_engine_str;
255
256
static char compiled_default_collation_name[]= DRIZZLE_DEFAULT_COLLATION_NAME;
256
 
static I_List<Session> thread_cache;
257
257
 
258
258
/* Global variables */
259
259
 
313
313
uint64_t slow_launch_time;
314
314
uint64_t slave_open_temp_tables;
315
315
uint64_t open_files_limit;
316
 
uint64_t thread_pool_size= 0;
317
316
uint32_t refresh_version;  /* Increments on each reload */
318
317
uint64_t aborted_threads;
319
318
uint64_t aborted_connects;
413
412
 
414
413
pthread_key_t THR_Mem_root;
415
414
pthread_key_t THR_Session;
416
 
pthread_mutex_t LOCK_drizzle_create_db, LOCK_open, LOCK_thread_count,
 
415
pthread_mutex_t LOCK_drizzle_create_db, 
 
416
                LOCK_open, 
 
417
                LOCK_thread_count,
417
418
                LOCK_status,
418
419
                LOCK_global_read_lock,
419
420
                LOCK_global_system_variables,
420
 
                LOCK_slave_list,
421
 
                LOCK_active_mi,
422
421
                LOCK_connection_count;
423
422
 
424
423
pthread_rwlock_t        LOCK_sys_init_connect;
425
 
pthread_rwlock_t        LOCK_sys_init_slave;
426
424
pthread_rwlock_t        LOCK_system_variables_hash;
427
425
pthread_cond_t COND_refresh, COND_thread_count, COND_global_read_lock;
428
426
pthread_t signal_thread;
458
456
 
459
457
bool mysqld_embedded=0;
460
458
 
461
 
scheduler_functions thread_scheduler;
 
459
extern scheduling_st thread_scheduler;
462
460
 
463
461
/**
464
462
  Number of currently active user connections. The variable is protected by
561
559
  I_List_iterator<Session> it(threads);
562
560
  while ((tmp=it++))
563
561
  {
564
 
    /* We skip slave threads & scheduler on this first loop through. */
565
 
    if (tmp->slave_thread)
566
 
      continue;
567
 
 
568
562
    tmp->killed= Session::KILL_CONNECTION;
569
563
    thread_scheduler.post_kill_notification(tmp);
570
564
    if (tmp->mysys_var)
810
804
 
811
805
  if (print_message && server_start_time)
812
806
    errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),my_progname);
813
 
  thread_scheduler.end();
814
807
  /* Returns NULL on globerrs, we don't want to try to free that */
815
808
  //void *freeme=
816
809
  (void *)my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
858
851
  (void) pthread_mutex_destroy(&LOCK_thread_count);
859
852
  (void) pthread_mutex_destroy(&LOCK_status);
860
853
  (void) pthread_mutex_destroy(&LOCK_connection_count);
861
 
  (void) pthread_mutex_destroy(&LOCK_active_mi);
862
854
  (void) pthread_rwlock_destroy(&LOCK_sys_init_connect);
863
 
  (void) pthread_rwlock_destroy(&LOCK_sys_init_slave);
864
855
  (void) pthread_mutex_destroy(&LOCK_global_system_variables);
865
856
  (void) pthread_rwlock_destroy(&LOCK_system_variables_hash);
866
857
  (void) pthread_mutex_destroy(&LOCK_global_read_lock);
1034
1025
  struct addrinfo hints;
1035
1026
  int error;
1036
1027
 
1037
 
  if (thread_scheduler.init())
1038
 
    unireg_abort(1);                    /* purecov: inspected */
1039
 
 
1040
1028
  set_ports();
1041
1029
 
1042
1030
  memset(fds, 0, sizeof(struct pollfd) * UINT8_MAX);
1159
1147
  if (session)
1160
1148
  {
1161
1149
    statistic_increment(killed_threads, &LOCK_status);
1162
 
    thread_scheduler.end_thread(session,0);             /* purecov: inspected */
 
1150
    (void)thread_scheduler.end_thread(session, 0);              /* purecov: inspected */
1163
1151
  }
1164
1152
  return;;                              /* purecov: deadcode */
1165
1153
}
1583
1571
          tmp_sched_param.sched_priority= INTERRUPT_PRIOR;
1584
1572
          (void)pthread_attr_setschedparam(&connection_attrib, &tmp_sched_param);
1585
1573
        }
1586
 
        if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
1587
 
                           (void*) &sig))
1588
 
              errmsg_printf(ERRMSG_LVL_ERROR, _("Can't create thread to kill server"));
 
1574
        if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
 
1575
                           (void*) &sig))
 
1576
          errmsg_printf(ERRMSG_LVL_ERROR, _("Can't create thread to kill server"));
1589
1577
#else
1590
 
        kill_server((void*) sig);       // MIT THREAD has a alarm thread
 
1578
        kill_server((void*) sig);       // MIT THREAD has a alarm thread
1591
1579
#endif
1592
1580
      }
1593
1581
      break;
1649
1637
                          DRIZZLE_ERROR::WARN_LEVEL_ERROR))
1650
1638
      return;;
1651
1639
 
1652
 
    session->is_slave_error=  1; // needed to catch query errors during replication
1653
 
 
1654
1640
    /*
1655
1641
      session->lex->current_select == 0 if lex structure is not inited
1656
1642
      (not query command (COM_QUERY))
1888
1874
          happen if max_connections is decreased above).
1889
1875
        */
1890
1876
        table_cache_size= (uint32_t) cmin(cmax((files-10-max_connections)/2,
1891
 
                                          (uint32_t)TABLE_OPEN_CACHE_MIN),
1892
 
                                      table_cache_size);
 
1877
                                               (uint32_t)TABLE_OPEN_CACHE_MIN),
 
1878
                                          table_cache_size);
1893
1879
        if (global_system_variables.log_warnings)
1894
1880
              errmsg_printf(ERRMSG_LVL_WARN, _("Changed limits: max_open_files: %u  "
1895
 
                              "max_connections: %"PRIu64"  table_cache: %"PRIu64""),
 
1881
                                               "max_connections: %"PRIu64"  table_cache: %"PRIu64""),
1896
1882
                            files, max_connections, table_cache_size);
1897
1883
      }
1898
1884
      else if (global_system_variables.log_warnings)
2005
1991
  (void) pthread_mutex_init(&LOCK_open, NULL);
2006
1992
  (void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
2007
1993
  (void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
2008
 
  (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
2009
1994
  (void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
2010
1995
  (void) pthread_rwlock_init(&LOCK_system_variables_hash, NULL);
2011
1996
  (void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
2012
1997
  (void) pthread_mutex_init(&LOCK_connection_count, MY_MUTEX_INIT_FAST);
2013
1998
  (void) pthread_rwlock_init(&LOCK_sys_init_connect, NULL);
2014
 
  (void) pthread_rwlock_init(&LOCK_sys_init_slave, NULL);
2015
1999
  (void) pthread_cond_init(&COND_thread_count,NULL);
2016
2000
  (void) pthread_cond_init(&COND_refresh,NULL);
2017
2001
  (void) pthread_cond_init(&COND_global_read_lock,NULL);
2979
2963
  {"max_connections", OPT_MAX_CONNECTIONS,
2980
2964
   N_("The number of simultaneous clients allowed."),
2981
2965
   (char**) &max_connections,
2982
 
   (char**) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 100000, 0, 1,
2983
 
   0},
 
2966
   (char**) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 2048, 1, 100000, 0, 1, 0},
2984
2967
  {"max_error_count", OPT_MAX_ERROR_COUNT,
2985
2968
   N_("Max number of errors/warnings to store for a statement."),
2986
2969
   (char**) &global_system_variables.max_error_count,
3159
3142
      "error. Used only if the connection has active cursors."),
3160
3143
   (char**) &table_lock_wait_timeout, (char**) &table_lock_wait_timeout,
3161
3144
   0, GET_ULL, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0},
3162
 
  {"thread_pool_size", OPT_THREAD_CACHE_SIZE,
3163
 
    N_("How many threads we should create to handle query requests in case of "
3164
 
       "'thread_handling=pool-of-threads'"),
3165
 
    (char**) &thread_pool_size, (char**) &thread_pool_size, 0, GET_ULL,
3166
 
    REQUIRED_ARG, 8, 1, 16384, 0, 1, 0},
3167
3145
  {"thread_stack", OPT_THREAD_STACK,
3168
3146
   N_("The stack size for each thread."),
3169
3147
   (char**) &my_thread_stack_size,
3437
3415
  myisam_recover_options_str= "OFF";
3438
3416
  myisam_stats_method_str= "nulls_unequal";
3439
3417
  threads.empty();
3440
 
  thread_cache.empty();
3441
3418
  key_caches.empty();
3442
3419
  if (!(dflt_key_cache= get_or_create_key_cache(default_key_cache_base.str,
3443
3420
                                                default_key_cache_base.length)))
3772
3749
      init_global_datetime_format(DRIZZLE_TIMESTAMP_DATETIME,
3773
3750
                                  &global_system_variables.datetime_format))
3774
3751
    exit(1);
3775
 
 
3776
 
  pool_of_threads_scheduler(&thread_scheduler);  /* purecov: tested */
3777
3752
}
3778
3753
 
3779
3754