@@ -495,7 +495,7 @@ static void unix_dgram_disconnected(struct sock *sk, struct sock *other)
495
495
sk_error_report (other );
496
496
}
497
497
}
498
- sk -> sk_state = other -> sk_state = TCP_CLOSE ;
498
+ other -> sk_state = TCP_CLOSE ;
499
499
}
500
500
501
501
static void unix_sock_destructor (struct sock * sk )
@@ -1222,6 +1222,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
1222
1222
if (err )
1223
1223
goto out_unlock ;
1224
1224
1225
+ sk -> sk_state = other -> sk_state = TCP_ESTABLISHED ;
1225
1226
} else {
1226
1227
/*
1227
1228
* 1003.1g breaking connected state with AF_UNSPEC
@@ -1235,7 +1236,10 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
1235
1236
*/
1236
1237
if (unix_peer (sk )) {
1237
1238
struct sock * old_peer = unix_peer (sk );
1239
+
1238
1240
unix_peer (sk ) = other ;
1241
+ if (!other )
1242
+ sk -> sk_state = TCP_CLOSE ;
1239
1243
unix_dgram_peer_wake_disconnect_wakeup (sk , old_peer );
1240
1244
1241
1245
unix_state_double_unlock (sk , other );
@@ -1248,8 +1252,6 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
1248
1252
unix_state_double_unlock (sk , other );
1249
1253
}
1250
1254
1251
- if (unix_peer (sk ))
1252
- sk -> sk_state = other -> sk_state = TCP_ESTABLISHED ;
1253
1255
return 0 ;
1254
1256
1255
1257
out_unlock :
@@ -1831,6 +1833,7 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
1831
1833
1832
1834
unix_state_unlock (sk );
1833
1835
1836
+ sk -> sk_state = TCP_CLOSE ;
1834
1837
unix_dgram_disconnected (sk , other );
1835
1838
sock_put (other );
1836
1839
err = - ECONNREFUSED ;
0 commit comments