diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2008-11-08 16:45:53 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2008-11-08 16:45:53 +0200 |
commit | f780466edee5e4b9214632ab8714b959eace6634 (patch) | |
tree | a3ab10a5905847f72276e56dfca8106b7bb5e3e9 | |
parent | 878dee664d16eb6643e0ba2d5d9c2452f98f172e (diff) |
Store RFCOMM tty fd and close it before release
-rw-r--r-- | serial/port.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/serial/port.c b/serial/port.c index 911c777e..c83c84b6 100644 --- a/serial/port.c +++ b/serial/port.c @@ -75,6 +75,7 @@ struct serial_port { uint8_t channel; /* RFCOMM channel */ char *uuid; /* service identification */ char *dev; /* RFCOMM device name */ + int fd; /* Opened file descriptor */ guint listener_id; struct serial_device *device; }; @@ -137,6 +138,11 @@ static int port_release(struct serial_port *port) if (rfcomm_ctl < 0) return -errno; + if (port->fd >= 0) { + close(port->fd); + port->fd = -1; + } + memset(&req, 0, sizeof(req)); req.dev_id = port->id; @@ -233,6 +239,7 @@ static void open_notify(int fd, int err, struct serial_port *port) port_release(port); reply = failed(port->msg, strerror(err)); } else { + port->fd = fd; reply = g_dbus_create_reply(port->msg, DBUS_TYPE_STRING, &port->dev, DBUS_TYPE_INVALID); @@ -457,6 +464,7 @@ int port_register(DBusConnection *conn, const char *path, bdaddr_t *src, port->channel = channel; port->device = device; port->id = -1; + port->fd = -1; device->ports = g_slist_append(device->ports, port); |