summaryrefslogtreecommitdiff
path: root/android/avdtp.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2013-12-20 12:59:26 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2013-12-20 13:07:53 +0200
commit82c1095423b0b871b5fdd62c510b21d85b0cb240 (patch)
tree0c94f83c8a7720438c83f3fbc2f0e4d66308e627 /android/avdtp.c
parente3d07f58d15072c60703ab5bbe2e3b33513a000c (diff)
downloadbluez-82c1095423b0b871b5fdd62c510b21d85b0cb240.tar.gz
android/AVDTP: Duplicate fd passed to avdtp_new
This use dup to create a new fd to be used by AVDTP session leaving the caller free to close the original fd. Note that even if the caller decides to keep the original fd it will still be notified when avdtp_shutdown is called since it uses shutdown.
Diffstat (limited to 'android/avdtp.c')
-rw-r--r--android/avdtp.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/android/avdtp.c b/android/avdtp.c
index 7d3cb18a8..2a5ea9bb6 100644
--- a/android/avdtp.c
+++ b/android/avdtp.c
@@ -2045,9 +2045,16 @@ struct avdtp *avdtp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
{
struct avdtp *session;
GIOCondition cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
+ int new_fd;
+
+ new_fd = dup(fd);
+ if (new_fd < 0) {
+ error("dup(): %s (%d)", strerror(errno), errno);
+ return NULL;
+ }
session = g_new0(struct avdtp, 1);
- session->io = g_io_channel_unix_new(fd);
+ session->io = g_io_channel_unix_new(new_fd);
session->version = version;
session->imtu = imtu;
session->omtu = omtu;