~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Monty Taylor
  • Date: 2009-04-15 22:32:00 UTC
  • mfrom: (971.3.29 eday-dev)
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090415223200-povslfjkbb5q6dj7
MergedĀ fromĀ Eric.

Show diffs side-by-side

added added

removed removed

Lines of Context:
248
248
bool opt_endinfo, using_udf_functions;
249
249
bool locked_in_memory;
250
250
bool volatile abort_loop;
 
251
int abort_pipe[2];
251
252
bool volatile shutdown_in_progress;
252
253
uint32_t max_used_connections;
253
254
const char *opt_scheduler= "multi_thread";
448
449
 
449
450
void close_connections(void)
450
451
{
451
 
  int x;
452
 
 
453
452
  /* Abort listening to new connections */
454
 
  for (x= 0; x < pollfd_count; x++)
455
 
  {
456
 
    if (fds[x].fd != -1)
457
 
    {
458
 
      (void) shutdown(fds[x].fd, SHUT_RDWR);
459
 
      (void) close(fds[x].fd);
460
 
      fds[x].fd= -1;
461
 
    }
462
 
  }
463
 
 
 
453
  (void) write(abort_pipe[1], "\0", 1);
464
454
 
465
455
  /* kill connection thread */
466
456
  (void) pthread_mutex_lock(&LOCK_thread_count);
808
798
  struct addrinfo *next;
809
799
  struct addrinfo hints;
810
800
  int error;
 
801
  int ip_sock;
811
802
 
812
803
  set_ports();
813
804
 
824
815
    unireg_abort(1);                            /* purecov: tested */
825
816
  }
826
817
 
827
 
  for (next= ai, pollfd_count= 0; next; next= next->ai_next, pollfd_count++)
 
818
  for (next= ai, pollfd_count= 0; next; next= next->ai_next)
828
819
  {
829
 
    int ip_sock;
830
 
 
831
820
    ip_sock= socket(next->ai_family, next->ai_socktype, next->ai_protocol);
832
 
 
833
821
    if (ip_sock == -1)
834
822
    {
835
 
      sql_perror(ER(ER_IPSOCK_ERROR));          /* purecov: tested */
836
 
      unireg_abort(1);                          /* purecov: tested */
 
823
      /* getaddrinfo can return bad results, skip them here and error later if
 
824
         we didn't find anything to bind to. */
 
825
      continue;
837
826
    }
838
827
 
839
828
    fds[pollfd_count].fd= ip_sock;
840
829
    fds[pollfd_count].events= POLLIN | POLLERR;
 
830
    pollfd_count++;
841
831
 
842
832
    /* Add options for our listening socket */
843
833
    {
916
906
    }
917
907
  }
918
908
 
 
909
  if (pollfd_count == 0 && ai != NULL && ip_sock == -1)
 
910
  {
 
911
    sql_perror(ER(ER_IPSOCK_ERROR));            /* purecov: tested */
 
912
    unireg_abort(1);                            /* purecov: tested */
 
913
  }
 
914
 
919
915
  freeaddrinfo(ai);
 
916
 
 
917
  /* We need a pipe to wakeup the listening thread since some operating systems
 
918
     are stupid. *cough* OSX *cough* */
 
919
  if (pipe(abort_pipe) == -1)
 
920
  {
 
921
    sql_perror(_("Can't open abort pipet"));
 
922
    errmsg_printf(ERRMSG_LVL_ERROR,
 
923
                  _("pipe() on abort_pipe failed with error %d"), errno);
 
924
    unireg_abort(1);
 
925
  }
 
926
 
 
927
  fds[pollfd_count].fd= abort_pipe[0];
 
928
  fds[pollfd_count].events= POLLIN | POLLERR;
 
929
  pollfd_count++; 
 
930
 
920
931
  return;
921
932
}
922
933
 
1972
1983
 
1973
1984
    create_new_thread(session);
1974
1985
  }
 
1986
 
 
1987
  for (x= 0; x < pollfd_count; x++)
 
1988
  {
 
1989
    if (fds[x].fd != -1)
 
1990
    {
 
1991
      (void) shutdown(fds[x].fd, SHUT_RDWR);
 
1992
      (void) close(fds[x].fd);
 
1993
      fds[x].fd= -1;
 
1994
    }
 
1995
  }
 
1996
 
 
1997
  /* abort_pipe[0] was closed in the for loop above in fds[] */
 
1998
  (void) close(abort_pipe[1]);
1975
1999
}
1976
2000
 
1977
2001