From f780466edee5e4b9214632ab8714b959eace6634 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sat, 8 Nov 2008 16:45:53 +0200 Subject: Store RFCOMM tty fd and close it before release --- serial/port.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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); -- cgit