Commit 7f4aee1c authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi
Browse files

Make killing of threads safer

parent e251f9d8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -46712,6 +46712,9 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.42
@itemize @bullet
@item
Fixed rare hang when doing @code{mysqladmin shutdown} when there was
a lot of activity in other threads.
@item
Fixed problem with @code{INSERT DELAYED} where delay thread could be
hanging on @code{upgrading locks} without any apparent reasons.
@item
+5 −3
Original line number Diff line number Diff line
@@ -575,12 +575,14 @@ extern int pthread_dummy(int);
struct st_my_thread_var
{
  int thr_errno;
  pthread_cond_t suspend, *current_cond;
  pthread_mutex_t mutex,  *current_mutex;
  pthread_cond_t suspend;
  pthread_mutex_t mutex;
  pthread_mutex_t * volatile current_mutex;
  pthread_cond_t * volatile current_cond;
  pthread_t pthread_self;
  long id;
  int cmp_length;
  volatile int abort;
  int volatile abort;
#ifndef DBUG_OFF
  gptr dbug;
  char name[THREAD_NAME_SIZE+1];
+4 −4
Original line number Diff line number Diff line
@@ -374,16 +374,16 @@ static my_bool wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
  }

  /* Set up control struct to allow others to abort locks */
  pthread_mutex_lock(&thread_var->mutex);
  thread_var->current_mutex= &data->lock->mutex;
  thread_var->current_cond=  cond;
  pthread_mutex_unlock(&thread_var->mutex);

  data->cond=cond;
  do
  while (!thread_var->abort || in_wait_list)
  {
    pthread_cond_wait(cond,&data->lock->mutex);
  } while (data->cond == cond && (!thread_var->abort || in_wait_list));
    if (data->cond != cond)
      break;
  }

  if (data->cond || data->type == TL_UNLOCK)
  {
+5 −11
Original line number Diff line number Diff line
@@ -1483,11 +1483,9 @@ longlong Item_func_get_lock::val_int()

  /* structure is now initialized.  Try to get the lock */
  /* Set up control struct to allow others to abort locks */
  pthread_mutex_lock(&thd->mysys_var->mutex);
  thd->proc_info="User lock";
  thd->mysys_var->current_mutex= &LOCK_user_locks;
  thd->mysys_var->current_cond=  &ull->cond;
  pthread_mutex_unlock(&thd->mysys_var->mutex);

#ifdef HAVE_TIMESPEC_TS_SEC
  abstime.ts_sec=time((time_t*) 0)+(time_t) timeout;
@@ -1497,15 +1495,11 @@ longlong Item_func_get_lock::val_int()
  abstime.tv_nsec=0;
#endif

  while ((error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime))
	 != ETIME && error != ETIMEDOUT && ull->locked)
  {
    if (thd->killed || abort_loop)
    {
  while (!thd->killed &&
	 (error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime))
	 != ETIME && error != ETIMEDOUT && ull->locked) ;
  if (thd->killed)
    error=EINTR;				// Return NULL
      break;
    }
  }
  if (ull->locked)
  {
    if (!--ull->count)
+0 −2
Original line number Diff line number Diff line
@@ -65,11 +65,9 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count)
      }	

      pthread_mutex_lock(&LOCK_open);
      pthread_mutex_lock(&thd->mysys_var->mutex);
      thd->mysys_var->current_mutex= &LOCK_open;
      thd->mysys_var->current_cond= &COND_refresh;
      thd->proc_info="Waiting for table";
      pthread_mutex_unlock(&thd->mysys_var->mutex);

      while (global_read_lock && ! thd->killed &&
	     thd->version == refresh_version)
Loading