[MM] [PATCH v2] serial-port: avoid opening a serial port that has been disposed
- From: Ben Chan <benchan chromium org>
- To: networkmanager-list gnome org
- Subject: [MM] [PATCH v2] serial-port: avoid opening a serial port that has been disposed
- Date: Tue, 27 Nov 2012 12:39:30 -0800
---
src/mm-serial-port.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c
index 0a8820d..a33c745 100644
--- a/src/mm-serial-port.c
+++ b/src/mm-serial-port.c
@@ -69,6 +69,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
typedef struct {
guint32 open_count;
+ gboolean disposed;
gboolean forced_close;
int fd;
GHashTable *reply_cache;
@@ -849,6 +850,12 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
device = mm_port_get_device (MM_PORT (self));
+ /* If the MMSerialPort object has been disposed, just return an error. */
+ if (priv->disposed) {
+ mm_info ("(%s) skipped opening serial port that has been disposed", device);
+ return FALSE;
+ }
+
if (priv->open_count) {
/* Already open */
goto success;
@@ -1537,6 +1544,9 @@ dispose (GObject *object)
{
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (object);
+ /* Mark the MMSerialPort object as disposed to prevent it from being re-opened. */
+ priv->disposed = TRUE;
+
if (priv->timeout_id) {
g_source_remove (priv->timeout_id);
priv->timeout_id = 0;
--
1.7.7.3
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]