Skip to content

Instantly share code, notes, and snippets.

@hashbrowncipher
Created October 4, 2015 20:20
Show Gist options
  • Select an option

  • Save hashbrowncipher/a80d0b72498e09c2cbe2 to your computer and use it in GitHub Desktop.

Select an option

Save hashbrowncipher/a80d0b72498e09c2cbe2 to your computer and use it in GitHub Desktop.
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 1d0c3ad..156b420 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -807,14 +807,10 @@ int inet_shutdown(struct socket *sock, int how)
sk->sk_prot->shutdown(sk, how);
break;
- /* Remaining two branches are temporary solution for missing
+ /* Remaining branch is a temporary solution for missing
* close() in multithreaded environment. It is _not_ a good idea,
* but we have no choice until close() is repaired at VFS level.
*/
- case TCP_LISTEN:
- if (!(how & RCV_SHUTDOWN))
- break;
- /* Fall through */
case TCP_SYN_SENT:
err = sk->sk_prot->disconnect(sk, O_NONBLOCK);
sock->state = err ? SS_DISCONNECTING : SS_UNCONNECTED;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index b8b8fa1..2ffcb97 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1975,6 +1975,11 @@ static int tcp_close_state(struct sock *sk)
void tcp_shutdown(struct sock *sk, int how)
{
+ if(sk->sk_state == TCP_LISTEN) {
+ tcp_set_state(sk, TCP_CLOSE);
+ return;
+ }
+
/* We need to grab some memory, and put together a FIN,
* and then put it into the queue to be sent.
* Tim MacKenzie([email protected]) 4 Dec '92.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment