mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 16:57:44 +00:00
zebra: make incoming zserv message-processing a singleton event
Stop creating individual, one-time events as each batch of incoming zserv/zapi messages is processed - use a singleton event so that the incoming message activity is more fair if the zebra main pthread has other events to run. Signed-off-by: Mark Stapp <mjs@voltanet.io>
This commit is contained in:
parent
b7822d2016
commit
dded2aba4a
@ -492,8 +492,8 @@ static int zserv_process_messages(struct thread *thread)
|
|||||||
struct zserv *client = THREAD_ARG(thread);
|
struct zserv *client = THREAD_ARG(thread);
|
||||||
struct stream *msg;
|
struct stream *msg;
|
||||||
struct stream_fifo *cache = stream_fifo_new();
|
struct stream_fifo *cache = stream_fifo_new();
|
||||||
|
|
||||||
uint32_t p2p = zebrad.packets_to_process;
|
uint32_t p2p = zebrad.packets_to_process;
|
||||||
|
bool need_resched = false;
|
||||||
|
|
||||||
pthread_mutex_lock(&client->ibuf_mtx);
|
pthread_mutex_lock(&client->ibuf_mtx);
|
||||||
{
|
{
|
||||||
@ -505,6 +505,12 @@ static int zserv_process_messages(struct thread *thread)
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg = NULL;
|
msg = NULL;
|
||||||
|
|
||||||
|
/* Need to reschedule processing work if there are still
|
||||||
|
* packets in the fifo.
|
||||||
|
*/
|
||||||
|
if (stream_fifo_head(client->ibuf_fifo))
|
||||||
|
need_resched = true;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&client->ibuf_mtx);
|
pthread_mutex_unlock(&client->ibuf_mtx);
|
||||||
|
|
||||||
@ -516,6 +522,10 @@ static int zserv_process_messages(struct thread *thread)
|
|||||||
|
|
||||||
stream_fifo_free(cache);
|
stream_fifo_free(cache);
|
||||||
|
|
||||||
|
/* Reschedule ourselves if necessary */
|
||||||
|
if (need_resched)
|
||||||
|
zserv_event(client, ZSERV_PROCESS_MESSAGES);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,6 +638,7 @@ void zserv_close_client(struct zserv *client)
|
|||||||
|
|
||||||
thread_cancel_event(zebrad.master, client);
|
thread_cancel_event(zebrad.master, client);
|
||||||
THREAD_OFF(client->t_cleanup);
|
THREAD_OFF(client->t_cleanup);
|
||||||
|
THREAD_OFF(client->t_process);
|
||||||
|
|
||||||
/* destroy pthread */
|
/* destroy pthread */
|
||||||
frr_pthread_destroy(client->pthread);
|
frr_pthread_destroy(client->pthread);
|
||||||
@ -828,7 +839,7 @@ void zserv_event(struct zserv *client, enum zserv_event event)
|
|||||||
break;
|
break;
|
||||||
case ZSERV_PROCESS_MESSAGES:
|
case ZSERV_PROCESS_MESSAGES:
|
||||||
thread_add_event(zebrad.master, zserv_process_messages, client,
|
thread_add_event(zebrad.master, zserv_process_messages, client,
|
||||||
0, NULL);
|
0, &client->t_process);
|
||||||
break;
|
break;
|
||||||
case ZSERV_HANDLE_CLIENT_FAIL:
|
case ZSERV_HANDLE_CLIENT_FAIL:
|
||||||
thread_add_event(zebrad.master, zserv_handle_client_fail,
|
thread_add_event(zebrad.master, zserv_handle_client_fail,
|
||||||
|
@ -73,6 +73,9 @@ struct zserv {
|
|||||||
struct thread *t_read;
|
struct thread *t_read;
|
||||||
struct thread *t_write;
|
struct thread *t_write;
|
||||||
|
|
||||||
|
/* Event for message processing, for the main pthread */
|
||||||
|
struct thread *t_process;
|
||||||
|
|
||||||
/* Threads for the main pthread */
|
/* Threads for the main pthread */
|
||||||
struct thread *t_cleanup;
|
struct thread *t_cleanup;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user