dispatcher-connection: add new 'disconnect-request' event
When bearer gets an event that should trigger a disconnection but we
cannot disconnect (for example because we're waiting for pppd to close),
we now trigger a new 'disconnect-request' event instead
This was tested with the following hook:
```
$ cat /etc/ModemManager/connection.d/handle-disconnect-request.sh
#!/bin/sh
if [ "$4" != disconnect-request ]; then
exit 0
fi
iface=$(mmcli -b "$2" -K | awk '/bearer.status.interface/ { print $3 }')
if pkill -f "pppd\>.*\<$iface\>"; then
logger -t mm-disconnect-request "Killed $iface pppd"
else
logger -t mm-disconnect-request "No pppd found for $iface"
fi
```
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
This commit is contained in:
@@ -1492,6 +1492,8 @@ mm_base_bearer_disconnect_force (MMBaseBearer *self)
|
||||
|
||||
if (self->priv->ignore_disconnection_reports) {
|
||||
mm_obj_dbg (self, "disconnection should be forced but it's explicitly ignored");
|
||||
bearer_run_dispatcher_scripts (self,
|
||||
MM_DISPATCHER_CONNECTION_EVENT_DISCONNECT_REQUEST);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@ mm_dispatcher_connection_event_to_string (MMDispatcherConnectionEvent event)
|
||||
return g_strdup ("connected");
|
||||
case MM_DISPATCHER_CONNECTION_EVENT_DISCONNECTED:
|
||||
return g_strdup ("disconnected");
|
||||
case MM_DISPATCHER_CONNECTION_EVENT_DISCONNECT_REQUEST:
|
||||
return g_strdup ("disconnect-request");
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ typedef struct _MMDispatcherConnectionPrivate MMDispatcherConnectionPrivate;
|
||||
typedef enum { /*< underscore_name=mm_dispatcher_connection_event >*/
|
||||
MM_DISPATCHER_CONNECTION_EVENT_CONNECTED,
|
||||
MM_DISPATCHER_CONNECTION_EVENT_DISCONNECTED,
|
||||
MM_DISPATCHER_CONNECTION_EVENT_DISCONNECT_REQUEST,
|
||||
} MMDispatcherConnectionEvent;
|
||||
|
||||
GType mm_dispatcher_connection_get_type (void);
|
||||
|
||||
Reference in New Issue
Block a user