net/rpmsg: add nonblock connect(2) support
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
498830d3f4
commit
c19edbd08e
@ -91,6 +91,7 @@ struct rpmsg_socket_conn_s
|
||||
uint32_t recvlen;
|
||||
FAR struct circbuf_s recvbuf;
|
||||
|
||||
FAR struct socket *psock;
|
||||
FAR struct rpmsg_socket_conn_s *next;
|
||||
|
||||
/* server listen-scoket listening: backlog > 0;
|
||||
@ -291,7 +292,10 @@ static int rpmsg_socket_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||
if (head->cmd == RPMSG_SOCKET_CMD_SYNC)
|
||||
{
|
||||
conn->sendsize = head->size;
|
||||
conn->psock->s_flags |= _SF_CONNECTED;
|
||||
_SO_SETERRNO(conn->psock, OK);
|
||||
rpmsg_socket_post(&conn->sendsem);
|
||||
rpmsg_socket_pollnotify(conn, POLLOUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -508,6 +512,7 @@ static void rpmsg_socket_ns_bind(FAR struct rpmsg_device *rdev,
|
||||
}
|
||||
|
||||
tmp->next = new;
|
||||
new->psock = server->psock;
|
||||
|
||||
rpmsg_socket_unlock(&server->recvlock);
|
||||
|
||||
@ -568,6 +573,7 @@ static int rpmsg_socket_setup(FAR struct socket *psock, int protocol)
|
||||
}
|
||||
|
||||
psock->s_conn = conn;
|
||||
conn->psock = psock;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -647,16 +653,21 @@ static int rpmsg_socket_connect_internal(FAR struct socket *psock)
|
||||
|
||||
if (conn->sendsize == 0)
|
||||
{
|
||||
if (_SS_ISNONBLOCK(psock->s_flags))
|
||||
{
|
||||
return -EINPROGRESS;
|
||||
}
|
||||
|
||||
ret = net_timedwait(&conn->sendsem,
|
||||
_SO_TIMEOUT(psock->s_rcvtimeo));
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
rpmsg_unregister_callback(conn,
|
||||
rpmsg_socket_device_created,
|
||||
rpmsg_socket_device_destroy,
|
||||
rpmsg_socket_device_connect);
|
||||
if (ret < 0)
|
||||
{
|
||||
rpmsg_unregister_callback(conn,
|
||||
rpmsg_socket_device_created,
|
||||
rpmsg_socket_device_destroy,
|
||||
rpmsg_socket_device_connect);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -836,6 +847,11 @@ static int rpmsg_socket_poll(FAR struct socket *psock,
|
||||
|
||||
rpmsg_socket_unlock(&conn->recvlock);
|
||||
}
|
||||
else if (!_SS_ISCONNECTED(psock->s_flags) &&
|
||||
_SS_ISNONBLOCK(psock->s_flags))
|
||||
{
|
||||
ret = OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -EPERM;
|
||||
@ -1125,8 +1141,6 @@ static ssize_t rpmsg_socket_recvmsg(FAR struct socket *psock,
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
psock->s_flags |= _SF_CONNECTED;
|
||||
}
|
||||
|
||||
if (!_SS_ISCONNECTED(psock->s_flags))
|
||||
|
Loading…
Reference in New Issue
Block a user