~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Monty Taylor
  • Date: 2008-11-12 17:42:40 UTC
  • mto: This revision was merged to the branch mainline in revision 584.
  • Revision ID: monty@inaugust.com-20081112174240-l2vg9lnzbmjc3uyk
More header cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include <mysys/mysys_err.h>
35
35
#include <drizzled/error.h>
36
36
#include <drizzled/tztime.h>
 
37
#include <drizzled/sql_base.h>
 
38
#include <drizzled/show.h>
 
39
#include <drizzled/sql_parse.h>
37
40
 
38
41
#if TIME_WITH_SYS_TIME
39
42
# include <sys/time.h>
674
677
}
675
678
 
676
679
 
677
 
void kill_drizzle(void)
678
 
{
679
 
 
680
 
#if defined(SIGNALS_DONT_BREAK_READ)
681
 
  abort_loop=1;                                 // Break connection loops
682
 
  close_server_sock();                          // Force accept to wake up
683
 
#endif
684
 
 
685
 
#if defined(HAVE_PTHREAD_KILL)
686
 
  pthread_kill(signal_thread, DRIZZLE_KILL_SIGNAL);
687
 
#elif !defined(SIGNALS_DONT_BREAK_READ)
688
 
  kill(current_pid, DRIZZLE_KILL_SIGNAL);
689
 
#endif
690
 
  shutdown_in_progress=1;                       // Safety if kill didn't work
691
 
#ifdef SIGNALS_DONT_BREAK_READ
692
 
  if (!kill_in_progress)
693
 
  {
694
 
    pthread_t tmp;
695
 
    abort_loop=1;
696
 
    if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
697
 
                           (void*) 0))
698
 
      sql_print_error(_("Can't create thread to kill server"));
699
 
  }
700
 
#endif
701
 
  return;;
702
 
}
703
680
 
704
681
/**
705
682
  Force server down. Kill all connections and threads and exit.
1207
1184
  return;
1208
1185
}
1209
1186
 
1210
 
/**
1211
 
  Close a connection.
1212
 
 
1213
 
  @param session                Thread handle
1214
 
  @param errcode        Error code to print to console
1215
 
  @param lock           1 if we have have to lock LOCK_thread_count
1216
 
 
1217
 
  @note
1218
 
    For the connection that is doing shutdown, this is called twice
1219
 
*/
1220
 
void close_connection(Session *session, uint32_t errcode, bool lock)
1221
 
{
1222
 
  st_vio *vio;
1223
 
  if (lock)
1224
 
    (void) pthread_mutex_lock(&LOCK_thread_count);
1225
 
  session->killed= Session::KILL_CONNECTION;
1226
 
  if ((vio= session->net.vio) != 0)
1227
 
  {
1228
 
    if (errcode)
1229
 
      net_send_error(session, errcode, ER(errcode)); /* purecov: inspected */
1230
 
    net_close(&(session->net));         /* vio is freed in delete session */
1231
 
  }
1232
 
  if (lock)
1233
 
    (void) pthread_mutex_unlock(&LOCK_thread_count);
1234
 
  return;;
1235
 
}
1236
1187
 
1237
1188
 
1238
1189
/** Called when a thread is aborted. */