Skip to content

Commit b35dc6a

Browse files
author
Teppo Järvelin
committed
Review fix:
- set ppp_active false if close fails in ppp disconnect. - unset sigio in ppp disconnect - take ownership of filehandle in CellularNetwork::disconnect even in case of failure
1 parent dab4215 commit b35dc6a

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

features/FEATURE_LWIP/lwip-interface/ppp_lwip.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,18 +295,16 @@ extern "C" err_t ppp_lwip_connect(void *pcb)
295295

296296
extern "C" err_t ppp_lwip_disconnect(void *pcb)
297297
{
298+
err_t ret = ERR_OK;
298299
if (ppp_active) {
299-
err_t ret = ppp_close(my_ppp_pcb, 0);
300-
if (ret != ERR_OK) {
301-
return ret;
300+
ret = ppp_close(my_ppp_pcb, 0);
301+
if (ret == ERR_OK) {
302+
/* close call made, now let's catch the response in the status callback */
303+
sys_arch_sem_wait(&ppp_close_sem, 0);
302304
}
303-
304-
/* close call made, now let's catch the response in the status callback */
305-
sys_arch_sem_wait(&ppp_close_sem, 0);
306305
ppp_active = false;
307306
}
308-
309-
return ERR_OK;
307+
return ret;
310308
}
311309

312310
extern "C" nsapi_error_t ppp_lwip_if_init(void *pcb, struct netif *netif, const nsapi_ip_stack_t stack)
@@ -384,6 +382,7 @@ nsapi_error_t nsapi_ppp_connect(FileHandle *stream, Callback<void(nsapi_event_t,
384382

385383
if (retcode != NSAPI_ERROR_OK) {
386384
connection_status_cb = NULL;
385+
my_stream->sigio(NULL);
387386
my_stream->set_blocking(true);
388387
my_stream = NULL;
389388
}

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,9 @@ nsapi_error_t AT_CellularNetwork::disconnect()
374374
nsapi_error_t err = nsapi_ppp_disconnect(_at.get_file_handle());
375375
// after ppp disconnect if we wan't to use same at handler we need to set filehandle again to athandler so it
376376
// will set the correct sigio and nonblocking
377-
if (err == NSAPI_ERROR_OK) {
378-
_at.lock();
379-
_at.set_file_handle(_at.get_file_handle());
380-
_at.unlock();
381-
}
377+
_at.lock();
378+
_at.set_file_handle(_at.get_file_handle());
379+
_at.unlock();
382380
return err;
383381
#else
384382
_at.lock();

0 commit comments

Comments
 (0)