]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/zclient.c
Merge pull request #13060 from opensourcerouting/feature/allow_peering_with_127.0.0.1
[mirror_frr.git] / lib / zclient.c
index 2cd80cc58567dc548e592eba65b6821ff266c0d8..95093a56f5d9e9aaa022762c14ed256372441555 100644 (file)
@@ -14,7 +14,7 @@
 #include "vrf_int.h"
 #include "if.h"
 #include "log.h"
-#include "event.h"
+#include "frrevent.h"
 #include "zclient.h"
 #include "memory.h"
 #include "table.h"
@@ -51,7 +51,7 @@ socklen_t zclient_addr_len;
 static int zclient_debug;
 
 /* Allocate zclient structure. */
-struct zclient *zclient_new(struct thread_master *master,
+struct zclient *zclient_new(struct event_loop *master,
                            struct zclient_options *opt,
                            zclient_handler *const *handlers, size_t n_handlers)
 {
@@ -160,9 +160,9 @@ void zclient_stop(struct zclient *zclient)
                zlog_debug("zclient %p stopped", zclient);
 
        /* Stop threads. */
-       THREAD_OFF(zclient->t_read);
-       THREAD_OFF(zclient->t_connect);
-       THREAD_OFF(zclient->t_write);
+       EVENT_OFF(zclient->t_read);
+       EVENT_OFF(zclient->t_connect);
+       EVENT_OFF(zclient->t_write);
 
        /* Reset streams. */
        stream_reset(zclient->ibuf);
@@ -249,9 +249,9 @@ static enum zclient_send_status zclient_failed(struct zclient *zclient)
        return ZCLIENT_SEND_FAILURE;
 }
 
-static void zclient_flush_data(struct thread *thread)
+static void zclient_flush_data(struct event *thread)
 {
-       struct zclient *zclient = THREAD_ARG(thread);
+       struct zclient *zclient = EVENT_ARG(thread);
 
        zclient->t_write = NULL;
        if (zclient->sock < 0)
@@ -266,8 +266,8 @@ static void zclient_flush_data(struct thread *thread)
                return;
        case BUFFER_PENDING:
                zclient->t_write = NULL;
-               thread_add_write(zclient->master, zclient_flush_data, zclient,
-                                zclient->sock, &zclient->t_write);
+               event_add_write(zclient->master, zclient_flush_data, zclient,
+                               zclient->sock, &zclient->t_write);
                break;
        case BUFFER_EMPTY:
                if (zclient->zebra_buffer_write_ready)
@@ -295,11 +295,11 @@ enum zclient_send_status zclient_send_message(struct zclient *zclient)
                         __func__, zclient->sock);
                return zclient_failed(zclient);
        case BUFFER_EMPTY:
-               THREAD_OFF(zclient->t_write);
+               EVENT_OFF(zclient->t_write);
                return ZCLIENT_SEND_SUCCESS;
        case BUFFER_PENDING:
-               thread_add_write(zclient->master, zclient_flush_data, zclient,
-                                zclient->sock, &zclient->t_write);
+               event_add_write(zclient->master, zclient_flush_data, zclient,
+                               zclient->sock, &zclient->t_write);
                return ZCLIENT_SEND_BUFFERED;
        }
 
@@ -744,11 +744,11 @@ void zclient_init(struct zclient *zclient, int redist_default,
 
 /* This function is a wrapper function for calling zclient_start from
    timer or event thread. */
-static void zclient_connect(struct thread *t)
+static void zclient_connect(struct event *t)
 {
        struct zclient *zclient;
 
-       zclient = THREAD_ARG(t);
+       zclient = EVENT_ARG(t);
        zclient->t_connect = NULL;
 
        if (zclient_debug)
@@ -4026,7 +4026,7 @@ static zclient_handler *const lib_handlers[] = {
 };
 
 /* Zebra client message read function. */
-static void zclient_read(struct thread *thread)
+static void zclient_read(struct event *thread)
 {
        size_t already;
        uint16_t length, command;
@@ -4035,7 +4035,7 @@ static void zclient_read(struct thread *thread)
        struct zclient *zclient;
 
        /* Get socket to zebra. */
-       zclient = THREAD_ARG(thread);
+       zclient = EVENT_ARG(thread);
        zclient->t_read = NULL;
 
        /* Read zebra header (if we don't have it already). */
@@ -4204,22 +4204,22 @@ static void zclient_event(enum zclient_event event, struct zclient *zclient)
 {
        switch (event) {
        case ZCLIENT_SCHEDULE:
-               thread_add_event(zclient->master, zclient_connect, zclient, 0,
-                                &zclient->t_connect);
+               event_add_event(zclient->master, zclient_connect, zclient, 0,
+                               &zclient->t_connect);
                break;
        case ZCLIENT_CONNECT:
                if (zclient_debug)
                        zlog_debug(
                                "zclient connect failures: %d schedule interval is now %d",
                                zclient->fail, zclient->fail < 3 ? 10 : 60);
-               thread_add_timer(zclient->master, zclient_connect, zclient,
-                                zclient->fail < 3 ? 10 : 60,
-                                &zclient->t_connect);
+               event_add_timer(zclient->master, zclient_connect, zclient,
+                               zclient->fail < 3 ? 10 : 60,
+                               &zclient->t_connect);
                break;
        case ZCLIENT_READ:
                zclient->t_read = NULL;
-               thread_add_read(zclient->master, zclient_read, zclient,
-                               zclient->sock, &zclient->t_read);
+               event_add_read(zclient->master, zclient_read, zclient,
+                              zclient->sock, &zclient->t_read);
                break;
        }
 }