+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Zebra API server.
* Portions:
* Copyright (C) 1997-1999 Kunihiro Ishiguro
* Copyright (C) 2015-2018 Cumulus Networks, Inc.
* et al.
- *
- * 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 "lib/sockopt.h" /* for setsockopt_so_recvbuf, setsockopt... */
#include "lib/sockunion.h" /* for sockopt_reuseaddr, sockopt_reuseport */
#include "lib/stream.h" /* for STREAM_SIZE, stream (ptr only), ... */
-#include "lib/thread.h" /* for thread (ptr only), THREAD_ARG, ... */
+#include "event.h" /* for thread (ptr only), THREAD_ARG, ... */
#include "lib/vrf.h" /* for vrf_info_lookup, VRF_DEFAULT */
#include "lib/vty.h" /* for vty_out, vty (ptr only) */
#include "lib/zclient.h" /* for zmsghdr, ZEBRA_HEADER_SIZE, ZEBRA... */
/*
* Zebra server event driver for all client threads.
*
- * This is essentially a wrapper around thread_add_event() that centralizes
+ * This is essentially a wrapper around event_add_event() that centralizes
* those scheduling calls into one place.
*
* All calls to this function schedule an event on the pthread running the
/*
* Zebra server event driver for the main thread.
*
- * This is essentially a wrapper around thread_add_event() that centralizes
+ * This is essentially a wrapper around event_add_event() that centralizes
* those scheduling calls into one place.
*
* All calls to this function schedule an event on Zebra's main pthread.
* allows us to expose information about input and output queues to the user in
* terms of number of packets rather than size of data.
*/
-static void zserv_write(struct thread *thread)
+static void zserv_write(struct event *thread)
{
struct zserv *client = THREAD_ARG(thread);
struct stream *msg;
*
* Any failure in any of these actions is handled by terminating the client.
*/
-static void zserv_read(struct thread *thread)
+static void zserv_read(struct event *thread)
{
struct zserv *client = THREAD_ARG(thread);
int sock;
{
switch (event) {
case ZSERV_CLIENT_READ:
- thread_add_read(client->pthread->master, zserv_read, client,
- client->sock, &client->t_read);
+ event_add_read(client->pthread->master, zserv_read, client,
+ client->sock, &client->t_read);
break;
case ZSERV_CLIENT_WRITE:
- thread_add_write(client->pthread->master, zserv_write, client,
- client->sock, &client->t_write);
+ event_add_write(client->pthread->master, zserv_write, client,
+ client->sock, &client->t_write);
break;
}
}
* rely on the read thread to handle queuing this task enough times to process
* everything on the input queue.
*/
-static void zserv_process_messages(struct thread *thread)
+static void zserv_process_messages(struct event *thread)
{
struct zserv *client = THREAD_ARG(thread);
struct stream *msg;
* - Free associated resources
* - Free client structure
*
- * This does *not* take any action on the struct thread * fields. These are
+ * This does *not* take any action on the struct event * fields. These are
* managed by the owning pthread and any tasks associated with them must have
* been stopped prior to invoking this function.
*/
zlog_debug("Closing client '%s'",
zebra_route_string(client->proto));
- thread_cancel_event(zrouter.master, client);
+ event_cancel_event(zrouter.master, client);
THREAD_OFF(client->t_cleanup);
THREAD_OFF(client->t_process);
* already have been closed and the thread will most likely have died, but its
* resources still need to be cleaned up.
*/
-static void zserv_handle_client_fail(struct thread *thread)
+static void zserv_handle_client_fail(struct event *thread)
{
struct zserv *client = THREAD_ARG(thread);
* main pthread.
*/
if (client->is_closed)
- thread_add_event(zrouter.master,
- zserv_handle_client_fail,
- client, 0, &client->t_cleanup);
+ event_add_event(zrouter.master,
+ zserv_handle_client_fail,
+ client, 0, &client->t_cleanup);
}
}
/*
* Accept socket connection.
*/
-static void zserv_accept(struct thread *thread)
+static void zserv_accept(struct event *thread)
{
int accept_sock;
int client_sock;
{
switch (event) {
case ZSERV_ACCEPT:
- thread_add_read(zrouter.master, zserv_accept, NULL, zsock,
- NULL);
+ event_add_read(zrouter.master, zserv_accept, NULL, zsock, NULL);
break;
case ZSERV_PROCESS_MESSAGES:
- thread_add_event(zrouter.master, zserv_process_messages, client,
- 0, &client->t_process);
+ event_add_event(zrouter.master, zserv_process_messages, client,
+ 0, &client->t_process);
break;
case ZSERV_HANDLE_CLIENT_FAIL:
- thread_add_event(zrouter.master, zserv_handle_client_fail,
- client, 0, &client->t_cleanup);
+ event_add_event(zrouter.master, zserv_handle_client_fail,
+ client, 0, &client->t_cleanup);
}
}