File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
libraries/SocketWrapper/src Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -13,20 +13,24 @@ uint8_t arduino::MbedClient::status() {
1313 return _status;
1414}
1515
16+
1617void arduino::MbedClient::readSocket () {
17- while (1 ) {
18+ uint8_t data[SOCKET_BUFFER_SIZE];
19+
20+ while (sock != nullptr ) {
1821 event->wait_any (0xFF , 100 );
19- uint8_t data[SOCKET_BUFFER_SIZE];
2022 int ret = NSAPI_ERROR_WOULD_BLOCK;
2123 do {
24+ mutex->lock ();
25+ if (sock == nullptr ) {
26+ goto cleanup;
27+ }
28+ mutex->unlock ();
2229 if (rxBuffer.availableForStore () == 0 ) {
2330 yield ();
2431 continue ;
2532 }
2633 mutex->lock ();
27- if (sock == nullptr ) {
28- goto cleanup;
29- }
3034 ret = sock->recv (data, rxBuffer.availableForStore ());
3135 if (ret < 0 && ret != NSAPI_ERROR_WOULD_BLOCK) {
3236 goto cleanup;
@@ -61,7 +65,7 @@ void arduino::MbedClient::configureSocket(Socket *_s) {
6165 _s->set_timeout (_timeout);
6266 _s->set_blocking (false );
6367 _s->getpeername (&address);
64-
68+
6569 if (event == nullptr ) {
6670 event = new rtos::EventFlags;
6771 }
@@ -295,6 +299,7 @@ void arduino::MbedClient::stop() {
295299 mutex = nullptr ;
296300 }
297301 _status = false ;
302+ rxBuffer.clear ();
298303}
299304
300305uint8_t arduino::MbedClient::connected () {
You can’t perform that action at this time.
0 commit comments