summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/glib-ectomy.c65
-rw-r--r--common/glib-ectomy.h1
-rw-r--r--hcid/dbus-security.c5
3 files changed, 45 insertions, 26 deletions
diff --git a/common/glib-ectomy.c b/common/glib-ectomy.c
index f90973ba..f4e552cd 100644
--- a/common/glib-ectomy.c
+++ b/common/glib-ectomy.c
@@ -230,21 +230,26 @@ static int timeout_cmp(const void *t1, const void *t2)
static void timeout_handlers_check(GMainContext *context)
{
- struct slist *l = context->ltimeout;
struct timeout *t;
struct timeval tv;
gettimeofday(&tv, NULL);
- while (l) {
+ context->processed = NULL;
+
+ while (context->ltimeout) {
struct slist *match;
+ glong secs, msecs;
gboolean ret;
- t = l->data;
- l = l->next;
+ t = context->ltimeout->data;
+
+ context->ltimeout = slist_remove(context->ltimeout, t);
- if (timercmp(&tv, &t->expiration, <))
+ if (timercmp(&tv, &t->expiration, <)) {
+ context->processed = slist_append(context->processed, t);
continue;
+ }
ret = t->function(t->data);
@@ -255,26 +260,27 @@ static void timeout_handlers_check(GMainContext *context)
if (!match)
continue;
- /* Update next pointer if callback changed the list */
- l = match->next;
-
- if (ret == FALSE) {
- context->ltimeout = slist_remove(context->ltimeout, t);
+ if (!ret) {
free(t);
- } else {
- glong secs, msecs;
- /* update the next expiration time */
- secs = t->interval / 1000;
- msecs = t->interval - secs * 1000;
-
- t->expiration.tv_sec = tv.tv_sec + secs;
- t->expiration.tv_usec = tv.tv_usec + msecs * 1000;
- if (t->expiration.tv_usec >= 1000000) {
- t->expiration.tv_usec -= 1000000;
- t->expiration.tv_sec++;
- }
+ continue;
}
+
+ /* update the next expiration time */
+ secs = t->interval / 1000;
+ msecs = t->interval - secs * 1000;
+
+ t->expiration.tv_sec = tv.tv_sec + secs;
+ t->expiration.tv_usec = tv.tv_usec + msecs * 1000;
+ if (t->expiration.tv_usec >= 1000000) {
+ t->expiration.tv_usec -= 1000000;
+ t->expiration.tv_sec++;
+ }
+
+ context->processed = slist_append(context->processed, t);
}
+
+ context->ltimeout = context->processed;
+ context->processed = NULL;
}
void g_main_loop_run(GMainLoop *loop)
@@ -420,5 +426,20 @@ gint g_timeout_remove(const guint id)
return 0;
}
+ l = default_context->processed;
+
+ while (l) {
+ t = l->data;
+ l = l->next;
+
+ if (t->id != id)
+ continue;
+
+ default_context->processed = slist_remove(default_context->processed, t);
+ free(t);
+
+ return 0;
+ }
+
return -1;
}
diff --git a/common/glib-ectomy.h b/common/glib-ectomy.h
index f52a9ce2..af6f4fbb 100644
--- a/common/glib-ectomy.h
+++ b/common/glib-ectomy.h
@@ -48,6 +48,7 @@ typedef struct _GMainContext {
guint next_id;
glong timeout;
struct slist *ltimeout;
+ struct slist *processed;
} GMainContext;
typedef struct _GMainLoop {
diff --git a/hcid/dbus-security.c b/hcid/dbus-security.c
index c9c6763f..5bc8adde 100644
--- a/hcid/dbus-security.c
+++ b/hcid/dbus-security.c
@@ -40,7 +40,7 @@
#include "hcid.h"
#define REQUEST_TIMEOUT (30 * 1000) /* 30 seconds */
-#define AGENT_TIMEOUT (1 * 10 * 1000) /* 3 minutes */
+#define AGENT_TIMEOUT (3 * 60 * 1000) /* 3 minutes */
static struct passkey_agent *default_agent = NULL;
@@ -255,10 +255,7 @@ static DBusHandlerResult register_agent(DBusConnection *conn,
if (!slist_find(adapter->passkey_agents, &ref, (cmp_func_t)agent_cmp))
name_listener_add(conn, ref.name, (name_cb_t)agent_exited, adapter);
- /* Because of bugs in glib-ectonomy.c this doesn't work yet */
-#if 0
agent->timeout = g_timeout_add(AGENT_TIMEOUT, (GSourceFunc)agent_timeout, agent);
-#endif
adapter->passkey_agents = slist_append(adapter->passkey_agents, agent);