![]() |
kinetic-c
v0.12.0
Seagate Kinetic Protocol Client Library for C
|
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/time.h>
#include <assert.h>
#include <err.h>
#include <time.h>
#include "bus_internal_types.h"
#include "listener.h"
#include "listener_helper.h"
#include "listener_cmd.h"
#include "listener_task.h"
#include "listener_internal.h"
#include "syscall.h"
#include "util.h"
Go to the source code of this file.
Functions | |
struct listener * | Listener_Init (struct bus *b, struct bus_config *cfg) |
Initialize the listener. More... | |
bool | Listener_AddSocket (struct listener *l, connection_info *ci, int *notify_fd) |
Add/remove sockets' metadata from internal info. More... | |
bool | Listener_RemoveSocket (struct listener *l, int fd, int *notify_fd) |
bool | Listener_HoldResponse (struct listener *l, int fd, int64_t seq_id, int16_t timeout_sec, int *notify_fd) |
The client is about to start a write, the listener should hold on to the response (with timeout) if it arrives before receiving further instructions from the client. More... | |
bool | Listener_ExpectResponse (struct listener *l, boxed_msg *box, uint16_t *backpressure) |
The client has finished a write, the listener should expect a response. More... | |
bool | Listener_Shutdown (struct listener *l, int *notify_fd) |
Shut down the listener. More... | |
void | Listener_Free (struct listener *l) |
Free the listener, which must already be shut down. More... | |
struct listener* Listener_Init | ( | struct bus * | b, |
struct bus_config * | cfg | ||
) |
Initialize the listener.
Definition at line 39 of file listener.c.
References listener::bus, BUS_LOG, listener::commit_pipe, listener::fds, listener_msg::id, rx_info_t::id, listener::incoming_msg_pipe, INCOMING_MSG_PIPE_ID, LISTENER_NO_FD, LOG_LISTENER, MAX_PENDING_MESSAGES, MAX_QUEUE_MESSAGES, listener::msg_freelist, listener::msgs, listener_msg::next, rx_info_t::next, listener_msg::pipes, RIS_INACTIVE, listener::rx_info, listener::rx_info_freelist, listener::rx_info_max_used, listener::shutdown_notify_fd, rx_info_t::state, syscall_close(), and bus::udata.
bool Listener_AddSocket | ( | struct listener * | l, |
connection_info * | ci, | ||
int * | notify_fd | ||
) |
Add/remove sockets' metadata from internal info.
Blocking.
Definition at line 94 of file listener.c.
References listener_msg::add_socket, ListenerHelper_GetFreeMsg(), ListenerHelper_PushMessage(), MSG_ADD_SOCKET, listener_msg::pipes, listener_msg::type, and listener_msg::u.
bool Listener_RemoveSocket | ( | struct listener * | l, |
int | fd, | ||
int * | notify_fd | ||
) |
Definition at line 105 of file listener.c.
References ListenerHelper_GetFreeMsg(), ListenerHelper_PushMessage(), MSG_REMOVE_SOCKET, listener_msg::pipes, listener_msg::remove_socket, listener_msg::type, and listener_msg::u.
bool Listener_HoldResponse | ( | struct listener * | l, |
int | fd, | ||
int64_t | seq_id, | ||
int16_t | timeout_sec, | ||
int * | notify_fd | ||
) |
The client is about to start a write, the listener should hold on to the response (with timeout) if it arrives before receiving further instructions from the client.
Definition at line 115 of file listener.c.
References listener::bus, BUS_LOG, BUS_LOG_SNPRINTF, listener_msg::hold, ListenerHelper_GetFreeMsg(), ListenerHelper_PushMessage(), LOG_LISTENER, LOG_MEMORY, MSG_HOLD_RESPONSE, listener_msg::pipes, listener_msg::type, listener_msg::u, and bus::udata.
The client has finished a write, the listener should expect a response.
Definition at line 143 of file listener.c.
References listener::bus, BUS_ASSERT, BUS_LOG_SNPRINTF, BUS_SEND_UNDEFINED, listener_msg::expect, ListenerHelper_GetFreeMsg(), ListenerHelper_PushMessage(), ListenerTask_GetBackpressure(), LOG_MEMORY, MSG_EXPECT_RESPONSE, boxed_msg::out_seq_id, boxed_msg::result, bus_msg_result_t::status, listener_msg::type, listener_msg::u, and bus::udata.
bool Listener_Shutdown | ( | struct listener * | l, |
int * | notify_fd | ||
) |
Shut down the listener.
Blocking.
Definition at line 170 of file listener.c.
References ListenerHelper_GetFreeMsg(), ListenerHelper_PushMessage(), MSG_SHUTDOWN, listener_msg::pipes, listener_msg::shutdown, listener_msg::type, and listener_msg::u.
void Listener_Free | ( | struct listener * | l | ) |
Free the listener, which must already be shut down.
Definition at line 179 of file listener.c.
References listener_msg::add_socket, listener::bus, BUS_ASSERT, BUS_LOG_SNPRINTF, listener::commit_pipe, listener_msg::expect, rx_info_t::expect, listener::incoming_msg_pipe, LISTENER_SHUTDOWN_COMPLETE_FD, ListenerCmd_NotifyCaller(), LOG_LISTENER, MAX_PENDING_MESSAGES, MAX_QUEUE_MESSAGES, MSG_ADD_SOCKET, MSG_EXPECT_RESPONSE, MSG_REMOVE_SOCKET, listener::msgs, listener_msg::pipes, listener::read_buf, listener_msg::remove_socket, RIS_EXPECT, RIS_HOLD, RIS_INACTIVE, listener::rx_info, listener::shutdown_notify_fd, rx_info_t::state, syscall_close(), listener_msg::type, listener_msg::u, rx_info_t::u, and bus::udata.