mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-24 15:14:06 +00:00
When SO_LINGER is enabled w/ linger time = 0, do hard disconnect regardless of whether there's any pending or unacked data
References: - Wright & Stevens, "TCP/IP Illustrated, Volume 2" - 30.4. tcp_disconnect Function - Figure 30.12. tcp_disconnect function: initiate TCP disconnect. - "Hard disconnect" section - UNIX Network Programming / Volume 1, Third Edition: The Sockets Networking API (aka "UNP") - 7.5 Generic Socket Options - "SO_LINGER Socket Option" section
This commit is contained in:
parent
73fcf72792
commit
a4eeaac87c
@ -981,14 +981,14 @@ lwip_netconn_do_close_internal(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
#if LWIP_SO_LINGER
|
||||
/* check linger possibilities before calling tcp_close */
|
||||
err = ERR_OK;
|
||||
/* linger enabled/required at all? (i.e. is there untransmitted data left?) */
|
||||
if ((conn->linger >= 0) && (conn->pcb.tcp->unsent || conn->pcb.tcp->unacked)) {
|
||||
/* linger enabled? */
|
||||
if (conn->linger >= 0) {
|
||||
if ((conn->linger == 0)) {
|
||||
/* data left but linger prevents waiting */
|
||||
/* 0-timeout linger prevents waiting */
|
||||
tcp_abort(tpcb);
|
||||
tpcb = NULL;
|
||||
} else if (conn->linger > 0) {
|
||||
/* data left and linger says we should wait */
|
||||
} else if (conn->pcb.tcp->unsent || conn->pcb.tcp->unacked) {
|
||||
/* data left and nonzero linger says we should wait */
|
||||
if (netconn_is_nonblocking(conn)) {
|
||||
/* data left on a nonblocking netconn -> cannot linger */
|
||||
err = ERR_WOULDBLOCK;
|
||||
|
Loading…
Reference in New Issue
Block a user