Skip to content
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

Fix TCPSocket::accept() #7992

Merged
merged 1 commit into from
Sep 14, 2018
Merged

Conversation

SeppoTakalo
Copy link
Contributor

Description

TCPSocket::accept() was actually always return NULL, and unsted because we only
have tests with one device.

We will add the testcase for this soon.

This fixes #7936

@kjbracey-arm please review

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Breaking change

This one was actually always return NULL, and unsted because we only
have tests with one device.

We will add the testcase for this soon
@SeppoTakalo
Copy link
Contributor Author

Tested manually by modifying the TEST_APP from Mbed OS

diff --git i/TEST_APPS/device/socket_app/cmd_socket.cpp w/TEST_APPS/device/socket_app/cmd_socket.cpp
index 4aefe700d..0d321159f 100644
--- i/TEST_APPS/device/socket_app/cmd_socket.cpp
+++ w/TEST_APPS/device/socket_app/cmd_socket.cpp
@@ -1125,22 +1125,13 @@ static int cmd_socket(int argc, char *argv[])
         }
 
     } else if (COMMAND_IS("accept")) {
-        SocketAddress addr;
         int32_t id;
-        if (!cmd_parameter_int(argc, argv, "accept", &id)) {
-            cmd_printf("Need new socket id\r\n");
-            return CMDLINE_RETCODE_INVALID_PARAMETERS;
-        }
-        SInfo *new_info = get_sinfo(id);
-        if (!new_info) {
-            cmd_printf("Invalid socket id\r\n");
-            return CMDLINE_RETCODE_FAIL;
-        }
-        TCPSocket *new_sock = static_cast<TCPSocket *>(&new_info->socket());
-        nsapi_error_t ret = static_cast<TCPServer &>(info->socket()).accept(new_sock, &addr);
+        nsapi_error_t ret;
+        TCPSocket *new_sock = static_cast<TCPSocket &>(info->socket()).accept(&ret);
         if (ret == NSAPI_ERROR_OK) {
-            cmd_printf("TCPServer::accept() new socket sid: %d connection from %s port %d\r\n",
-                       new_info->id(), addr.get_ip_address(), addr.get_port());
+            SInfo *new_info = new SInfo(new_sock);
+            m_sockets.push_back(new_info);
+            cmd_printf("TCPServer::accept() new socket sid: %d\r\n", new_info->id());
         }
         return handle_nsapi_error("TCPServer::accept()", ret);
     }

@kjbracey
Copy link
Contributor

/morph build

@mbed-ci
Copy link

mbed-ci commented Sep 10, 2018

Build : SUCCESS

Build number : 3040
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7992/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Sep 10, 2018

@mbed-ci
Copy link

mbed-ci commented Sep 10, 2018

@SeppoTakalo
Copy link
Contributor Author

@kjbracey-arm @0xc0170 @cmonr This is ready for merge, but missing version labels.
Pull it into RC3 if there is still time.

Otherwise next patch

@cmonr
Copy link
Contributor

cmonr commented Sep 14, 2018

Thanks @SeppoTakalo. We'll bring it into the 5.10.1 patch.
At this point, we're doing risk mitigation for RC3 PRs, and even though this PR looks like it should be ok to come in, this not having a test case makes me a bit uneasy.

@cmonr cmonr merged commit 8475477 into ARMmbed:master Sep 14, 2018
@SeppoTakalo SeppoTakalo deleted the fix-tcpsocket-accept branch September 20, 2018 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New TCPSocket API always returns NULL from accept function
6 participants