void network_conn_available_handle(int G_GNUC_UNUSED event_fd, short G_GNUC_UNUSED events, void* user_data) { int err = 0; char ping[1]; network_mysqld_con_lua_t *st; injection *inj; GString *packet; chassis *chas = user_data; guint index = chassis_event_thread_index_get(); chassis_event_thread_t *thread = g_ptr_array_index(chas->threads, index); if (read(thread->con_read_fd, ping, 1) != 1) g_message("%s:pipes - read error,error message:%s", G_STRLOC, g_strerror(errno)); network_mysqld_con *con = g_queue_pop_head(thread->block_con_queue); if(con == NULL) return; network_socket* sock = network_connection_pool_lua_swap(con, con->backend_ndx, 0, &err); if(sock == NULL) { g_queue_push_tail(thread->block_con_queue, con); return; } con->server = sock; st = con->plugin_con_state; inj = g_queue_peek_head(st->injected.queries); con->resultset_is_needed = inj->resultset_is_needed; /* let the lua-layer decide if we want to buffer the result or not */ network_mysqld_queue_reset(con->server); network_mysqld_queue_append(con->server, con->server->send_queue, S(inj->query)); while ((packet = g_queue_pop_head(con->client->recv_queue->chunks))) g_string_free(packet, TRUE); con->state = CON_STATE_SEND_QUERY; network_mysqld_con_reset_command_response_state(con); network_mysqld_con_handle(-1, 0, con); }
void chassis_event_handle(int G_GNUC_UNUSED event_fd, short G_GNUC_UNUSED events, void* user_data) { chassis_event_thread_t* thread = user_data; char ping[1]; if (read(thread->notify_receive_fd, ping, 1) != 1) g_log_dbproxy(g_error, "pipes - read error"); network_mysqld_con* client_con = g_async_queue_try_pop(thread->event_queue); if (client_con != NULL) { g_atomic_pointer_add(&(thread->thread_status_var.thread_stat[THREAD_STAT_EVENT_WAITING]), -1); chassis_event_add_connection(NULL, thread, client_con); network_mysqld_con_handle(-1, 0, client_con); } }