Re: [PATCH v1 1/1] shared/att: Handle disconnects.

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

 



Hi Arman,

On Fri, Aug 08, 2014, Arman Uguray wrote:
> +static bool disconnect_cb(struct io *io, void *user_data)
> +{
> +	struct bt_att *att = user_data;
> +
> +	bt_att_cancel_all(att);
> +
> +	att->invalid = true;
> +
> +	util_debug(att->debug_callback, att->debug_data,
> +						"Physical link disconnected");
> +
> +	if (att->disconn_callback)
> +		att->disconn_callback(att->disconn_data);
> +
> +	/* It's unsafe to destroy the struct io during the disconnect callback.
> +	 * post a task on the main loop to perform this later.
> +	 */
> +	att->io_destroy_id = timeout_add(1, io_destroy_cb, att, NULL);

Is this the only reason you're keeping the "bool invalid" variable? I'd
take a different approach and fix the generic IO handling to be able to
destroy the io from within of the disconnect callback. The simplest way
to do this would be to increment the reference count in the generic io
code before calling the disconnect callback and the decrement once done
with the io pointer.

Johan
--
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