| 889 | } |
| 890 | |
| 891 | static int rpmsg_socket_poll(FAR struct socket *psock, |
| 892 | FAR struct pollfd *fds, bool setup) |
| 893 | { |
| 894 | FAR struct rpmsg_socket_conn_s *conn = psock->s_conn; |
| 895 | pollevent_t eventset = 0; |
| 896 | int i; |
| 897 | |
| 898 | if (setup) |
| 899 | { |
| 900 | nxmutex_lock(&conn->polllock); |
| 901 | for (i = 0; i < CONFIG_NET_RPMSG_NPOLLWAITERS; i++) |
| 902 | { |
| 903 | /* Find an available slot */ |
| 904 | |
| 905 | if (!conn->fds[i]) |
| 906 | { |
| 907 | /* Bind the poll structure and this slot */ |
| 908 | |
| 909 | conn->fds[i] = fds; |
| 910 | fds->priv = &conn->fds[i]; |
| 911 | break; |
| 912 | } |
| 913 | } |
| 914 | |
| 915 | nxmutex_unlock(&conn->polllock); |
| 916 | if (i >= CONFIG_NET_RPMSG_NPOLLWAITERS) |
| 917 | { |
| 918 | fds->priv = NULL; |
| 919 | return -EBUSY; |
| 920 | } |
| 921 | |
| 922 | /* Immediately notify on any of the requested events */ |
| 923 | |
| 924 | if (_SS_ISLISTENING(conn->sconn.s_flags)) |
| 925 | { |
| 926 | nxmutex_lock(&conn->recvlock); |
| 927 | if (conn->next) |
| 928 | { |
| 929 | eventset |= POLLIN; |
| 930 | } |
| 931 | |
| 932 | nxmutex_unlock(&conn->recvlock); |
| 933 | } |
| 934 | else if (_SS_ISCONNECTED(conn->sconn.s_flags)) |
| 935 | { |
| 936 | if (!conn->ept.rdev || conn->unbind) |
| 937 | { |
| 938 | eventset |= POLLHUP; |
| 939 | } |
| 940 | |
| 941 | nxmutex_lock(&conn->sendlock); |
| 942 | if (rpmsg_socket_get_space(conn) > 0) |
| 943 | { |
| 944 | eventset |= POLLOUT; |
| 945 | } |
| 946 | |
| 947 | nxmutex_unlock(&conn->sendlock); |
| 948 |
nothing calls this directly
no test coverage detected