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

Conversation

Projects
None yet
6 participants
@SeppoTakalo
Contributor

SeppoTakalo commented Sep 5, 2018

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
Fix TCPSocket::accept()
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

This comment has been minimized.

Contributor

SeppoTakalo commented Sep 5, 2018

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);
     }
@0xc0170

0xc0170 approved these changes Sep 5, 2018

@kjbracey-arm

This comment has been minimized.

Contributor

kjbracey-arm commented Sep 10, 2018

/morph build

@mbed-ci

This comment has been minimized.

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

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@SeppoTakalo

This comment has been minimized.

Contributor

SeppoTakalo commented Sep 14, 2018

@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

This comment has been minimized.

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

14 checks passed

ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-mbed2-build build completed
Details
ci-morph-test test completed , RTOS ROM(+0.0%) RAM(+0.0%)
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci/cloud_client_smoke_test Test job: successful
Details
travis-ci/astyle Passed, 597 files
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/events Passed, runtime is 9189 cycles (+63 cycles)
Details
travis-ci/gitattributestest Local gitattributestest testing has passed
Details
travis-ci/licence_check Local licence_check testing has passed
Details
travis-ci/littlefs Passed, code size is 8372B (+0.00%)
Details
travis-ci/tools-py2.7 Local tools-py2.7 testing has passed
Details

@SeppoTakalo SeppoTakalo deleted the SeppoTakalo:fix-tcpsocket-accept branch Sep 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment