-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OS_SocketAccept fails #349
Comments
Is it possible to create a functional test case to cover this? The fact it doesn't work seems to indicate a missing functional test. |
@CDKnightNASA - any progress on this one? Do you suggest we discuss at a CCB, or is there anything you need to help resolve it? |
I need to write unit tests for it, hasn't been high on priority list. I can take a crack at it today. |
FYI @jphickey there's a great dearth of unit tests for the network API... So I wasn't clear after this last CCB whether we should use stubbed versions of the OS calls or use the real calls in unit testing. I am guessing that socket code should call the stubs as the OS may throw errors depending on firewall or other security-related configuration. |
see #373 |
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
The text was updated successfully, but these errors were encountered: