Skip to content

Commit

Permalink
Fix an issue with UDP port writes fail
Browse files Browse the repository at this point in the history
If a UDP write fails, the read enable on the port wasn't being enabled.
The check to say that there was still data to write to the port was
returning that there was still data, but there obviously wasn't because
the UDP port failed.

The re-enable after the timeout also wasn't properly setting the state,
and there was a place that was clearing the write position when it
shouldn't have.

Also remove some debugging cruft that got left in earlier.

Signed-off-by: Corey Minyard <[email protected]>
  • Loading branch information
cminyard committed Jan 9, 2025
1 parent 90e35f7 commit 80f8208
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion dataxfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ port_check_connect_backs(port_info_t *port)
/*
* Some data came in while we were shutting down the port.
* Just ignore it for now, when the port is opened back up we
* wills tart the connections.
* will start the connections.
*/
return 1;
}
Expand Down Expand Up @@ -621,6 +621,12 @@ net_fd_write(port_info_t *port, net_info_t *netcon,
/* Can't use buffer send operation here, multiple writers can send
from the buffers. */
reterr = gensio_write(netcon->net, &count, buf->buf + *pos, to_send, NULL);
if (reterr)
/*
* Mark that we have written all the data so the check for more data
* to send will not count this one.
*/
*pos = port->dev_to_net.cursize;
if (reterr == GE_REMCLOSE) {
shutdown_one_netcon(netcon, "Remote closed");
return -1;
Expand Down
5 changes: 3 additions & 2 deletions port.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ shutdown_one_netcon(net_info_t *netcon, const char *reason)
if (netcon->closing)
return;

netcon->write_pos = 0;
footer_trace(netcon->port, "netcon", reason);

netcon->close_on_output_done = false;
Expand Down Expand Up @@ -835,8 +834,10 @@ port_timeout(struct gensio_timer *timer, void *data)

if (port->nocon_read_enable_time_left) {
port->nocon_read_enable_time_left--;
if (port->nocon_read_enable_time_left == 0)
if (port->nocon_read_enable_time_left == 0) {
gensio_set_read_callback_enable(port->io, true);
port->dev_to_net_state = PORT_WAITING_INPUT;
}
goto out;
}

Expand Down

0 comments on commit 80f8208

Please sign in to comment.