| 234 | namespace { |
| 235 | |
| 236 | int |
| 237 | wait_server_to_start(THD *thd, volatile int& shutdown_flag) |
| 238 | { |
| 239 | int r = 0; |
| 240 | DBG_SHUT(fprintf(stderr, "HNDSOCK wsts\n")); |
| 241 | pthread_mutex_lock(&LOCK_server_started); |
| 242 | while (!mysqld_server_started) { |
| 243 | timespec abstime = { }; |
| 244 | set_timespec(abstime, 1); |
| 245 | pthread_cond_timedwait(&COND_server_started, &LOCK_server_started, |
| 246 | &abstime); |
| 247 | pthread_mutex_unlock(&LOCK_server_started); |
| 248 | pthread_mutex_lock(&thd->mysys_var->mutex); |
| 249 | int killed = thd_killed(thd); |
| 250 | pthread_mutex_unlock(&thd->mysys_var->mutex); |
| 251 | DBG_SHUT(fprintf(stderr, "HNDSOCK wsts kst %d\n", killed)); |
| 252 | pthread_mutex_lock(&LOCK_server_started); |
| 253 | if (killed) { |
| 254 | DBG_SHUT(fprintf(stderr, "HNDSOCK wsts kst %d break\n", killed)); |
| 255 | r = -1; |
| 256 | break; |
| 257 | } |
| 258 | if (shutdown_flag) { |
| 259 | DBG_SHUT(fprintf(stderr, "HNDSOCK wsts kst shut break\n")); |
| 260 | r = -1; |
| 261 | break; |
| 262 | } |
| 263 | } |
| 264 | pthread_mutex_unlock(&LOCK_server_started); |
| 265 | DBG_SHUT(fprintf(stderr, "HNDSOCK wsts done\n")); |
| 266 | return r; |
| 267 | } |
| 268 | |
| 269 | }; // namespace |
| 270 | |