-
Notifications
You must be signed in to change notification settings - Fork 253
Description
Describe the bug
When using OS_SocketAccept on a stream (TCP) server socket, it fails because the accept code calls OS_ObjectIdGetById() passing a OS_LOCK_MODE_REFCOUNT, but then OS_SocketAccept sees the refcount > 0 and fails out.
To Reproduce
Create code (e.g. an app) that creates a TCP socket server and try using OS_SocketAccept() to receive the incoming connections.
Expected behavior
OS_SocketAccept should work as expected/documented.
Code snips
OS_SockAddr_t Addr;
int Socket = 0, ClientFd;
int32 Status = 0;
OS_SocketAddrInit(&Addr, OS_SocketDomain_INET);
OS_SocketAddrFromString(Addr, "127.0.0.1");
OS_SocketOpen(&Socket, OS_SocketDomain_INET, OS_SocketType_STREAM);
OS_SocketBind(Socket, &Addr);
Status = OS_SocketAccept(Socket, &ClientFd, &Addr, 0);
System observed on:
Debian 9 64-bit x86
Additional context
removing the check for refcount results in expected behavior, OS accept() call should be thread-safe so need not maintain lock through SocketAccept() function.
Reporter Info
Chris Knight, NASA Ames