summaryrefslogtreecommitdiff
path: root/serial
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-11-08 16:45:53 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-11-08 16:45:53 +0200
commitf780466edee5e4b9214632ab8714b959eace6634 (patch)
treea3ab10a5905847f72276e56dfca8106b7bb5e3e9 /serial
parent878dee664d16eb6643e0ba2d5d9c2452f98f172e (diff)
Store RFCOMM tty fd and close it before release
Diffstat (limited to 'serial')
-rw-r--r--serial/port.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/serial/port.c b/serial/port.c
index 911c777ec..c83c84b66 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);