From 36fa1a97d415410c9d8f1ed350702775829d370b Mon Sep 17 00:00:00 2001 From: Joel Cunningham Date: Fri, 24 Feb 2017 15:24:22 -0600 Subject: [PATCH] lwip_netconn_do_writemore() cleanups This commit makes a couple of cleanups discussed in patch #8882: 1) msg.w.offset should not be set to 0 in the error case. It is only valid when err == ERR_OK 2) Remove out-of-date comment which indicated the entire write had completed (not true for non-blocking write) This also updates the documentation on offset to include that offset is only valid when err == ERR_OK --- src/api/api_msg.c | 5 ----- src/include/lwip/priv/api_msg.h | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/api/api_msg.c b/src/api/api_msg.c index fcdade1c..853ca4ba 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -1564,7 +1564,6 @@ err_mem: conn->current_msg->msg.w.offset += len; if ((conn->current_msg->msg.w.offset == conn->current_msg->msg.w.len) || dontblock) { /* return sent length (caller reads length from msg.w.offset) */ - /* everything was written */ write_finished = 1; } out_err = tcp_output(conn->pcb.tcp); @@ -1574,7 +1573,6 @@ err_mem: to the application thread. */ err = out_err; write_finished = 1; - conn->current_msg->msg.w.offset = 0; } } else if (err == ERR_MEM) { /* If ERR_MEM, we wait for sent_tcp or poll_tcp to be called. @@ -1590,18 +1588,15 @@ err_mem: to the application thread. */ err = out_err; write_finished = 1; - conn->current_msg->msg.w.offset = 0; } else if (dontblock) { /* non-blocking write is done on ERR_MEM */ err = ERR_WOULDBLOCK; write_finished = 1; - conn->current_msg->msg.w.offset = 0; } } else { /* On errors != ERR_MEM, we don't try writing any more but return the error to the application thread. */ write_finished = 1; - conn->current_msg->msg.w.offset = 0; } } if (write_finished) { diff --git a/src/include/lwip/priv/api_msg.h b/src/include/lwip/priv/api_msg.h index 65b6aec5..f397a394 100644 --- a/src/include/lwip/priv/api_msg.h +++ b/src/include/lwip/priv/api_msg.h @@ -106,7 +106,7 @@ struct api_msg { const void *dataptr; /** total length of dataptr */ size_t len; - /** offset into dataptr/output of bytes written */ + /** offset into dataptr/output of bytes written when err == ERR_OK */ size_t offset; u8_t apiflags; #if LWIP_SO_SNDTIMEO