コード例 #1
0
ファイル: storeinfo.c プロジェクト: MhdAlyan/courier
int do_copy_message(unsigned long n, int byuid, void *voidptr)
{
	struct do_copy_info *cpy_info=(struct do_copy_info *)voidptr;
	int	fd;
	struct imapflags new_flags;

	--n;
	fd=imapscan_openfile(current_mailbox, &current_maildir_info, n);
	if (fd < 0)	return (0);
	get_message_flags(current_maildir_info.msgs+n, 0, &new_flags);

	if (copy_message(fd, cpy_info, &new_flags,

			 acl_flags_adjust(cpy_info->acls,
					  &new_flags) ? NULL
			 : current_maildir_info.msgs[n].keywordMsg,
			 current_maildir_info.msgs[n].uid))
	{
		close(fd);
		return (-1);
	}
	close(fd);
	current_maildir_info.msgs[n].copiedflag=1;
	return (0);
}
コード例 #2
0
ファイル: server_lib.c プロジェクト: puresmw/egui
extern si_t send_window_cancel_message(struct egui_uds* uds_ptr, union message* msg, si_t window_descripter)
{
    union message msg_to_be_sent;
    copy_message(msg, &msg_to_be_sent);
    message_set_window_cancel(&msg_to_be_sent, window_descripter);
    return comm_send_message(uds_ptr, &msg_to_be_sent);
}
コード例 #3
0
ファイル: server_lib.c プロジェクト: puresmw/egui
extern si_t send_widget_resize_message(struct egui_uds* uds_ptr, union message* msg, si_t window_descripter, si_t x_axis, si_t y_axis, si_t x_size, si_t y_size)
{
    union message msg_to_be_sent;
    struct rectangle area = {0};
    copy_message(msg, &msg_to_be_sent);
    rectangle_set(&area, x_axis, y_axis, x_size, y_size);
    message_set_widget_resize(&msg_to_be_sent, window_descripter, &area);
    return comm_send_message(uds_ptr, &msg_to_be_sent);
}
コード例 #4
0
ファイル: server_lib.c プロジェクト: puresmw/egui
extern si_t send_widget_move_message(struct egui_uds* uds_ptr, union message* msg, si_t window_descripter, si_t x_offset, si_t y_offset)
{
    union message msg_to_be_sent;
    struct point p = {0};
    point_set(&p, x_offset, y_offset);
    copy_message(msg, &msg_to_be_sent);
    message_set_widget_move(&msg_to_be_sent, window_descripter, &p);
    return comm_send_message(uds_ptr, &msg_to_be_sent);
}
コード例 #5
0
ファイル: sys_ipc.c プロジェクト: BruceYi/okl4
/* Send an IPC to another thread. */
NORETURN void
sys_ipc_recv(word_t src_thread, word_t operation)
{
    /* Ensure the thread exists. */
    if (EXPECT_FALSE(src_thread >= max_tcbs && src_thread != IPC_WAIT_ANY)) {
        syscall_return_error(IPC_ERROR, EINVAL);
    }

    spin_lock(&ipc_lock);

    /* Get first thread on send queue. */
    tcb_t *src = current_tcb->ipc_send_head;

    /* If there are no threads, go to sleep. */
    if (src == NULL) {
        current_tcb->ipc_waiting_for = src;
        tcb_t *next = deactivate_self_schedule(THREAD_STATE_WAIT_IPC_RECV);
        spin_unlock(&ipc_lock);
        switch_to(next);
    }

    /* Otherwise, dequeue the thread. */
    dequeue_send(current_tcb, src);

    /* Copy the message across and wake up the sender. */
    copy_message(src, current_tcb);

    /* Is the sender performing a call? */
    if (src->thread_state == THREAD_STATE_WAIT_IPC_CALL) {
        /* Move it into receive phase. 'ipc_waiting_for' should already be set
         * to us. */
        word_t tid = src->tid;
        ASSERT(src->ipc_waiting_for == current_tcb);
        src->thread_state = THREAD_STATE_WAIT_IPC_RECV;
        spin_unlock(&ipc_lock);
        syscall_return_success(tid);
        /* NOTREACHED */
    }

    /* If the sender was not performing a call, wake them up. */
    src->ipc_waiting_for = NULL;
    set_syscall_return_val_success(src, 0);
    set_syscall_return_val_success(current_tcb, src->tid);
    tcb_t *next = activate_schedule(src);
    spin_unlock(&ipc_lock);
    switch_to(next);
    /* NOTREACHED */
}
コード例 #6
0
ファイル: delay.c プロジェクト: haolei/tcpcopy
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  delay_table_add
 *  Description:  add msg to delay table
 * =====================================================================================
 */
void delay_table_add(uint64_t key,struct receiver_msg_st *msg){
	linklist *msg_list=NULL;
	struct receiver_msg_st *cmsg = NULL;
	lnodeptr pnode=NULL;

	delay_table_delete_obsolete(key);	
	msg_list =(linklist *)hash_find(table,key);
	cmsg = copy_message(msg);
	pnode = lnode_malloc((void *)cmsg);
	if(NULL == msg_list){
		lCount++;
		msg_list = linklist_create();
		hash_add(table,key,msg_list);
	}
	mCount++;
	linklist_append(msg_list,pnode);
	return;
}
コード例 #7
0
ファイル: tc_delay.c プロジェクト: barrysun/intercept
void
delay_table_add(uint64_t key, struct msg_server_s *msg)
{
    tc_pool_t           *pool;
    p_link_node          ln;
    delay_sess_t        *s;
    struct msg_server_s *cmsg;

    s = (delay_sess_t *) hash_find(table, key);
    if (s == NULL) {
        pool = tc_create_pool(TC_DEFAULT_POOL_SIZE, 0);

        if (pool != NULL) {

            s = (delay_sess_t *) tc_pcalloc(pool, sizeof(delay_sess_t));
            if (s != NULL) {
                s->key = key;
                s->pool = pool;
                s->msg_list = link_list_create(s->pool);
                s->evt = tc_event_add_timer(s->pool, OUTPUT_INTERVAL, s, 
                        tc_delay_del_obs);
                msg_ls_cnt++;
                hash_add(table, s->pool, key, s);
            } else {
                return;
            }
        } else {
            return;
        }
    }

    cmsg = copy_message(s->pool, msg);
    if (cmsg != NULL) {
        ln   = link_node_malloc(s->pool, (void *) cmsg);
        link_list_append(s->msg_list, ln);

        msg_item_cnt++;
    }
}
コード例 #8
0
ファイル: sys_ipc.c プロジェクト: BruceYi/okl4
/* Send an IPC to another thread. Return the thread that should be next
 * scheduled. */
static tcb_t *
do_send(tcb_t *dest, int is_call, int is_non_blocking)
{
    /* If the thread is not ready to receive, go to sleep or abort the call. */
    if (EXPECT_FALSE(!is_ready_to_receive(current_tcb, dest)))
        goto not_ready;

    /* Otherwise, copy our message across. */
    copy_message(current_tcb, dest);
    dest->ipc_waiting_for = NULL;
    set_syscall_return_val_success(dest, current_tcb->tid);

    /* If we are not performing a call, just wake up the destination and we are
     * done. */
    if (!is_call) {
        set_syscall_return_val_success(current_tcb, 0);
        return activate_schedule(dest);
    }

    /* Otherwise, wake up the destination and go to sleep. */
    current_tcb->ipc_waiting_for = dest;
    activate(dest);
    deactivate_self(THREAD_STATE_WAIT_IPC_RECV);
    return schedule();

    /* Destination thread not ready. */
not_ready:;
    if (is_non_blocking) {
        /* Return an error and keep running. */
        set_syscall_return_val_error(current_tcb, IPC_ERROR, EWOULDBLOCK);
        return current_tcb;
    }

    /* Go to sleep. */
    enqueue_send(dest, current_tcb);
    current_tcb->ipc_waiting_for = dest;
    return deactivate_self_schedule(
            is_call ? THREAD_STATE_WAIT_IPC_CALL : THREAD_STATE_WAIT_IPC_SEND);
}
コード例 #9
0
ファイル: tc_delay.c プロジェクト: MistShi/tcpcopy
/* add message to delay table */
void
delay_table_add(uint64_t key, struct msg_server_s *msg)
{
    link_list           *msg_list;
    p_link_node          ln;
    struct msg_server_s *cmsg;

    msg_list = (link_list *) hash_find(table, key);
    if (msg_list == NULL) {
        msg_ls_cnt++;
        msg_list = link_list_create();
        hash_add(table, key, msg_list);
    }

    cmsg = copy_message(msg);
    if (cmsg != NULL) {
        ln   = link_node_malloc((void *) cmsg);
        link_list_append(msg_list, ln);

        msg_item_cnt++;
    }

    return;
}