| 225 | |
| 226 | |
| 227 | void tp_callback(TP_connection *c) |
| 228 | { |
| 229 | DBUG_ASSERT(c); |
| 230 | |
| 231 | Worker_thread_context worker_context; |
| 232 | |
| 233 | THD *thd= c->thd; |
| 234 | |
| 235 | c->state = TP_STATE_RUNNING; |
| 236 | |
| 237 | if (unlikely(!thd)) |
| 238 | { |
| 239 | /* No THD, need to login first. */ |
| 240 | DBUG_ASSERT(c->connect); |
| 241 | thd= c->thd= threadpool_add_connection(c->connect, c); |
| 242 | if (!thd) |
| 243 | { |
| 244 | /* Bail out on connect error.*/ |
| 245 | goto error; |
| 246 | } |
| 247 | c->connect= 0; |
| 248 | } |
| 249 | else |
| 250 | { |
| 251 | retry: |
| 252 | switch(threadpool_process_request(thd)) |
| 253 | { |
| 254 | case DISPATCH_COMMAND_WOULDBLOCK: |
| 255 | if (!thd->async_state.try_suspend()) |
| 256 | { |
| 257 | /* |
| 258 | All async operations finished meanwhile, thus nobody is will wake up |
| 259 | this THD. Therefore, we'll resume "manually" here. |
| 260 | */ |
| 261 | thd->async_state.m_state = thd_async_state::enum_async_state::RESUMED; |
| 262 | goto retry; |
| 263 | } |
| 264 | return; |
| 265 | case DISPATCH_COMMAND_CLOSE_CONNECTION: |
| 266 | /* QUIT or an error occurred. */ |
| 267 | goto error; |
| 268 | case DISPATCH_COMMAND_SUCCESS: |
| 269 | break; |
| 270 | } |
| 271 | thd->async_state.m_state= thd_async_state::enum_async_state::NONE; |
| 272 | } |
| 273 | |
| 274 | /* Set priority */ |
| 275 | c->priority= get_priority(c); |
| 276 | |
| 277 | /* Read next command from client. */ |
| 278 | c->set_io_timeout(thd->get_net_wait_timeout()); |
| 279 | c->state= TP_STATE_IDLE; |
| 280 | if (c->start_io()) |
| 281 | goto error; |
| 282 | return; |
| 283 | |
| 284 | error: |
nothing calls this directly
no test coverage detected