3 static LIST_HEAD(transports);
5 #define required(_rq) \
8 "Transport %s missing required field aura_transport.%s; Disabled", \
32 "Transport has buffer_overhead (%d) < buffer_offset (%d). It will crash. Disabled",
38 list_add_tail(&tr->
registry, &transports);
51 list_for_each_entry(pos, &transports,
registry)
52 if (strcmp(pos->name, name) == 0 ) {
64 void aura_transport_dump_usage()
67 slog(0, SLOG_INFO,
"--- Registered transports ---");
68 list_for_each_entry(pos, &transports,
registry)
69 slog(0, SLOG_INFO, "%s (%d instances in use)", pos->
name, pos->
usage);
81 int aura_get_pollfds(struct aura_node *node, const struct aura_pollfds **fds)
95 void aura_add_pollfds(
struct aura_node *node,
int fd, uint32_t events)
97 struct aura_pollfds *ap;
101 node->fds = calloc(8,
sizeof(*node->fds));
104 slog(4, SLOG_DEBUG,
"node: %d descriptor slots available", node->numfds);
107 if (node->nextfd >= node->numfds) {
108 int count = node->numfds * 2;
109 node->fds = realloc(node->fds, count *
sizeof(*node->fds));
110 node->numfds = count;
111 slog(4, SLOG_DEBUG,
"node: Resized. %d descriptor slots available", node->numfds);
115 slog(0, SLOG_FATAL,
"Memory allocation problem");
119 ap = &node->fds[node->nextfd++];
124 if (node->fd_changed_cb)
125 node->fd_changed_cb(ap, AURA_FD_ADDED, node->fd_changed_arg);
134 void aura_del_pollfds(
struct aura_node *node,
int fd)
137 for (i=0; i < node->nextfd; i++) {
138 struct aura_pollfds *fds = &node->fds[i];
142 if (i == node->nextfd) {
143 slog(0, SLOG_FATAL,
"Attempt to delete invalid descriptor from node");
148 if (node->fd_changed_cb)
149 node->fd_changed_cb(&node->fds[i], AURA_FD_REMOVED,
150 node->fd_changed_arg);
152 memmove(&node->fds[i], &node->fds[i+1],
153 sizeof(
struct aura_pollfds) * (node->nextfd - i - 1));
155 bzero(&node->fds[node->nextfd],
sizeof(
struct aura_pollfds));
void(* loop)(struct aura_node *node, const struct aura_pollfds *fd)
Required.
const char * name
Required.
int buffer_offset
Optional.
struct list_head registry
Private.
struct aura_buffer *(* buffer_get)(struct aura_buffer *buf)
Optional.
int buffer_overhead
Optional.
void(* close)(struct aura_node *node)
Required.
int(* open)(struct aura_node *node, const char *opts)
Required.
void(* buffer_put)(struct aura_buffer *dst, struct aura_buffer *buf)
Optional.