Commit b4dbbee6 authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

Completed cleanups of queues when the daemon is stopping

parent 964be441
......@@ -99,8 +99,7 @@ extern struct fifo * fd_g_outgoing; /* messages to be sent to other peers on the
extern struct fifo * fd_g_local; /* messages to be handled to local extensions */
/* Message queues */
int fd_queues_init(void);
int fd_queues_fini_rt(void);
int fd_queues_fini_disp(void);
int fd_queues_fini(struct fifo ** queue);
/* Create all the dictionary objects defined in the Diameter base RFC. */
int fd_dict_base_protocol(struct dictionary * dict);
......
......@@ -50,30 +50,32 @@ int fd_queues_init(void)
return 0;
}
/* Destroy the routing message queues */
int fd_queues_fini_rt(void)
/* Destroy a queue after emptying it (and dumping the content) */
int fd_queues_fini(struct fifo ** queue)
{
TRACE_ENTRY();
/* Empty all contents */
TODO("Empty all contents (dump to log file ?)");
struct msg * msg;
int ret = 0;
/* Now, delete the queues */
CHECK_FCT( fd_fifo_del ( &fd_g_incoming ) );
CHECK_FCT( fd_fifo_del ( &fd_g_outgoing ) );
TRACE_ENTRY("%p", queue);
return 0;
}
/* Note : the threads that post into this queue should already been stopped before this !!! */
/* Destroy the local message queue */
int fd_queues_fini_disp(void)
{
TRACE_ENTRY();
/* Empty all contents */
TODO("Empty all contents (dump to log file ?)");
while (1) {
/* Check if there is a message in the queue */
ret = fd_fifo_tryget(*queue, &msg);
if (ret == EWOULDBLOCK)
break;
CHECK_FCT(ret);
/* We got one! */
fd_log_debug("The following message is lost because the daemon is stopping:\n");
fd_msg_dump_walk(NONE, msg);
fd_msg_free(msg);
}
CHECK_FCT( fd_fifo_del ( &fd_g_local ) );
/* Now, delete the empty queue */
CHECK_FCT( fd_fifo_del ( queue ) );
return 0;
}
This diff is collapsed.
......@@ -561,6 +561,7 @@ struct fd_rt_out_hdl;
enum fd_rt_out_score {
FD_SCORE_NO_DELIVERY = -70, /* We should not send this message to this candidate */
FD_SCORE_INI = -2, /* All candidates are initialized with this value */
FD_SCORE_LOAD_BALANCE = 1, /* Use this to differentiate between several peers with the same score */
FD_SCORE_DEFAULT = 5, /* The peer is a default route for all messages */
FD_SCORE_DEFAULT_REALM = 10, /* The peer is a default route for this realm */
......
......@@ -1632,7 +1632,7 @@ int fd_rtd_candidate_add(struct rt_data * rtd, char * peerid);
void fd_rtd_candidate_del(struct rt_data * rtd, char * peerid, size_t sz /* if !0, peerid does not need to be \0 terminated */);
/* Extract the list of valid candidates, and initialize their scores to 0 */
void fd_rtd_candidate_extract(struct rt_data * rtd, struct fd_list ** candidates);
void fd_rtd_candidate_extract(struct rt_data * rtd, struct fd_list ** candidates, int ini_score);
/* If a peer returned a protocol error for this message, save it so that we don't try to send it there again */
int fd_rtd_error_add(struct rt_data * rtd, char * sentto, uint8_t * origin, size_t originsz, uint32_t rcode);
......@@ -2605,7 +2605,7 @@ int fd_fifo_get_int ( struct fifo * queue, void ** item );
*
* PARAMETERS:
* queue : The queue from which the element must be retrieved.
* msg : On return, the message is stored here.
* item : On return, the first element of the queue is stored here.
*
* DESCRIPTION:
* This function is similar to fd_fifo_get, except that it will not block if
......
......@@ -226,7 +226,7 @@ int fd_rtd_error_add(struct rt_data * rtd, char * sentto, uint8_t * origin, siz
}
/* Extract the list of valid candidates, and initialize their scores to 0 */
void fd_rtd_candidate_extract(struct rt_data * rtd, struct fd_list ** candidates)
void fd_rtd_candidate_extract(struct rt_data * rtd, struct fd_list ** candidates, int ini_score)
{
TRACE_ENTRY("%p %p", rtd, candidates);
CHECK_PARAMS_DO( candidates, return );
......@@ -235,11 +235,11 @@ void fd_rtd_candidate_extract(struct rt_data * rtd, struct fd_list ** candidates
*candidates = &rtd->candidates;
if (rtd->extracted) {
/* Reset all scores to 0 */
/* Reset all scores to INITIAL score */
struct fd_list * li;
for (li = rtd->candidates.next; li != &rtd->candidates; li = li->next) {
struct rtd_candidate * c = (struct rtd_candidate *) li;
c->score = 0;
c->score = ini_score;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment