Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of ublox-at-cellular-interface by
Revision 14:5f55453ef38f, committed 2018-03-01
- Comitter:
- amq
- Date:
- Thu Mar 01 21:32:25 2018 +0000
- Parent:
- 13:39264b492ce7
- Commit message:
- Let handle_event() finish a full cycle before destruction
Changed in this revision
| UbloxATCellularInterface.cpp | Show annotated file Show diff for this revision Revisions of this file |
| UbloxATCellularInterface.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/UbloxATCellularInterface.cpp Wed Jan 10 09:44:24 2018 +0000
+++ b/UbloxATCellularInterface.cpp Thu Mar 01 21:32:25 2018 +0000
@@ -40,7 +40,7 @@
fhs.fh = _fh;
fhs.events = POLLIN;
- while (true) {
+ while (_run_event_thread) {
count = poll(&fhs, 1, 1000);
if (count > 0 && (fhs.revents & POLLIN)) {
LOCK();
@@ -938,6 +938,8 @@
_uname = NULL;
_pwd = NULL;
_connection_status_cb = NULL;
+
+ _run_event_thread = true;
// Initialise sockets storage
memset(_sockets, 0, sizeof(_sockets));
@@ -969,6 +971,9 @@
// Destructor.
UbloxATCellularInterface::~UbloxATCellularInterface()
{
+ _run_event_thread = false;
+ event_thread.join();
+
// Free _ip if it was ever allocated
free(_ip);
}
--- a/UbloxATCellularInterface.h Wed Jan 10 09:44:24 2018 +0000
+++ b/UbloxATCellularInterface.h Thu Mar 01 21:32:25 2018 +0000
@@ -609,6 +609,7 @@
bool _sim_pin_change_pending;
const char *_sim_pin_change_pending_new_pin_value;
Thread event_thread;
+ bool _run_event_thread;
void handle_event();
SockCtrl * find_socket(int modem_handle = SOCKET_UNUSED);
void clear_socket(SockCtrl * socket);
