~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Brian Aker
  • Date: 2009-02-27 23:47:26 UTC
  • Revision ID: brian@tangent.org-20090227234726-ablw59a5y72edac6
Shutdown for Linux fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
 
82
82
#define MAX_MEM_TABLE_SIZE SIZE_MAX
83
83
 
84
 
/* We have HAVE_purify below as this speeds up the shutdown of MySQL */
85
 
 
86
 
#if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ) || defined(HAVE_purify) && defined(__linux__)
87
 
#define HAVE_CLOSE_SERVER_SOCK 1
88
 
#endif
89
 
 
90
84
extern "C" {                                    // Because of SCO 3.2V4.2
91
85
#include <errno.h>
92
86
#include <sys/stat.h>
474
468
static void clean_up(bool print_message);
475
469
 
476
470
static void usage(void);
477
 
static void close_server_sock();
478
471
static void clean_up_mutexes(void);
479
472
static void drizzled_exit(int exit_code) __attribute__((noreturn));
480
473
extern "C" bool safe_read_error_impl(NET *net);
485
478
 
486
479
void close_connections(void)
487
480
{
 
481
  int x;
 
482
 
 
483
  /* Abort listening to new connections */
 
484
  for (x= 0; x < pollfd_count; x++)
 
485
  {
 
486
    if (fds[x].fd != -1)
 
487
    {
 
488
      (void) shutdown(fds[x].fd, SHUT_RDWR);
 
489
      (void) close(fds[x].fd);
 
490
      fds[x].fd= -1;
 
491
    }
 
492
  }
 
493
 
488
494
 
489
495
  /* kill connection thread */
490
496
  (void) pthread_mutex_lock(&LOCK_thread_count);
497
503
    set_timespec(abstime, 2);
498
504
    for (uint32_t tmp=0 ; tmp < 10 && select_thread_in_use; tmp++)
499
505
    {
500
 
      error=pthread_cond_timedwait(&COND_thread_count,&LOCK_thread_count,
501
 
                                   &abstime);
 
506
      error=pthread_cond_timedwait(&COND_thread_count,&LOCK_thread_count, &abstime);
502
507
      if (error != EINTR)
503
 
        break;
 
508
        break;
504
509
    }
505
 
    close_server_sock();
506
510
  }
507
511
  (void) pthread_mutex_unlock(&LOCK_thread_count);
508
512
 
509
513
 
510
 
  /* Abort listening to new connections */
511
 
  {
512
 
    int x;
513
 
 
514
 
    for (x= 0; x < pollfd_count; x++)
515
 
    {
516
 
      if (fds[x].fd != -1)
517
 
      {
518
 
        (void) shutdown(fds[x].fd, SHUT_RDWR);
519
 
        (void) close(fds[x].fd);
520
 
        fds[x].fd= -1;
521
 
      }
522
 
    }
523
 
  }
524
 
 
525
514
  /*
526
515
    First signal all threads that it's time to die
527
516
    This will give the threads some time to gracefully abort their
590
579
}
591
580
 
592
581
 
593
 
static void close_server_sock()
594
 
{
595
 
#ifdef HAVE_CLOSE_SERVER_SOCK
596
 
  {
597
 
    int x;
598
 
 
599
 
    for (x= 0; x < pollfd_count; x++)
600
 
    {
601
 
      if (fds[x].fd != -1)
602
 
      {
603
 
        (void) shutdown(fds[x].fd, SHUT_RDWR);
604
 
        (void) close(fds[x].fd);
605
 
        fds[x].fd= -1;
606
 
      }
607
 
    }
608
 
  }
609
 
#endif
610
 
}
611
 
 
612
 
 
613
582
extern "C" void print_signal_warning(int sig)
614
583
{
615
584
  if (global_system_variables.log_warnings)