Lines Matching full:other
52 * other the moment one end closes.
463 static int unix_dgram_peer_wake_connect(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_connect() argument
469 u_other = unix_sk(other); in unix_dgram_peer_wake_connect()
474 u->peer_wake.private = other; in unix_dgram_peer_wake_connect()
485 struct sock *other) in unix_dgram_peer_wake_disconnect() argument
490 u_other = unix_sk(other); in unix_dgram_peer_wake_disconnect()
493 if (u->peer_wake.private == other) { in unix_dgram_peer_wake_disconnect()
502 struct sock *other) in unix_dgram_peer_wake_disconnect_wakeup() argument
504 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_disconnect_wakeup()
512 * - unix_peer(sk) == other
515 static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) in unix_dgram_peer_wake_me() argument
519 connected = unix_dgram_peer_wake_connect(sk, other); in unix_dgram_peer_wake_me()
521 /* If other is SOCK_DEAD, we want to make sure we signal in unix_dgram_peer_wake_me()
524 * to other and its full, we will hang waiting for POLLOUT. in unix_dgram_peer_wake_me()
526 if (unix_recvq_full_lockless(other) && !sock_flag(other, SOCK_DEAD)) in unix_dgram_peer_wake_me()
530 unix_dgram_peer_wake_disconnect(sk, other); in unix_dgram_peer_wake_me()
560 static void unix_dgram_disconnected(struct sock *sk, struct sock *other) in unix_dgram_disconnected() argument
570 if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) { in unix_dgram_disconnected()
571 WRITE_ONCE(other->sk_err, ECONNRESET); in unix_dgram_disconnected()
572 sk_error_report(other); in unix_dgram_disconnected()
575 other->sk_state = TCP_CLOSE; in unix_dgram_disconnected()
1356 struct sock *other; in unix_dgram_connect() local
1381 other = unix_find_other(sock_net(sk), sunaddr, alen, sock->type); in unix_dgram_connect()
1382 if (IS_ERR(other)) { in unix_dgram_connect()
1383 err = PTR_ERR(other); in unix_dgram_connect()
1387 unix_state_double_lock(sk, other); in unix_dgram_connect()
1390 if (sock_flag(other, SOCK_DEAD)) { in unix_dgram_connect()
1391 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1392 sock_put(other); in unix_dgram_connect()
1397 if (!unix_may_send(sk, other)) in unix_dgram_connect()
1400 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_connect()
1404 sk->sk_state = other->sk_state = TCP_ESTABLISHED; in unix_dgram_connect()
1409 other = NULL; in unix_dgram_connect()
1410 unix_state_double_lock(sk, other); in unix_dgram_connect()
1419 unix_peer(sk) = other; in unix_dgram_connect()
1420 if (!other) in unix_dgram_connect()
1424 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1426 if (other != old_peer) in unix_dgram_connect()
1430 unix_peer(sk) = other; in unix_dgram_connect()
1431 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1437 unix_state_double_unlock(sk, other); in unix_dgram_connect()
1438 sock_put(other); in unix_dgram_connect()
1443 static long unix_wait_for_peer(struct sock *other, long timeo) in unix_wait_for_peer() argument
1444 __releases(&unix_sk(other)->lock) in unix_wait_for_peer()
1446 struct unix_sock *u = unix_sk(other); in unix_wait_for_peer()
1452 sched = !sock_flag(other, SOCK_DEAD) && in unix_wait_for_peer()
1453 !(other->sk_shutdown & RCV_SHUTDOWN) && in unix_wait_for_peer()
1454 unix_recvq_full_lockless(other); in unix_wait_for_peer()
1456 unix_state_unlock(other); in unix_wait_for_peer()
1469 struct sock *sk = sock->sk, *newsk = NULL, *other = NULL; in unix_stream_connect() local
1516 other = unix_find_other(net, sunaddr, addr_len, sk->sk_type); in unix_stream_connect()
1517 if (IS_ERR(other)) { in unix_stream_connect()
1518 err = PTR_ERR(other); in unix_stream_connect()
1519 other = NULL; in unix_stream_connect()
1524 unix_state_lock(other); in unix_stream_connect()
1527 if (sock_flag(other, SOCK_DEAD)) { in unix_stream_connect()
1528 unix_state_unlock(other); in unix_stream_connect()
1529 sock_put(other); in unix_stream_connect()
1534 if (other->sk_state != TCP_LISTEN) in unix_stream_connect()
1536 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_stream_connect()
1539 if (unix_recvq_full(other)) { in unix_stream_connect()
1544 timeo = unix_wait_for_peer(other, timeo); in unix_stream_connect()
1549 sock_put(other); in unix_stream_connect()
1559 state. other is TCP_LISTEN, if sk is TCP_LISTEN we in unix_stream_connect()
1583 unix_state_unlock(other); in unix_stream_connect()
1584 sock_put(other); in unix_stream_connect()
1588 err = security_unix_stream_connect(sk, other, newsk); in unix_stream_connect()
1603 otheru = unix_sk(other); in unix_stream_connect()
1630 copy_peercred(sk, other); in unix_stream_connect()
1642 spin_lock(&other->sk_receive_queue.lock); in unix_stream_connect()
1643 __skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_connect()
1644 spin_unlock(&other->sk_receive_queue.lock); in unix_stream_connect()
1645 unix_state_unlock(other); in unix_stream_connect()
1646 other->sk_data_ready(other); in unix_stream_connect()
1647 sock_put(other); in unix_stream_connect()
1651 if (other) in unix_stream_connect()
1652 unix_state_unlock(other); in unix_stream_connect()
1658 if (other) in unix_stream_connect()
1659 sock_put(other); in unix_stream_connect()
1842 const struct sock *other) in unix_passcred_enabled() argument
1846 !other->sk_socket || in unix_passcred_enabled()
1847 test_bit(SOCK_PASSCRED, &other->sk_socket->flags) || in unix_passcred_enabled()
1848 test_bit(SOCK_PASSPIDFD, &other->sk_socket->flags); in unix_passcred_enabled()
1857 const struct sock *other) in maybe_add_creds() argument
1861 if (unix_passcred_enabled(sock, other)) { in maybe_add_creds()
1902 struct sock *sk = sock->sk, *other = NULL; in unix_dgram_sendmsg() local
1934 other = unix_peer_get(sk); in unix_dgram_sendmsg()
1935 if (!other) in unix_dgram_sendmsg()
1979 if (!other) { in unix_dgram_sendmsg()
1984 other = unix_find_other(sock_net(sk), sunaddr, msg->msg_namelen, in unix_dgram_sendmsg()
1986 if (IS_ERR(other)) { in unix_dgram_sendmsg()
1987 err = PTR_ERR(other); in unix_dgram_sendmsg()
1988 other = NULL; in unix_dgram_sendmsg()
1993 if (sk_filter(other, skb) < 0) { in unix_dgram_sendmsg()
2000 unix_state_lock(other); in unix_dgram_sendmsg()
2003 if (!unix_may_send(sk, other)) in unix_dgram_sendmsg()
2006 if (unlikely(sock_flag(other, SOCK_DEAD))) { in unix_dgram_sendmsg()
2011 unix_state_unlock(other); in unix_dgram_sendmsg()
2012 sock_put(other); in unix_dgram_sendmsg()
2020 * is clearing @other. Never change state to TCP_CLOSE in unix_dgram_sendmsg()
2025 } else if (unix_peer(sk) == other) { in unix_dgram_sendmsg()
2027 unix_dgram_peer_wake_disconnect_wakeup(sk, other); in unix_dgram_sendmsg()
2032 unix_dgram_disconnected(sk, other); in unix_dgram_sendmsg()
2033 sock_put(other); in unix_dgram_sendmsg()
2039 other = NULL; in unix_dgram_sendmsg()
2046 if (other->sk_shutdown & RCV_SHUTDOWN) in unix_dgram_sendmsg()
2050 err = security_unix_may_send(sk->sk_socket, other->sk_socket); in unix_dgram_sendmsg()
2055 /* other == sk && unix_peer(other) != sk if in unix_dgram_sendmsg()
2059 if (other != sk && in unix_dgram_sendmsg()
2060 unlikely(unix_peer(other) != sk && in unix_dgram_sendmsg()
2061 unix_recvq_full_lockless(other))) { in unix_dgram_sendmsg()
2063 timeo = unix_wait_for_peer(other, timeo); in unix_dgram_sendmsg()
2073 unix_state_unlock(other); in unix_dgram_sendmsg()
2074 unix_state_double_lock(sk, other); in unix_dgram_sendmsg()
2077 if (unix_peer(sk) != other || in unix_dgram_sendmsg()
2078 unix_dgram_peer_wake_me(sk, other)) { in unix_dgram_sendmsg()
2093 if (sock_flag(other, SOCK_RCVTSTAMP)) in unix_dgram_sendmsg()
2095 maybe_add_creds(skb, sock, other); in unix_dgram_sendmsg()
2096 scm_stat_add(other, skb); in unix_dgram_sendmsg()
2097 skb_queue_tail(&other->sk_receive_queue, skb); in unix_dgram_sendmsg()
2098 unix_state_unlock(other); in unix_dgram_sendmsg()
2099 other->sk_data_ready(other); in unix_dgram_sendmsg()
2100 sock_put(other); in unix_dgram_sendmsg()
2107 unix_state_unlock(other); in unix_dgram_sendmsg()
2111 if (other) in unix_dgram_sendmsg()
2112 sock_put(other); in unix_dgram_sendmsg()
2123 static int queue_oob(struct socket *sock, struct msghdr *msg, struct sock *other, in queue_oob() argument
2126 struct unix_sock *ousk = unix_sk(other); in queue_oob()
2148 unix_state_lock(other); in queue_oob()
2150 if (sock_flag(other, SOCK_DEAD) || in queue_oob()
2151 (other->sk_shutdown & RCV_SHUTDOWN)) { in queue_oob()
2152 unix_state_unlock(other); in queue_oob()
2157 maybe_add_creds(skb, sock, other); in queue_oob()
2165 scm_stat_add(other, skb); in queue_oob()
2166 skb_queue_tail(&other->sk_receive_queue, skb); in queue_oob()
2167 sk_send_sigurg(other); in queue_oob()
2168 unix_state_unlock(other); in queue_oob()
2169 other->sk_data_ready(other); in queue_oob()
2179 struct sock *other = NULL; in unix_stream_sendmsg() local
2207 other = unix_peer(sk); in unix_stream_sendmsg()
2208 if (!other) in unix_stream_sendmsg()
2268 unix_state_lock(other); in unix_stream_sendmsg()
2270 if (sock_flag(other, SOCK_DEAD) || in unix_stream_sendmsg()
2271 (other->sk_shutdown & RCV_SHUTDOWN)) in unix_stream_sendmsg()
2274 maybe_add_creds(skb, sock, other); in unix_stream_sendmsg()
2275 scm_stat_add(other, skb); in unix_stream_sendmsg()
2276 skb_queue_tail(&other->sk_receive_queue, skb); in unix_stream_sendmsg()
2277 unix_state_unlock(other); in unix_stream_sendmsg()
2278 other->sk_data_ready(other); in unix_stream_sendmsg()
2284 err = queue_oob(sock, msg, other, &scm, fds_sent); in unix_stream_sendmsg()
2296 unix_state_unlock(other); in unix_stream_sendmsg()
2924 struct sock *other; in unix_shutdown() local
2937 other = unix_peer(sk); in unix_shutdown()
2938 if (other) in unix_shutdown()
2939 sock_hold(other); in unix_shutdown()
2943 if (other && in unix_shutdown()
2947 const struct proto *prot = READ_ONCE(other->sk_prot); in unix_shutdown()
2950 prot->unhash(other); in unix_shutdown()
2955 unix_state_lock(other); in unix_shutdown()
2956 WRITE_ONCE(other->sk_shutdown, other->sk_shutdown | peer_mode); in unix_shutdown()
2957 unix_state_unlock(other); in unix_shutdown()
2958 other->sk_state_change(other); in unix_shutdown()
2960 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_HUP); in unix_shutdown()
2962 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_IN); in unix_shutdown()
2964 if (other) in unix_shutdown()
2965 sock_put(other); in unix_shutdown()
3118 * we set writable also when the other side has shut down the in unix_poll()
3130 struct sock *sk = sock->sk, *other; in unix_dgram_poll() local
3173 other = unix_peer(sk); in unix_dgram_poll()
3174 if (other && unix_peer(other) != sk && in unix_dgram_poll()
3175 unix_recvq_full_lockless(other) && in unix_dgram_poll()
3176 unix_dgram_peer_wake_me(sk, other)) in unix_dgram_poll()