static tb_void_t tb_aiop_ptor_kilo(tb_aicp_ptor_impl_t* ptor, tb_aico_impl_t* aico) { // check tb_aiop_ptor_impl_t* impl = (tb_aiop_ptor_impl_t*)ptor; tb_assert_and_check_return(impl && impl->timer && impl->ltimer && impl->aiop && aico); // trace tb_trace_d("kilo: aico: %p, type: %u: ..", aico, aico->type); // the aiop aico tb_aiop_aico_t* aiop_aico = (tb_aiop_aico_t*)aico; // add timeout task for killing the accept socket if (aico->type == TB_AICO_TYPE_SOCK && aiop_aico->aice.code == TB_AICE_CODE_ACPT) { // add task if (!aiop_aico->task) { aiop_aico->task = tb_ltimer_task_init(impl->ltimer, 10000, tb_false, tb_aiop_spak_wait_timeout, aico); aiop_aico->bltimer = 1; } } // kill the task if (aiop_aico->task) { // trace tb_trace_d("kilo: aico: %p, type: %u, task: %p: ..", aico, aico->type, aiop_aico->task); // kill task if (aiop_aico->bltimer) tb_ltimer_task_kill(impl->ltimer, aiop_aico->task); else tb_timer_task_kill(impl->timer, aiop_aico->task); } // kill sock if (aico->type == TB_AICO_TYPE_SOCK && aico->handle) { // trace tb_trace_d("kilo: aico: %p, type: %u, sock: %p: ..", aico, aico->type, aico->handle); // kill it tb_socket_kill(aico->handle, TB_SOCKET_KILL_RW); } // kill file else if (aico->type == TB_AICO_TYPE_FILE) { // kill it tb_aicp_file_kilo(impl, aico); } /* the aiop will wait long time if the lastest task wait period is too long * so spak the aiop manually for spak the ltimer */ tb_aiop_spak(impl->aiop); // trace tb_trace_d("kilo: aico: %p, type: %u: ok", aico, aico->type); }
static tb_void_t tb_aiop_spak_klist(tb_aiop_ptor_impl_t* impl) { // check tb_assert_and_check_return(impl && impl->klist); // enter tb_spinlock_enter(&impl->klock); // kill it if exists the killing aico if (tb_vector_size(impl->klist)) { // kill all tb_for_all_if (tb_aico_impl_t*, aico, impl->klist, aico) { // the aiop aico tb_aiop_aico_t* aiop_aico = (tb_aiop_aico_t*)aico; // sock? if (aico->type == TB_AICO_TYPE_SOCK) { // add it first if do not exists timeout task if (!aiop_aico->task) { aiop_aico->task = tb_ltimer_task_init(impl->ltimer, 10000, tb_false, tb_aiop_spak_wait_timeout, aico); aiop_aico->bltimer = 1; } // kill the task if (aiop_aico->task) { // kill task if (aiop_aico->bltimer) tb_ltimer_task_kill(impl->ltimer, aiop_aico->task); else tb_timer_task_kill(impl->timer, aiop_aico->task); } } else if (aico->type == TB_AICO_TYPE_FILE) { // kill file tb_aicp_file_kilo(impl, aico); } // trace tb_trace_d("kill: aico: %p, type: %u: ok", aico, aico->type); } }