~ubuntu-branches/ubuntu/karmic/mysql-dfsg-5.1/karmic

« back to all changes in this revision

Viewing changes to sql/sql_manager.cc

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-02-10 16:42:05 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090210164205-ej41ocvm4z1s14nq
Tags: 5.1.31-1ubuntu1
* Merge from debian experimental, remaining changes: 
  - debian/mysql-server-5.1.config: ask for MySQL root password at priority
    high instead of medium so that the password prompt is seen on a default
    install. (LP: #319843)
  - debian/control: 
    + Don't build mysql-server, mysql-client, mysql-common and 
      libmysqlclient15-dev binary packages since they're still provided 
      by mysql-dfsg-5.0.
    + Rename libmysqlclient-dev package to libmysqlclient16-dev (LP: #316280).
      Make it conflict with libmysqlclient15-dev.
    + Make mysql-{client,server}-5.1 packages conflict and
      replace mysql-{client,server}-5.0, but not provide 
      mysql-{client,server}.
    + Depend on a specific version of mysql-common rather than the src 
      version of mysql-dfsg-5.1 since mysql-common is currently part of
      mysql-dfsg-5.0.
  - debian/rules: added -fno-strict-aliasing to CFLAGS to get
    around mysql testsuite build failures.
* debian/patches/92_ssl_test_cert.dpatch: certificate expiration in 
  test suite (LP: #323755).
* Dropped changes:
  - all of the changes made to support both 5.0 and 5.1 installed at the
    same time have been dropped now that amarok doesn't depend on
    mysql-server-5.1 anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "mysql_priv.h"
25
25
 
26
 
ulong volatile manager_status;
27
 
bool volatile manager_thread_in_use;
 
26
 
 
27
static bool volatile manager_thread_in_use;
 
28
static bool abort_manager;
28
29
 
29
30
pthread_t manager_thread;
30
31
pthread_mutex_t LOCK_manager;
63
64
pthread_handler_t handle_manager(void *arg __attribute__((unused)))
64
65
{
65
66
  int error = 0;
66
 
  ulong status;
67
67
  struct timespec abstime;
68
68
  bool reset_flush_time = TRUE;
69
69
  struct handler_cb *cb= NULL;
72
72
 
73
73
  pthread_detach_this_thread();
74
74
  manager_thread = pthread_self();
75
 
  manager_status = 0;
76
75
  manager_thread_in_use = 1;
77
76
 
78
77
  for (;;)
87
86
        set_timespec(abstime, flush_time);
88
87
        reset_flush_time = FALSE;
89
88
      }
90
 
      while (!manager_status && (!error || error == EINTR) && !abort_loop)
 
89
      while ((!error || error == EINTR) && !abort_manager)
91
90
        error= pthread_cond_timedwait(&COND_manager, &LOCK_manager, &abstime);
92
91
    }
93
92
    else
94
93
    {
95
 
      while (!manager_status && (!error || error == EINTR) && !abort_loop)
 
94
      while ((!error || error == EINTR) && !abort_manager)
96
95
        error= pthread_cond_wait(&COND_manager, &LOCK_manager);
97
96
    }
98
 
    status = manager_status;
99
 
    manager_status = 0;
100
97
    if (cb == NULL)
101
98
    {
102
99
      cb= cb_list;
104
101
    }
105
102
    pthread_mutex_unlock(&LOCK_manager);
106
103
 
107
 
    if (abort_loop)
 
104
    if (abort_manager)
108
105
      break;
109
106
 
110
107
    if (error == ETIMEDOUT || error == ETIME)
121
118
      my_free((uchar*)cb, MYF(0));
122
119
      cb= next;
123
120
    }
124
 
 
125
 
    if (status)
126
 
      DBUG_PRINT("error", ("manager did not handle something: %lx", status));
127
121
  }
128
122
  manager_thread_in_use = 0;
 
123
  DBUG_LEAVE; // Can't use DBUG_RETURN after my_thread_end
129
124
  my_thread_end();
130
 
  DBUG_RETURN(NULL);
131
 
}
 
125
  return (NULL);
 
126
}
 
127
 
 
128
 
 
129
/* Start handle manager thread */
 
130
void start_handle_manager()
 
131
{
 
132
  DBUG_ENTER("start_handle_manager");
 
133
  abort_manager = false;
 
134
  if (flush_time && flush_time != ~(ulong) 0L)
 
135
  {
 
136
    pthread_t hThread;
 
137
    if (pthread_create(&hThread,&connection_attrib,handle_manager,0))
 
138
      sql_print_warning("Can't create handle_manager thread");
 
139
  }
 
140
  DBUG_VOID_RETURN;
 
141
}
 
142
 
 
143
 
 
144
/* Initiate shutdown of handle manager thread */
 
145
void stop_handle_manager()
 
146
{
 
147
  DBUG_ENTER("stop_handle_manager");
 
148
  abort_manager = true;
 
149
  pthread_mutex_lock(&LOCK_manager);
 
150
  if (manager_thread_in_use)
 
151
  {
 
152
    DBUG_PRINT("quit", ("initiate shutdown of handle manager thread: 0x%lx",
 
153
                        (ulong)manager_thread));
 
154
   pthread_cond_signal(&COND_manager);
 
155
  }
 
156
  pthread_mutex_unlock(&LOCK_manager);
 
157
  DBUG_VOID_RETURN;
 
158
}
 
159