[PATCH v3 2/3] shared/att: Use io_set_close_on_destroy.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It's better to use io_set_close_on_destroy as opposed to keeping a special
"close_on_unref" flag in bt_att. This not only achieves the exact same result,
but also allows the code to automatically close the file descriptor from several
places by simply calling io_destroy.
---
 src/shared/att.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/shared/att.c b/src/shared/att.c
index 0d27dfa..6f5e405 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -47,7 +47,6 @@ struct att_send_op;
 struct bt_att {
 	int ref_count;
 	int fd;
-	bool close_on_unref;
 	struct io *io;
 	bool invalid;  /* bt_att becomes invalid when a request times out */
 
@@ -692,9 +691,6 @@ void bt_att_unref(struct bt_att *att)
 	io_destroy(att->io);
 	att->io = NULL;
 
-	if (att->close_on_unref)
-		close(att->fd);
-
 	if (att->timeout_destroy)
 		att->timeout_destroy(att->timeout_data);
 
@@ -712,9 +708,7 @@ bool bt_att_set_close_on_unref(struct bt_att *att, bool do_close)
 	if (!att)
 		return false;
 
-	att->close_on_unref = do_close;
-
-	return true;
+	return io_set_close_on_destroy(att->io, do_close);
 }
 
 bool bt_att_set_debug(struct bt_att *att, bt_att_debug_func_t callback,
-- 
2.1.0.rc2.206.gedb03e5

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux