Rename patty_ax25_sock.rx_buf to io_buf

Rename patty_ax25_sock.rx_buf to io_buf, as the buffer is not used for
receiving frames from an interface, but rather from reading local data
to write to a remote peer

Other changes:

    * Fix issue wherein patty_ax25_sock.n_maxlen_tx was not used for
      reading local data when sending I frames
This commit is contained in:
XANTRONIX Development 2020-08-23 21:01:07 -05:00 committed by XANTRONIX Industrial
parent 5a61a3057a
commit 2e360976bf
3 changed files with 15 additions and 15 deletions

View file

@ -135,7 +135,7 @@ typedef struct _patty_ax25_sock {
* Transmit and receive buffers
*/
void *tx_buf,
*rx_buf;
*io_buf;
void *tx_slots;

View file

@ -2042,7 +2042,7 @@ static int handle_sock_dgram(patty_ax25_server *server,
return 0;
}
if ((len = read(sock->fd, sock->rx_buf, sock->n_maxlen_rx)) < 0) {
if ((len = read(sock->fd, sock->io_buf, sock->n_maxlen_tx)) < 0) {
if (errno == EIO) {
(void)sock_close(server, sock);
} else {
@ -2051,7 +2051,7 @@ static int handle_sock_dgram(patty_ax25_server *server,
} else if (len == 0) {
(void)sock_close(server, sock);
} else if (len > 0) {
if (patty_ax25_sock_write(sock, sock->rx_buf, len) < 0) {
if (patty_ax25_sock_write(sock, sock->io_buf, len) < 0) {
goto error_sock_write;
}
}
@ -2227,7 +2227,7 @@ static int handle_sock(uint32_t key,
return 0;
}
if ((len = read(sock->fd, sock->rx_buf, sock->n_maxlen_rx)) < 0) {
if ((len = read(sock->fd, sock->io_buf, sock->n_maxlen_tx)) < 0) {
if (errno == EIO) {
(void)sock_shutdown(server, sock);
} else {
@ -2236,7 +2236,7 @@ static int handle_sock(uint32_t key,
} else if (len == 0) {
(void)sock_shutdown(server, sock);
} else if (len > 0) {
if (patty_ax25_sock_write(sock, sock->rx_buf, len) < 0) {
if (patty_ax25_sock_write(sock, sock->io_buf, len) < 0) {
goto error_sock_write;
}

View file

@ -52,8 +52,8 @@ static inline size_t tx_bufsz(patty_ax25_sock *sock) {
return PATTY_AX25_FRAME_OVERHEAD + sock->n_maxlen_tx;
}
static inline size_t rx_bufsz(patty_ax25_sock *sock) {
return PATTY_AX25_FRAME_OVERHEAD + sock->n_maxlen_rx;
static inline size_t io_bufsz(patty_ax25_sock *sock) {
return PATTY_AX25_FRAME_OVERHEAD + sock->n_maxlen_tx;
}
static inline size_t tx_slots(patty_ax25_sock *sock) {
@ -96,8 +96,8 @@ static int init_bufs(patty_ax25_sock *sock) {
goto error_realloc_tx_buf;
}
if ((sock->rx_buf = realloc(sock->rx_buf, rx_bufsz(sock))) == NULL) {
goto error_realloc_rx_buf;
if ((sock->io_buf = realloc(sock->io_buf, io_bufsz(sock))) == NULL) {
goto error_realloc_io_buf;
}
if ((sock->tx_slots = realloc(sock->tx_slots, tx_slots_size(sock))) == NULL) {
@ -114,10 +114,10 @@ static int init_bufs(patty_ax25_sock *sock) {
return 0;
error_realloc_tx_slots:
free(sock->rx_buf);
sock->rx_buf = NULL;
free(sock->io_buf);
sock->io_buf = NULL;
error_realloc_rx_buf:
error_realloc_io_buf:
free(sock->tx_buf);
sock->tx_buf = NULL;
@ -189,7 +189,7 @@ patty_ax25_sock *patty_ax25_sock_new(enum patty_ax25_proto proto,
error_init_bufs:
if (sock->tx_slots) free(sock->tx_slots);
if (sock->rx_buf) free(sock->rx_buf);
if (sock->io_buf) free(sock->io_buf);
if (sock->tx_buf) free(sock->tx_buf);
error_bind_pty:
@ -220,8 +220,8 @@ void patty_ax25_sock_destroy(patty_ax25_sock *sock) {
free(sock->tx_slots);
}
if (sock->rx_buf) {
free(sock->rx_buf);
if (sock->io_buf) {
free(sock->io_buf);
}
if (sock->tx_buf) {