// updates #fr_bio_fd_packet_ctx_t on successful FD read.
} fr_bio_fd_type_t;
-/** Run-time status of the socket.
- *
- */
-typedef struct {
- fr_socket_t socket; //!< as connected socket
-
- fr_bio_fd_type_t type; //!< type of the socket
-
- fr_bio_fd_state_t state; //!< connecting, open, closed, etc.
-
- bool read_blocked; //!< did we block on read?
- bool write_blocked; //!< did we block on write?
- bool eof; //!< are we at EOF?
-
-} fr_bio_fd_info_t;
-
/** Configuration for sockets
*
* Each piece of information is broken out into a separate field, so that the configuration file parser can
bool async; //!< is it async
} fr_bio_fd_config_t;
+/** Run-time status of the socket.
+ *
+ */
+typedef struct {
+ fr_socket_t socket; //!< as connected socket
+
+ fr_bio_fd_type_t type; //!< type of the socket
+
+ fr_bio_fd_state_t state; //!< connecting, open, closed, etc.
+
+ bool read_blocked; //!< did we block on read?
+ bool write_blocked; //!< did we block on write?
+ bool eof; //!< are we at EOF?
+
+ fr_bio_fd_config_t const *cfg; //!< so we know what was asked, vs what was granted.
+} fr_bio_fd_info_t;
+
fr_bio_t *fr_bio_fd_alloc(TALLOC_CTX *ctx, fr_bio_cb_funcs_t *cb, fr_socket_t const *sock, fr_bio_fd_type_t type, size_t offset) CC_HINT(nonnull(1));
int fr_bio_fd_close(fr_bio_t *bio) CC_HINT(nonnull);
fr_strerror_clear();
- my->info.socket = (fr_socket_t) {};
-
- my->info.socket.type = cfg->socket_type;
+ my->info = (fr_bio_fd_info_t) {
+ .socket = {
+ .type = cfg->socket_type,
+ },
+ .cfg = cfg,
+ };
if (!cfg->path) {
my->info.socket.af = cfg->src_ipaddr.af;
my->info.socket.type = SOCK_STREAM;
my->info.socket.unix.path = cfg->path;
protocol = 0;
- break;
}
/*
fr_strerror_printf("Failed opening setting O_NONBLOCK: %s", fr_syserror(errno));
fail:
- my->info.socket.fd = -1;
+ my->info.socket = (fr_socket_t) {
+ .fd = -1,
+ };
my->info.state = FR_BIO_FD_STATE_CLOSED;
+ my->info.cfg = NULL;
close(fd);
return -1;
}
if (fr_bio_fd_init_accept(my) < 0) goto fail;
break;
}
+
return 0;
}