struct zserv *client = THREAD_ARG(thread);
struct stream *msg;
struct stream_fifo *cache = stream_fifo_new();
-
uint32_t p2p = zebrad.packets_to_process;
+ bool need_resched = false;
pthread_mutex_lock(&client->ibuf_mtx);
{
}
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);
stream_fifo_free(cache);
+ /* Reschedule ourselves if necessary */
+ if (need_resched)
+ zserv_event(client, ZSERV_PROCESS_MESSAGES);
+
return 0;
}
thread_cancel_event(zebrad.master, client);
THREAD_OFF(client->t_cleanup);
+ THREAD_OFF(client->t_process);
/* destroy pthread */
frr_pthread_destroy(client->pthread);
break;
case ZSERV_PROCESS_MESSAGES:
thread_add_event(zebrad.master, zserv_process_messages, client,
- 0, NULL);
+ 0, &client->t_process);
break;
case ZSERV_HANDLE_CLIENT_FAIL:
thread_add_event(zebrad.master, zserv_handle_client_fail,
struct thread *t_read;
struct thread *t_write;
+ /* Event for message processing, for the main pthread */
+ struct thread *t_process;
+
/* Threads for the main pthread */
struct thread *t_cleanup;