From: "Daniel Örstadius" <daniel.orstadius@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] dbus timeout handling
Date: Wed, 16 Dec 2009 12:11:21 +0200 [thread overview]
Message-ID: <eb7933e20912160211h165d90f2s4969c6cfea2d9b01@mail.gmail.com> (raw)
In-Reply-To: <eb7933e20912110025y20eb4a6aw615660648d4756f8@mail.gmail.com>
On Fri, Dec 11, 2009 at 10:25 AM, Daniel Örstadius
<daniel.orstadius@gmail.com> wrote:
> When receiving a file it's possible to crash obexd by letting the
> "org.openobex.Error.Rejected" reply from the call to
> request_authorization and the obexd timeout for the response occur at
> roughly the same time.
>
Making a new patch proposal for this after discussion with Johan.
The patch concerns how dbus timeouts are stopped in obexd in the
functions remove_timeout and timeout_handler_free. Without this patch
it is all done in the latter. Using the patch it is done in both, with
the freeing being made in timeout_handler_free.
The reason for making this modification is that in at least one corner
case it looks to be possible for obexd to dispatch (by
timeout_handler_dispatch) a timeout on which dbus has called
remove_timeout (which is currently empty).
Compared the obexd-dbus mainloop integration with the dbus-glib
implementation at
http://cgit.freedesktop.org/dbus/dbus-glib/tree/dbus/dbus-gmain.c
Its corresponding callbacks for obexd's remove_timeout and
timeout_handler_free both do the same thing as far as I understood the
code.
>From the dbus-glib code:
dbus_connection_set_timeout_functions (.., remove_timeout,..)
leading to
remove_timeout ->
connection_setup_remove_timeout ->
timeout_handler_destroy_source ->
g_source_destroy
and
add_timeout -> dbus_timeout_set_data (.., timeout_handler_timeout_freed)
leading to
timeout_handler_timeout_freed ->
timeout_handler_destroy_source ->
g_source_destroy
They both stop the timeout, but do not free the timeout_handler
structure. This is done in timeout_handler_source_finalized which is
set via
g_source_set_callback (.., timeout_handler_source_finalized) in add_timeout.
obexd does not use this kind of finalize callback. Other than this,
the intention is for the patch to map to the dbus-glib implementation
by removing the timer in both callbacks.
(I'm not an expert in dbus nor glib, there could be pitfalls with this
modification)
/Daniel
---------
>From 70cc29c724c089e1468a6670c53e1f77d5b3ebcc Mon Sep 17 00:00:00 2001
From: Daniel Orstadius <daniel.orstadius@gmail.com>
Date: Wed, 16 Dec 2009 11:23:46 +0200
Subject: [PATCH] dbus timeout handling
---
gdbus/mainloop.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c
index bd775f8..f808f5d 100644
--- a/gdbus/mainloop.c
+++ b/gdbus/mainloop.c
@@ -183,7 +183,11 @@ static void timeout_handler_free(void *data)
if (!handler)
return;
- g_source_remove(handler->id);
+ if (handler->id != 0) {
+ g_source_remove(handler->id);
+ handler->id = 0;
+ }
+
g_free(handler);
}
@@ -207,6 +211,17 @@ static dbus_bool_t add_timeout(DBusTimeout
*timeout, void *data)
static void remove_timeout(DBusTimeout *timeout, void *data)
{
+ timeout_handler_t *handler;
+
+ handler = dbus_timeout_get_data(timeout);
+
+ if (!handler)
+ return;
+
+ if (handler->id != 0) {
+ g_source_remove(handler->id);
+ handler->id = 0;
+ }
}
static void timeout_toggled(DBusTimeout *timeout, void *data)
--
1.6.0.4
next prev parent reply other threads:[~2009-12-16 10:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-11 8:25 [PATCH] dbus timeout handling Daniel Örstadius
2009-12-16 10:11 ` Daniel Örstadius [this message]
2009-12-17 5:34 ` Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eb7933e20912160211h165d90f2s4969c6cfea2d9b01@mail.gmail.com \
--to=daniel.orstadius@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox