MCPcopy Create free account
hub / github.com/apache/nuttx / rpmsg_socket_poll

Function rpmsg_socket_poll

net/rpmsg/rpmsg_sockif.c:891–988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

889}
890
891static 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

Callers

nothing calls this directly

Calls 5

nxmutex_lockFunction · 0.85
nxmutex_unlockFunction · 0.85
rpmsg_socket_get_spaceFunction · 0.85
circbuf_is_emptyFunction · 0.85
poll_notifyFunction · 0.85

Tested by

no test coverage detected