コード例 #1
0
ファイル: hooks.c プロジェクト: KaushikBh/freeDiameter
struct fd_hook_permsgdata * fd_hook_get_request_pmd(struct fd_hook_data_hdl *data_hdl, struct msg * answer)
{
    struct msg * qry;
    struct fd_msg_pmdl *pmdl;
    struct fd_hook_permsgdata * ret = NULL;
    struct fd_list * li;

    CHECK_FCT_DO( fd_msg_answ_getq(answer, &qry), return NULL );
    if (!qry)
        return NULL;

    pmdl = fd_msg_pmdl_get(qry);
    if (!pmdl)
        return NULL;

    CHECK_POSIX_DO( pthread_mutex_lock(&pmdl->lock), );
    /* Search in the list for an item with the same handle. The list is ordered by this handle */
    for (li=pmdl->sentinel.next; li != &pmdl->sentinel; li = li->next) {
        struct pmd_list_item * pli = (struct pmd_list_item *) li;
        if (pli->hdl == data_hdl)
            ret = &pli->pmd;
        if (pli->hdl >= data_hdl)
            break;
    }
    CHECK_POSIX_DO( pthread_mutex_unlock(&pmdl->lock), );
    return ret;
}
コード例 #2
0
ファイル: hooks.c プロジェクト: KaushikBh/freeDiameter
struct fd_hook_permsgdata * fd_hook_get_pmd(struct fd_hook_data_hdl *data_hdl, struct msg * msg)
{
    struct fd_msg_pmdl *pmdl;
    struct fd_hook_permsgdata * ret = NULL;
    struct fd_list * li;

    pmdl = fd_msg_pmdl_get(msg);
    if (!pmdl)
        return NULL;

    ret = get_or_create_pmd(pmdl, data_hdl);
    return ret;
}
コード例 #3
0
ファイル: hooks.c プロジェクト: KaushikBh/freeDiameter
/* Save the list of pmd into the message structure, as well as the callback to free this list */
void   fd_hook_associate(struct msg * msg, struct fd_msg_pmdl * pmdl)
{
    struct fd_msg_pmdl * in_msg;

    CHECK_PARAMS_DO( msg && pmdl, return );
    in_msg = fd_msg_pmdl_get(msg);
    ASSERT(in_msg && (in_msg->sentinel.o == NULL)); /* error / already initialized ??? */
    in_msg->sentinel.o = pmdl_free;
    /* Now move all items from the pmdl pointer into the initialized list */
    CHECK_POSIX_DO( pthread_mutex_lock(&pmdl->lock), );
    fd_list_move_end(&in_msg->sentinel, &pmdl->sentinel);
    CHECK_POSIX_DO( pthread_mutex_unlock(&pmdl->lock), );
    pmdl_free(pmdl);
    /* We're done */
}
コード例 #4
0
ファイル: peers.c プロジェクト: Lucky7Studio/freeDiameter
/* Empty the lists of p_tosend, p_failover, and p_sentreq messages */
void fd_peer_failover_msg(struct fd_peer * peer)
{
	struct msg *m;
	TRACE_ENTRY("%p", peer);
	CHECK_PARAMS_DO(CHECK_PEER(peer), return);
	
	/* Requeue all messages in the "out" queue */
	while ( fd_fifo_tryget(peer->p_tosend, &m) == 0 ) {
		/* but only if they are routable */
		if (fd_msg_is_routable(m)) {
			fd_hook_call(HOOK_MESSAGE_FAILOVER, m, peer, NULL, fd_msg_pmdl_get(m));
			CHECK_FCT_DO(fd_fifo_post_noblock(fd_g_outgoing, (void *)&m), 
				{
					/* fallback: destroy the message */
					fd_hook_call(HOOK_MESSAGE_DROPPED, m, NULL, "Internal error: unable to requeue this message during failover process", fd_msg_pmdl_get(m));
					CHECK_FCT_DO(fd_msg_free(m), /* What can we do more? */)
				} );
		} else {