net/socket: fix cloning of local and raw sockets
This commit is contained in:
parent
d1fc0040d7
commit
d928b4271d
|
@ -50,6 +50,8 @@
|
|||
|
||||
#include "tcp/tcp.h"
|
||||
#include "udp/udp.h"
|
||||
#include "pkt/pkt.h"
|
||||
#include "local/local.h"
|
||||
#include "socket/socket.h"
|
||||
#include "usrsock/usrsock.h"
|
||||
|
||||
|
@ -97,6 +99,24 @@ int net_clone(FAR struct socket *psock1, FAR struct socket *psock2)
|
|||
DEBUGASSERT(psock2->s_conn);
|
||||
psock2->s_crefs = 1; /* One reference on the new socket itself */
|
||||
|
||||
#ifdef CONFIG_NET_LOCAL
|
||||
if (psock2->s_domain == PF_LOCAL)
|
||||
{
|
||||
FAR struct local_conn_s *conn = psock2->s_conn;
|
||||
DEBUGASSERT(conn->lc_crefs > 0 && conn->lc_crefs < 255);
|
||||
conn->lc_crefs++;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef CONFIG_NET_PKT
|
||||
if (psock2->s_type == SOCK_RAW)
|
||||
{
|
||||
FAR struct pkt_conn_s *conn = psock2->s_conn;
|
||||
DEBUGASSERT(conn->crefs > 0 && conn->crefs < 255);
|
||||
conn->crefs++;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef NET_TCP_HAVE_STACK
|
||||
if (psock2->s_type == SOCK_STREAM)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue