]> git.proxmox.com Git - mirror_frr.git/blobdiff - tests/lib/test_zmq.c
*: Convert `struct event_master` to `struct event_loop`
[mirror_frr.git] / tests / lib / test_zmq.c
index fe330d98d4b6af6addee08b441e613b7737059e6..2cd9d47cb4d4854503de8eb1715392d977df0e9e 100644 (file)
@@ -1,20 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * ZeroMQ event test
  * Copyright (C) 2017  David Lamparter, for NetDEF, 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
  */
 
 #include <zebra.h>
 #include "sigevent.h"
 #include "frr_zmq.h"
 
-DEFINE_MTYPE_STATIC(LIB, TESTBUF, "zmq test buffer")
-DEFINE_MTYPE_STATIC(LIB, ZMQMSG, "zmq message")
+DEFINE_MTYPE_STATIC(LIB, TESTBUF, "zmq test buffer");
+DEFINE_MTYPE_STATIC(LIB, ZMQMSG, "zmq message");
 
-static struct thread_master *master;
+static struct event_loop *master;
 
 static void msg_buf_free(void *data, void *hint)
 {
@@ -225,8 +212,8 @@ static void serverpartfn(void *arg, void *zmqsock, zmq_msg_t *msg,
        printf("server recv: %s\n", buf);
        fflush(stdout);
 
-       frrzmq_thread_add_write_msg(master, serverwritefn, NULL, msg_id,
-                                   zmqsock, &cb);
+       frrzmq_event_add_write_msg(master, serverwritefn, NULL, msg_id, zmqsock,
+                                  &cb);
 }
 
 static void serverfn(void *arg, void *zmqsock)
@@ -255,8 +242,8 @@ static void serverfn(void *arg, void *zmqsock)
        frrzmq_thread_cancel(&cb, &cb->read);
        frrzmq_thread_cancel(&cb, &cb->write);
 
-       frrzmq_thread_add_read_part(master, serverpartfn, NULL, NULL, zmqsock,
-                                   &cb);
+       frrzmq_event_add_read_part(master, serverpartfn, NULL, NULL, zmqsock,
+                                  &cb);
 }
 
 static void sigchld(void)
@@ -266,7 +253,7 @@ static void sigchld(void)
        frrzmq_thread_cancel(&cb, &cb->write);
 }
 
-static struct quagga_signal_t sigs[] = {
+static struct frr_signal_t sigs[] = {
        {
                .signal = SIGCHLD,
                .handler = sigchld,
@@ -277,9 +264,9 @@ static void run_server(int syncfd)
 {
        void *zmqsock;
        char dummy = 0;
-       struct thread t;
+       struct event t;
 
-       master = thread_master_create(NULL);
+       master = event_master_create(NULL);
        signal_init(master, array_size(sigs), sigs);
        frrzmq_init();
 
@@ -289,15 +276,15 @@ static void run_server(int syncfd)
                exit(1);
        }
 
-       frrzmq_thread_add_read_msg(master, serverfn, NULL, NULL, zmqsock, &cb);
+       frrzmq_event_add_read_msg(master, serverfn, NULL, NULL, zmqsock, &cb);
 
        write(syncfd, &dummy, sizeof(dummy));
-       while (thread_fetch(master, &t))
-               thread_call(&t);
+       while (event_fetch(master, &t))
+               event_call(&t);
 
        zmq_close(zmqsock);
        frrzmq_finish();
-       thread_master_free(master);
+       event_master_free(master);
        log_memstats_stderr("test");
 }