mirror of https://github.com/ARMmbed/mbed-os.git
Fixed ppp disconnect hangs when connection failure.
parent
4fcaa56b77
commit
dab4215a9a
|
@ -295,20 +295,18 @@ extern "C" err_t ppp_lwip_connect(void *pcb)
|
||||||
|
|
||||||
extern "C" err_t ppp_lwip_disconnect(void *pcb)
|
extern "C" err_t ppp_lwip_disconnect(void *pcb)
|
||||||
{
|
{
|
||||||
err_t ret = ppp_close(my_ppp_pcb, 0);
|
if (ppp_active) {
|
||||||
if (ret != ERR_OK) {
|
err_t ret = ppp_close(my_ppp_pcb, 0);
|
||||||
return ret;
|
if (ret != ERR_OK) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close call made, now let's catch the response in the status callback */
|
||||||
|
sys_arch_sem_wait(&ppp_close_sem, 0);
|
||||||
|
ppp_active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close call made, now let's catch the response in the status callback */
|
return ERR_OK;
|
||||||
sys_arch_sem_wait(&ppp_close_sem, 0);
|
|
||||||
|
|
||||||
/* Detach callbacks, and put handle back to default blocking mode */
|
|
||||||
my_stream->sigio(Callback<void()>());
|
|
||||||
my_stream->set_blocking(true);
|
|
||||||
my_stream = NULL;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" nsapi_error_t ppp_lwip_if_init(void *pcb, struct netif *netif, const nsapi_ip_stack_t stack)
|
extern "C" nsapi_error_t ppp_lwip_if_init(void *pcb, struct netif *netif, const nsapi_ip_stack_t stack)
|
||||||
|
@ -373,6 +371,9 @@ nsapi_error_t nsapi_ppp_connect(FileHandle *stream, Callback<void(nsapi_event_t,
|
||||||
retcode = lwip._add_ppp_interface(stream, true, stack, &my_interface);
|
retcode = lwip._add_ppp_interface(stream, true, stack, &my_interface);
|
||||||
if (retcode != NSAPI_ERROR_OK) {
|
if (retcode != NSAPI_ERROR_OK) {
|
||||||
my_interface = NULL;
|
my_interface = NULL;
|
||||||
|
my_stream->set_blocking(true);
|
||||||
|
my_stream = NULL;
|
||||||
|
connection_status_cb = NULL;
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,6 +382,12 @@ nsapi_error_t nsapi_ppp_connect(FileHandle *stream, Callback<void(nsapi_event_t,
|
||||||
// attach deferred until ppp_lwip_connect, called from mbed_lwip_bringup
|
// attach deferred until ppp_lwip_connect, called from mbed_lwip_bringup
|
||||||
retcode = my_interface->bringup(false, NULL, NULL, NULL, stack, blocking_connect);
|
retcode = my_interface->bringup(false, NULL, NULL, NULL, stack, blocking_connect);
|
||||||
|
|
||||||
|
if (retcode != NSAPI_ERROR_OK) {
|
||||||
|
connection_status_cb = NULL;
|
||||||
|
my_stream->set_blocking(true);
|
||||||
|
my_stream = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (retcode != NSAPI_ERROR_OK && connect_error_code != NSAPI_ERROR_OK) {
|
if (retcode != NSAPI_ERROR_OK && connect_error_code != NSAPI_ERROR_OK) {
|
||||||
return connect_error_code;
|
return connect_error_code;
|
||||||
} else {
|
} else {
|
||||||
|
@ -390,7 +397,19 @@ nsapi_error_t nsapi_ppp_connect(FileHandle *stream, Callback<void(nsapi_event_t,
|
||||||
|
|
||||||
nsapi_error_t nsapi_ppp_disconnect(FileHandle *stream)
|
nsapi_error_t nsapi_ppp_disconnect(FileHandle *stream)
|
||||||
{
|
{
|
||||||
return my_interface->bringdown();
|
if (my_stream != stream) {
|
||||||
|
return NSAPI_ERROR_NO_CONNECTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsapi_error_t retcode = my_interface->bringdown();
|
||||||
|
|
||||||
|
connection_status_cb = NULL;
|
||||||
|
/* Detach callbacks, and put handle back to default blocking mode */
|
||||||
|
my_stream->sigio(NULL);
|
||||||
|
my_stream->set_blocking(true);
|
||||||
|
my_stream = NULL;
|
||||||
|
|
||||||
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkStack *nsapi_ppp_get_stack()
|
NetworkStack *nsapi_ppp_get_stack()
|
||||||
|
|
Loading…
Reference in New Issue