Fix bug #51687 (tcp_close(): is it OK to return ERR_MEM if TF_CLOSEPEND is set?)

(cherry picked from commit 1d4ca0bff6)

# Conflicts:
#	src/core/tcp.c
This commit is contained in:
goldsimon 2017-08-28 21:59:05 +02:00
parent e8a3d42e2d
commit a13c488e52

View File

@ -370,6 +370,12 @@ tcp_close_shutdown_fin(struct tcp_pcb *pcb)
} else if (err == ERR_MEM) { } else if (err == ERR_MEM) {
/* Mark this pcb for closing. Closing is retried from tcp_tmr. */ /* Mark this pcb for closing. Closing is retried from tcp_tmr. */
pcb->flags |= TF_CLOSEPEND; pcb->flags |= TF_CLOSEPEND;
/* We have to return ERR_OK from here to indicate to the callers that this
pcb should not be used any more as it will be freed soon via tcp_tmr.
This is OK here since sending FIN does not guarantee a time frime for
actually freeing the pcb, either (it is left in closure states for
remote ACK or timeout) */
return ERR_OK;
} }
return err; return err;
} }
@ -407,8 +413,8 @@ tcp_close(struct tcp_pcb *pcb)
* @ingroup tcp_raw * @ingroup tcp_raw
* Causes all or part of a full-duplex connection of this PCB to be shut down. * Causes all or part of a full-duplex connection of this PCB to be shut down.
* This doesn't deallocate the PCB unless shutting down both sides! * This doesn't deallocate the PCB unless shutting down both sides!
* Shutting down both sides is the same as calling tcp_close, so if it succeds, * Shutting down both sides is the same as calling tcp_close, so if it succeds
* the PCB should not be referenced any more. * (i.e. returns ER_OK), the PCB must not be referenced any more!
* *
* @param pcb PCB to shutdown * @param pcb PCB to shutdown
* @param shut_rx shut down receive side if this is != 0 * @param shut_rx shut down receive side if this is != 0