~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Monty Taylor
  • Date: 2009-01-25 14:29:57 UTC
  • mfrom: (811 drizzle)
  • mto: (779.7.3 devel)
  • mto: This revision was merged to the branch mainline in revision 816.
  • Revision ID: mordred@inaugust.com-20090125142957-qd2dc0x4lbdeut84
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
 
49
50
#if TIME_WITH_SYS_TIME
312
313
uint64_t slow_launch_time;
313
314
uint64_t slave_open_temp_tables;
314
315
uint64_t open_files_limit;
315
 
uint64_t thread_pool_size= 0;
316
316
uint32_t refresh_version;  /* Increments on each reload */
317
317
uint64_t aborted_threads;
318
318
uint64_t aborted_connects;
412
412
 
413
413
pthread_key_t THR_Mem_root;
414
414
pthread_key_t THR_Session;
415
 
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,
416
418
                LOCK_status,
417
419
                LOCK_global_read_lock,
418
420
                LOCK_global_system_variables,
419
 
                LOCK_slave_list,
420
 
                LOCK_active_mi,
421
421
                LOCK_connection_count;
422
422
 
423
423
pthread_rwlock_t        LOCK_sys_init_connect;
424
 
pthread_rwlock_t        LOCK_sys_init_slave;
425
424
pthread_rwlock_t        LOCK_system_variables_hash;
426
425
pthread_cond_t COND_refresh, COND_thread_count, COND_global_read_lock;
427
426
pthread_t signal_thread;
457
456
 
458
457
bool mysqld_embedded=0;
459
458
 
460
 
scheduler_functions thread_scheduler;
 
459
extern scheduling_st thread_scheduler;
461
460
 
462
461
/**
463
462
  Number of currently active user connections. The variable is protected by
560
559
  I_List_iterator<Session> it(threads);
561
560
  while ((tmp=it++))
562
561
  {
563
 
    /* We skip slave threads & scheduler on this first loop through. */
564
 
    if (tmp->slave_thread)
565
 
      continue;
566
 
 
567
562
    tmp->killed= Session::KILL_CONNECTION;
568
563
    thread_scheduler.post_kill_notification(tmp);
569
564
    if (tmp->mysys_var)
809
804
 
810
805
  if (print_message && server_start_time)
811
806
    errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),my_progname);
812
 
  thread_scheduler.end();
813
807
  /* Returns NULL on globerrs, we don't want to try to free that */
814
808
  //void *freeme=
815
809
  (void *)my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
857
851
  (void) pthread_mutex_destroy(&LOCK_thread_count);
858
852
  (void) pthread_mutex_destroy(&LOCK_status);
859
853
  (void) pthread_mutex_destroy(&LOCK_connection_count);
860
 
  (void) pthread_mutex_destroy(&LOCK_active_mi);
861
854
  (void) pthread_rwlock_destroy(&LOCK_sys_init_connect);
862
 
  (void) pthread_rwlock_destroy(&LOCK_sys_init_slave);
863
855
  (void) pthread_mutex_destroy(&LOCK_global_system_variables);
864
856
  (void) pthread_rwlock_destroy(&LOCK_system_variables_hash);
865
857
  (void) pthread_mutex_destroy(&LOCK_global_read_lock);
1033
1025
  struct addrinfo hints;
1034
1026
  int error;
1035
1027
 
1036
 
  if (thread_scheduler.init())
1037
 
    unireg_abort(1);                    /* purecov: inspected */
1038
 
 
1039
1028
  set_ports();
1040
1029
 
1041
1030
  memset(fds, 0, sizeof(struct pollfd) * UINT8_MAX);
1158
1147
  if (session)
1159
1148
  {
1160
1149
    statistic_increment(killed_threads, &LOCK_status);
1161
 
    thread_scheduler.end_thread(session,0);             /* purecov: inspected */
 
1150
    (void)thread_scheduler.end_thread(session, 0);              /* purecov: inspected */
1162
1151
  }
1163
1152
  return;;                              /* purecov: deadcode */
1164
1153
}
1582
1571
          tmp_sched_param.sched_priority= INTERRUPT_PRIOR;
1583
1572
          (void)pthread_attr_setschedparam(&connection_attrib, &tmp_sched_param);
1584
1573
        }
1585
 
        if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
1586
 
                           (void*) &sig))
1587
 
              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"));
1588
1577
#else
1589
 
        kill_server((void*) sig);       // MIT THREAD has a alarm thread
 
1578
        kill_server((void*) sig);       // MIT THREAD has a alarm thread
1590
1579
#endif
1591
1580
      }
1592
1581
      break;
1887
1876
          happen if max_connections is decreased above).
1888
1877
        */
1889
1878
        table_cache_size= (uint32_t) cmin(cmax((files-10-max_connections)/2,
1890
 
                                          (uint32_t)TABLE_OPEN_CACHE_MIN),
1891
 
                                      table_cache_size);
 
1879
                                               (uint32_t)TABLE_OPEN_CACHE_MIN),
 
1880
                                          table_cache_size);
1892
1881
        if (global_system_variables.log_warnings)
1893
1882
              errmsg_printf(ERRMSG_LVL_WARN, _("Changed limits: max_open_files: %u  "
1894
 
                              "max_connections: %"PRIu64"  table_cache: %"PRIu64""),
 
1883
                                               "max_connections: %"PRIu64"  table_cache: %"PRIu64""),
1895
1884
                            files, max_connections, table_cache_size);
1896
1885
      }
1897
1886
      else if (global_system_variables.log_warnings)
2005
1994
  (void) pthread_mutex_init(&LOCK_open, NULL);
2006
1995
  (void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
2007
1996
  (void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
2008
 
  (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
2009
1997
  (void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
2010
1998
  (void) pthread_rwlock_init(&LOCK_system_variables_hash, NULL);
2011
1999
  (void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
2012
2000
  (void) pthread_mutex_init(&LOCK_connection_count, MY_MUTEX_INIT_FAST);
2013
2001
  (void) pthread_rwlock_init(&LOCK_sys_init_connect, NULL);
2014
 
  (void) pthread_rwlock_init(&LOCK_sys_init_slave, NULL);
2015
2002
  (void) pthread_cond_init(&COND_thread_count,NULL);
2016
2003
  (void) pthread_cond_init(&COND_refresh,NULL);
2017
2004
  (void) pthread_cond_init(&COND_global_read_lock,NULL);
2975
2962
  {"max_connections", OPT_MAX_CONNECTIONS,
2976
2963
   N_("The number of simultaneous clients allowed."),
2977
2964
   (char**) &max_connections,
2978
 
   (char**) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 100000, 0, 1,
2979
 
   0},
 
2965
   (char**) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 2048, 1, 100000, 0, 1, 0},
2980
2966
  {"max_error_count", OPT_MAX_ERROR_COUNT,
2981
2967
   N_("Max number of errors/warnings to store for a statement."),
2982
2968
   (char**) &global_system_variables.max_error_count,
3155
3141
      "error. Used only if the connection has active cursors."),
3156
3142
   (char**) &table_lock_wait_timeout, (char**) &table_lock_wait_timeout,
3157
3143
   0, GET_ULL, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0},
3158
 
  {"thread_pool_size", OPT_THREAD_CACHE_SIZE,
3159
 
    N_("How many threads we should create to handle query requests in case of "
3160
 
       "'thread_handling=pool-of-threads'"),
3161
 
    (char**) &thread_pool_size, (char**) &thread_pool_size, 0, GET_ULL,
3162
 
    REQUIRED_ARG, 8, 1, 16384, 0, 1, 0},
3163
3144
  {"thread_stack", OPT_THREAD_STACK,
3164
3145
   N_("The stack size for each thread."),
3165
3146
   (char**) &my_thread_stack_size,
3768
3749
      init_global_datetime_format(DRIZZLE_TIMESTAMP_DATETIME,
3769
3750
                                  &global_system_variables.datetime_format))
3770
3751
    exit(1);
3771
 
 
3772
 
  pool_of_threads_scheduler(&thread_scheduler);  /* purecov: tested */
3773
3752
}
3774
3753
 
3775
3754