]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_opaque.c
Merge pull request #13479 from ryndia/fix_leak
[mirror_frr.git] / zebra / zebra_opaque.c
index 3d757566e05db9d986f79ec06dcd3d9d7944e03c..8ceb1f8dc56fa54ed347f28c0f9228ab494b04dd 100644 (file)
@@ -1,20 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Zebra opaque message handler module
  * Copyright (c) 2020 Volta Networks, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 
@@ -90,10 +77,10 @@ static struct zebra_opaque_globals {
        struct frr_pthread *pthread;
 
        /* Event-delivery context 'master' for the module */
-       struct thread_master *master;
+       struct event_loop *master;
 
        /* Event/'thread' pointer for queued zapi messages */
-       struct thread *t_msgs;
+       struct event *t_msgs;
 
        /* Input fifo queue to the module, and lock to protect it. */
        pthread_mutex_t mutex;
@@ -107,7 +94,7 @@ static const char LOG_NAME[] = "Zebra Opaque";
 /* Prototypes */
 
 /* Main event loop, processing incoming message queue */
-static void process_messages(struct thread *event);
+static void process_messages(struct event *event);
 static int handle_opq_registration(const struct zmsghdr *hdr,
                                   struct stream *msg);
 static int handle_opq_unregistration(const struct zmsghdr *hdr,
@@ -161,8 +148,8 @@ void zebra_opaque_start(void)
        atomic_store_explicit(&zo_info.run, 1, memory_order_relaxed);
 
        /* Enqueue an initial event for the pthread */
-       thread_add_event(zo_info.master, process_messages, NULL, 0,
-                        &zo_info.t_msgs);
+       event_add_event(zo_info.master, process_messages, NULL, 0,
+                       &zo_info.t_msgs);
 
        /* And start the pthread */
        frr_pthread_run(zo_info.pthread, NULL);
@@ -247,7 +234,7 @@ uint32_t zebra_opaque_enqueue_batch(struct stream_fifo *batch)
        /* Dequeue messages from the incoming batch, and save them
         * on the module fifo.
         */
-       frr_with_mutex(&zo_info.mutex) {
+       frr_with_mutex (&zo_info.mutex) {
                msg = stream_fifo_pop(batch);
                while (msg) {
                        stream_fifo_push(&zo_info.in_fifo, msg);
@@ -261,8 +248,8 @@ uint32_t zebra_opaque_enqueue_batch(struct stream_fifo *batch)
                if (IS_ZEBRA_DEBUG_RECV && IS_ZEBRA_DEBUG_DETAIL)
                        zlog_debug("%s: received %u messages",
                                   __func__, counter);
-               thread_add_event(zo_info.master, process_messages, NULL, 0,
-                                &zo_info.t_msgs);
+               event_add_event(zo_info.master, process_messages, NULL, 0,
+                               &zo_info.t_msgs);
        }
 
        return counter;
@@ -271,7 +258,7 @@ uint32_t zebra_opaque_enqueue_batch(struct stream_fifo *batch)
 /*
  * Pthread event loop, process the incoming message queue.
  */
-static void process_messages(struct thread *event)
+static void process_messages(struct event *event)
 {
        struct stream_fifo fifo;
        struct stream *msg;
@@ -288,7 +275,7 @@ static void process_messages(struct thread *event)
         * Dequeue some messages from the incoming queue, temporarily
         * save them on the local fifo
         */
-       frr_with_mutex(&zo_info.mutex) {
+       frr_with_mutex (&zo_info.mutex) {
 
                for (i = 0; i < zo_info.msgs_per_cycle; i++) {
                        msg = stream_fifo_pop(&zo_info.in_fifo);
@@ -330,8 +317,8 @@ done:
        if (need_resched) {
                atomic_fetch_add_explicit(&zo_info.yields, 1,
                                          memory_order_relaxed);
-               thread_add_event(zo_info.master, process_messages, NULL, 0,
-                                &zo_info.t_msgs);
+               event_add_event(zo_info.master, process_messages, NULL, 0,
+                               &zo_info.t_msgs);
        }
 
        /* This will also free any leftover messages, in the shutdown case */