Пример #1
0
/* 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);
    }

}
Пример #2
0
bool hash_del(hash_table *table, uint64_t key)
{
    link_list   *l = get_link_list(table, key); 
    p_link_node ln = hash_find_node(table, key);
    if(ln != NULL){
        table->total--;
        link_list_remove(l, ln);
        link_node_internal_free(ln);
        free(ln);
        return true;
    }else{
        return false;
    }
}
Пример #3
0
/* 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++;
}
Пример #4
0
int
link_list_clear(link_list *l)
{
    int         count = 0;
    p_link_node p, next;

    p = l->head.next;
    while (p != &(l->head)) {
        next = p->next;
        count++;
        link_node_internal_free(p);
        free(p);
        p = next;
    }   

    l->head.next = &(l->head);
    l->head.prev = &(l->head);
    l->size = 0;

    return count;

}