mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
net/local: set the filep to peer on stream mode
Change-Id: I2e0b8f31bcd3c1c238f1b18456416678d5deae1e Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
@@ -123,7 +123,7 @@ static int psock_fifo_read(FAR struct socket *psock, FAR void *buf,
|
||||
static void local_recvctl(FAR struct local_conn_s *conn,
|
||||
FAR struct msghdr *msg)
|
||||
{
|
||||
FAR struct local_conn_s *peer = conn->lc_peer;
|
||||
FAR struct local_conn_s *peer;
|
||||
struct cmsghdr *cmsg;
|
||||
int count;
|
||||
int *fds;
|
||||
@@ -131,7 +131,16 @@ static void local_recvctl(FAR struct local_conn_s *conn,
|
||||
|
||||
net_lock();
|
||||
|
||||
if (peer == NULL)
|
||||
cmsg = CMSG_FIRSTHDR(msg);
|
||||
count = (cmsg->cmsg_len - sizeof(struct cmsghdr)) / sizeof(int);
|
||||
cmsg->cmsg_len = 0;
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (conn->lc_peer == NULL)
|
||||
{
|
||||
peer = local_peerconn(conn);
|
||||
if (peer == NULL)
|
||||
@@ -139,16 +148,12 @@ static void local_recvctl(FAR struct local_conn_s *conn,
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (peer->lc_cfpcount == 0)
|
||||
else
|
||||
{
|
||||
goto out;
|
||||
peer = conn;
|
||||
}
|
||||
|
||||
cmsg = CMSG_FIRSTHDR(msg);
|
||||
|
||||
count = (cmsg->cmsg_len - sizeof(struct cmsghdr)) / sizeof(int);
|
||||
if (count == 0)
|
||||
if (peer->lc_cfpcount == 0)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
static int local_sendctl(FAR struct local_conn_s *conn,
|
||||
FAR struct msghdr *msg)
|
||||
{
|
||||
FAR struct local_conn_s *peer;
|
||||
FAR struct file *filep2;
|
||||
FAR struct file *filep;
|
||||
struct cmsghdr *cmsg;
|
||||
@@ -71,6 +72,12 @@ static int local_sendctl(FAR struct local_conn_s *conn,
|
||||
|
||||
net_lock();
|
||||
|
||||
peer = conn->lc_peer;
|
||||
if (peer == NULL)
|
||||
{
|
||||
peer = conn;
|
||||
}
|
||||
|
||||
for_each_cmsghdr(cmsg, msg)
|
||||
{
|
||||
if (!CMSG_OK(msg, cmsg) ||
|
||||
@@ -84,7 +91,7 @@ static int local_sendctl(FAR struct local_conn_s *conn,
|
||||
fds = (int *)CMSG_DATA(cmsg);
|
||||
count = (cmsg->cmsg_len - sizeof(struct cmsghdr)) / sizeof(int);
|
||||
|
||||
if (count + conn->lc_cfpcount > LOCAL_NCONTROLFDS)
|
||||
if (count + peer->lc_cfpcount > LOCAL_NCONTROLFDS)
|
||||
{
|
||||
ret = -EMFILE;
|
||||
goto fail;
|
||||
@@ -112,7 +119,7 @@ static int local_sendctl(FAR struct local_conn_s *conn,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
conn->lc_cfps[conn->lc_cfpcount++] = filep2;
|
||||
peer->lc_cfps[peer->lc_cfpcount++] = filep2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,9 +130,9 @@ static int local_sendctl(FAR struct local_conn_s *conn,
|
||||
fail:
|
||||
while (i-- > 0)
|
||||
{
|
||||
file_close(conn->lc_cfps[--conn->lc_cfpcount]);
|
||||
kmm_free(conn->lc_cfps[conn->lc_cfpcount]);
|
||||
conn->lc_cfps[conn->lc_cfpcount] = NULL;
|
||||
file_close(peer->lc_cfps[--peer->lc_cfpcount]);
|
||||
kmm_free(peer->lc_cfps[peer->lc_cfpcount]);
|
||||
peer->lc_cfps[peer->lc_cfpcount] = NULL;
|
||||
}
|
||||
|
||||
net_unlock();
|
||||
|
||||
Reference in New Issue
Block a user