Lines Matching full:other

52  *		other the moment one end closes.
525 static int unix_dgram_peer_wake_connect(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_connect() argument
531 u_other = unix_sk(other); in unix_dgram_peer_wake_connect()
536 u->peer_wake.private = other; in unix_dgram_peer_wake_connect()
547 struct sock *other) in unix_dgram_peer_wake_disconnect() argument
552 u_other = unix_sk(other); in unix_dgram_peer_wake_disconnect()
555 if (u->peer_wake.private == other) { in unix_dgram_peer_wake_disconnect()
564 struct sock *other) in unix_dgram_peer_wake_disconnect_wakeup() argument
566 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_disconnect_wakeup()
574 * - unix_peer(sk) == other
577 static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_me() argument
581 connected = unix_dgram_peer_wake_connect(sk, other); in unix_dgram_peer_wake_me()
583 /* If other is SOCK_DEAD, we want to make sure we signal in unix_dgram_peer_wake_me()
586 * to other and its full, we will hang waiting for POLLOUT. in unix_dgram_peer_wake_me()
588 if (unix_recvq_full_lockless(other) && !sock_flag(other, SOCK_DEAD)) in unix_dgram_peer_wake_me()
592 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_me()
622 static void unix_dgram_disconnected(struct sock *sk, struct sock *other) in unix_dgram_disconnected() argument
634 if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) { in unix_dgram_disconnected()
635 WRITE_ONCE(other->sk_err, ECONNRESET); in unix_dgram_disconnected()
636 sk_error_report(other); in unix_dgram_disconnected()
1415 struct sock *other; in unix_dgram_connect() local
1440 other = unix_find_other(sock_net(sk), sunaddr, alen, sock->type); in unix_dgram_connect()
1441 if (IS_ERR(other)) { in unix_dgram_connect()
1442 err = PTR_ERR(other); in unix_dgram_connect()
1446 unix_state_double_lock(sk, other); in unix_dgram_connect()
1449 if (sock_flag(other, SOCK_DEAD)) { in unix_dgram_connect()
1450 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1451 sock_put(other); in unix_dgram_connect()
1456 if (!unix_may_send(sk, other)) in unix_dgram_connect()
1459 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_connect()
1464 WRITE_ONCE(other->sk_state, TCP_ESTABLISHED); in unix_dgram_connect()
1469 other = NULL; in unix_dgram_connect()
1470 unix_state_double_lock(sk, other); in unix_dgram_connect()
1479 unix_peer(sk) = other; in unix_dgram_connect()
1480 if (!other) in unix_dgram_connect()
1484 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1486 if (other != old_peer) { in unix_dgram_connect()
1497 unix_peer(sk) = other; in unix_dgram_connect()
1498 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1504 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1505 sock_put(other); in unix_dgram_connect()
1510 static long unix_wait_for_peer(struct sock *other, long timeo) in unix_wait_for_peer() argument
1511 __releases(&unix_sk(other)->lock) in unix_wait_for_peer()
1513 struct unix_sock *u = unix_sk(other); in unix_wait_for_peer()
1519 sched = !sock_flag(other, SOCK_DEAD) && in unix_wait_for_peer()
1520 !(other->sk_shutdown & RCV_SHUTDOWN) && in unix_wait_for_peer()
1521 unix_recvq_full_lockless(other); in unix_wait_for_peer()
1523 unix_state_unlock(other); in unix_wait_for_peer()
1536 struct sock *sk = sock->sk, *newsk = NULL, *other = NULL; in unix_stream_connect() local
1583 other = unix_find_other(net, sunaddr, addr_len, sk->sk_type); in unix_stream_connect()
1584 if (IS_ERR(other)) { in unix_stream_connect()
1585 err = PTR_ERR(other); in unix_stream_connect()
1589 unix_state_lock(other); in unix_stream_connect()
1592 if (sock_flag(other, SOCK_DEAD)) { in unix_stream_connect()
1593 unix_state_unlock(other); in unix_stream_connect()
1594 sock_put(other); in unix_stream_connect()
1598 if (other->sk_state != TCP_LISTEN || in unix_stream_connect()
1599 other->sk_shutdown & RCV_SHUTDOWN) { in unix_stream_connect()
1604 if (unix_recvq_full_lockless(other)) { in unix_stream_connect()
1610 timeo = unix_wait_for_peer(other, timeo); in unix_stream_connect()
1611 sock_put(other); in unix_stream_connect()
1637 err = security_unix_stream_connect(sk, other, newsk); in unix_stream_connect()
1651 newu->listener = other; in unix_stream_connect()
1653 otheru = unix_sk(other); in unix_stream_connect()
1680 copy_peercred(sk, other); in unix_stream_connect()
1692 spin_lock(&other->sk_receive_queue.lock); in unix_stream_connect()
1693 __skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_connect()
1694 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_connect()
1695 unix_state_unlock(other); in unix_stream_connect()
1696 other->sk_data_ready(other); in unix_stream_connect()
1697 sock_put(other); in unix_stream_connect()
1701 unix_state_unlock(other); in unix_stream_connect()
1702 sock_put(other); in unix_stream_connect()
1899 const struct sock *other) in unix_passcred_enabled() argument
1903 !other->sk_socket || in unix_passcred_enabled()
1904 test_bit(SOCK_PASSCRED, &other->sk_socket->flags) || in unix_passcred_enabled()
1905 test_bit(SOCK_PASSPIDFD, &other->sk_socket->flags); in unix_passcred_enabled()
1914 const struct sock *other) in maybe_add_creds() argument
1918 if (unix_passcred_enabled(sock, other)) { in maybe_add_creds()
1962 struct sock *sk = sock->sk, *other = NULL; in unix_dgram_sendmsg() local
2038 other = unix_find_other(sock_net(sk), msg->msg_name, in unix_dgram_sendmsg()
2040 if (IS_ERR(other)) { in unix_dgram_sendmsg()
2041 err = PTR_ERR(other); in unix_dgram_sendmsg()
2045 other = unix_peer_get(sk); in unix_dgram_sendmsg()
2046 if (!other) { in unix_dgram_sendmsg()
2052 if (sk_filter(other, skb) < 0) { in unix_dgram_sendmsg()
2060 unix_state_lock(other); in unix_dgram_sendmsg()
2063 if (!unix_may_send(sk, other)) { in unix_dgram_sendmsg()
2068 if (unlikely(sock_flag(other, SOCK_DEAD))) { in unix_dgram_sendmsg()
2071 unix_state_unlock(other); in unix_dgram_sendmsg()
2075 * is clearing @other. Never change state to TCP_CLOSE in unix_dgram_sendmsg()
2085 if (unix_peer(sk) == other) { in unix_dgram_sendmsg()
2087 unix_dgram_peer_wake_disconnect_wakeup(sk, other); in unix_dgram_sendmsg()
2092 unix_dgram_disconnected(sk, other); in unix_dgram_sendmsg()
2093 sock_put(other); in unix_dgram_sendmsg()
2105 sock_put(other); in unix_dgram_sendmsg()
2109 if (other->sk_shutdown & RCV_SHUTDOWN) { in unix_dgram_sendmsg()
2115 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_sendmsg()
2120 /* other == sk && unix_peer(other) != sk if in unix_dgram_sendmsg()
2124 if (other != sk && in unix_dgram_sendmsg()
2125 unlikely(unix_peer(other) != sk && in unix_dgram_sendmsg()
2126 unix_recvq_full_lockless(other))) { in unix_dgram_sendmsg()
2128 timeo = unix_wait_for_peer(other, timeo); in unix_dgram_sendmsg()
2138 unix_state_unlock(other); in unix_dgram_sendmsg()
2139 unix_state_double_lock(sk, other); in unix_dgram_sendmsg()
2142 if (unix_peer(sk) != other || in unix_dgram_sendmsg()
2143 unix_dgram_peer_wake_me(sk, other)) { in unix_dgram_sendmsg()
2158 if (sock_flag(other, SOCK_RCVTSTAMP)) in unix_dgram_sendmsg()
2160 maybe_add_creds(skb, sock, other); in unix_dgram_sendmsg()
2161 scm_stat_add(other, skb); in unix_dgram_sendmsg()
2162 skb_queue_tail(&other->sk_receive_queue, skb); in unix_dgram_sendmsg()
2163 unix_state_unlock(other); in unix_dgram_sendmsg()
2164 other->sk_data_ready(other); in unix_dgram_sendmsg()
2165 sock_put(other); in unix_dgram_sendmsg()
2172 unix_state_unlock(other); in unix_dgram_sendmsg()
2174 sock_put(other); in unix_dgram_sendmsg()
2188 static int queue_oob(struct socket *sock, struct msghdr *msg, struct sock *other, in queue_oob() argument
2191 struct unix_sock *ousk = unix_sk(other); in queue_oob()
2210 unix_state_lock(other); in queue_oob()
2212 if (sock_flag(other, SOCK_DEAD) || in queue_oob()
2213 (other->sk_shutdown & RCV_SHUTDOWN)) { in queue_oob()
2214 unix_state_unlock(other); in queue_oob()
2219 maybe_add_creds(skb, sock, other); in queue_oob()
2220 scm_stat_add(other, skb); in queue_oob()
2222 spin_lock(&other->sk_receive_queue.lock); in queue_oob()
2224 __skb_queue_tail(&other->sk_receive_queue, skb); in queue_oob()
2225 spin_unlock(&other->sk_receive_queue.lock); in queue_oob()
2227 sk_send_sigurg(other); in queue_oob()
2228 unix_state_unlock(other); in queue_oob()
2229 other->sk_data_ready(other); in queue_oob()
2243 struct sock *other = NULL; in unix_stream_sendmsg() local
2268 other = unix_peer(sk); in unix_stream_sendmsg()
2269 if (!other) { in unix_stream_sendmsg()
2329 unix_state_lock(other); in unix_stream_sendmsg()
2331 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendmsg()
2332 (other->sk_shutdown & RCV_SHUTDOWN)) in unix_stream_sendmsg()
2335 maybe_add_creds(skb, sock, other); in unix_stream_sendmsg()
2336 scm_stat_add(other, skb); in unix_stream_sendmsg()
2337 skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_sendmsg()
2338 unix_state_unlock(other); in unix_stream_sendmsg()
2339 other->sk_data_ready(other); in unix_stream_sendmsg()
2345 err = queue_oob(sock, msg, other, &scm, fds_sent); in unix_stream_sendmsg()
2357 unix_state_unlock(other); in unix_stream_sendmsg()
3029 struct sock *other; in unix_shutdown() local
3042 other = unix_peer(sk); in unix_shutdown()
3043 if (other) in unix_shutdown()
3044 sock_hold(other); in unix_shutdown()
3048 if (other && in unix_shutdown()
3052 const struct proto *prot = READ_ONCE(other->sk_prot); in unix_shutdown()
3055 prot->unhash(other); in unix_shutdown()
3060 unix_state_lock(other); in unix_shutdown()
3061 WRITE_ONCE(other->sk_shutdown, other->sk_shutdown | peer_mode); in unix_shutdown()
3062 unix_state_unlock(other); in unix_shutdown()
3063 other->sk_state_change(other); in unix_shutdown()
3065 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_HUP); in unix_shutdown()
3067 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_IN); in unix_shutdown()
3069 if (other) in unix_shutdown()
3070 sock_put(other); in unix_shutdown()
3240 * we set writable also when the other side has shut down the in unix_poll()
3252 struct sock *sk = sock->sk, *other; in unix_dgram_poll() local
3292 other = unix_peer(sk); in unix_dgram_poll()
3293 if (other && unix_peer(other) != sk && in unix_dgram_poll()
3294 unix_recvq_full_lockless(other) && in unix_dgram_poll()
3295 unix_dgram_peer_wake_me(sk, other)) in unix_dgram_poll()