/* send delayed message according to the key */ void delay_table_send(uint64_t key, int fd) { link_list *msg_list; p_link_node first; msg_server_t *msg ; msg_list = (link_list *) hash_find(table, key); if (msg_list == NULL) { return; } while (!link_list_is_empty(msg_list)) { first = link_list_pop_first(msg_list); msg = (first->data); #if (INTERCEPT_COMBINED) buffer_and_send(fd, fd, msg); #else tc_socket_send(fd, (char *) msg, MSG_SERVER_SIZE); #endif msg_delay_sent_cnt++; msg_item_free_cnt++; link_node_internal_free(first); free(first); } }
void delay_table_snd(uint64_t key, int fd) { link_list *msg_list; p_link_node first; msg_server_t *msg ; delay_sess_t *s; s = (delay_sess_t *) hash_find(table, key); if (s == NULL || s->msg_list == NULL) { return; } msg_list = s->msg_list; while (!link_list_is_empty(msg_list)) { first = link_list_pop_first(msg_list); msg = (first->data); #if (TC_COMBINED) buffer_and_snd(fd, msg); #else if (tc_socket_snd(fd, (char *) msg, MSG_SERVER_SIZE) == TC_ERR) { tc_intercept_release_tunnel(fd, NULL); } #endif msg_delay_sent_cnt++; msg_item_free_cnt++; tc_pfree(s->pool, first); } }
/* delete delay table item according to the key */ void delay_table_del(uint64_t key) { link_list *msg_list; p_link_node first; msg_list = (link_list *) hash_find(table, key); if (msg_list == NULL) { return; } while (!link_list_is_empty(msg_list)) { first = link_list_pop_first(msg_list); msg_item_free_cnt++; link_node_internal_free(first); free(first); } hash_del(table, key); free(msg_list); msg_ls_free_cnt++; }