40 struct listener *l = calloc(1,
sizeof(*l));
41 if (l == NULL) {
return NULL; }
48 if (0 != pipe(pipes)) {
63 uint16_t *p_id = (uint16_t *)&info->
id;
71 uint8_t *p_id = (uint8_t *)&msg->
id;
74 if (0 != pipe(msg->
pipes)) {
75 for (
int i = 0; i < pipe_count; i++) {
97 if (msg == NULL) {
return false; }
107 if (msg == NULL) {
return false; }
116 int64_t seq_id, int16_t timeout_sec,
int *notify_fd) {
125 "Listener_HoldResponse with <fd:%d, seq_id:%lld>",
126 fd, (
long long)seq_id);
130 msg->
u.
hold.seq_id = seq_id;
131 msg->
u.
hold.timeout_sec = timeout_sec;
137 "Listener_HoldResponse with <fd:%d, seq_id:%lld> FAILED",
138 fd, (
long long)seq_id);
144 uint16_t *backpressure) {
149 "! ListenerHelper_GetFreeMsg fail %p", (
void*)box);
154 "Listener_ExpectResponse with box of %p, seq_id:%lld",
165 "! ListenerHelper_PushMessage fail %p", (
void*)box);
172 if (msg == NULL) {
return false; }
187 switch (info->
state) {
203 "match fail %d on line %d", info->
state, __LINE__);
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 i...
#define MAX_QUEUE_MESSAGES
Max number of unprocessed queue messages.
Record in table for partially processed messages.
listener_msg * msg_freelist
struct pollfd fds[1000+1]
Tracked file descriptors, for polling.
struct listener_msg::@6::@7 add_socket
A queue message, with a command in the tagged union.
bool Listener_RemoveSocket(struct listener *l, int fd, int *notify_fd)
bus_msg_result_t result
Result message, constructed in place after the request/response cycle has completed or failed due to ...
int syscall_close(int fd)
struct listener * Listener_Init(struct bus *b, struct bus_config *cfg)
Initialize the listener.
#define INCOMING_MSG_PIPE_ID
ID of the struct pollfd for the listener's incoming command pipe.
uint16_t ListenerTask_GetBackpressure(struct listener *l)
Get the current backpressure from the listener.
bool ListenerHelper_PushMessage(struct listener *l, listener_msg *msg, int *reply_fd)
Push a message into the listener's message queue.
struct listener_msg::@6::@10 expect
bool Listener_AddSocket(struct listener *l, connection_info *ci, int *notify_fd)
Add/remove sockets' metadata from internal info.
void * udata
User data for callbacks.
struct listener_msg * next
struct listener_msg::@6::@9 hold
rx_info_t * rx_info_freelist
#define LISTENER_SHUTDOWN_COMPLETE_FD
void ListenerCmd_NotifyCaller(listener *l, int fd)
Notify the listener's caller that a command has completed.
rx_info_t rx_info[(1024)]
Per-socket connection context.
uint16_t rx_info_max_used
#define BUS_LOG_SNPRINTF(B, LEVEL, EVENT_KEY, UDATA, MAX_SZ, FMT,...)
bool Listener_Shutdown(struct listener *l, int *notify_fd)
Shut down the listener.
struct rx_info_t::@12::@14 expect
void Listener_Free(struct listener *l)
Free the listener, which must already be shut down.
bool Listener_ExpectResponse(struct listener *l, boxed_msg *box, uint16_t *backpressure)
The client has finished a write, the listener should expect a response.
#define BUS_ASSERT(B, UDATA, COND)
struct listener_msg::@6::@11 shutdown
#define LISTENER_NO_FD
Sentinel values used for listener.shutdown_notify_fd.
struct listener_msg::@6::@8 remove_socket
listener_msg * ListenerHelper_GetFreeMsg(listener *l)
Get a free message from the listener's message pool.
#define MAX_PENDING_MESSAGES
#define BUS_LOG(B, LEVEL, EVENT_KEY, MSG, UDATA)