diff options
| author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2006-06-30 18:59:27 +0000 | 
|---|---|---|
| committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2006-06-30 18:59:27 +0000 | 
| commit | a13cbac6d61e4696941a747b376a93bbcffda1a2 (patch) | |
| tree | d5e74a1d2cd825ad1865978da8f6adca402ff209 /common/glib-ectomy.c | |
| parent | da33b995b67d60a7f05a6ab068e6e6f3a99a6e8c (diff) | |
Fixed timeout for pending reply
Diffstat (limited to 'common/glib-ectomy.c')
| -rw-r--r-- | common/glib-ectomy.c | 19 | 
1 files changed, 16 insertions, 3 deletions
| diff --git a/common/glib-ectomy.c b/common/glib-ectomy.c index dff48ef6..aa1007ee 100644 --- a/common/glib-ectomy.c +++ b/common/glib-ectomy.c @@ -231,6 +231,11 @@ static void timeout_handlers_prepare(GMainContext *context)  	context->timeout = (timeout != LONG_MAX ? timeout: -1);  } +static int timeout_cmp(const void *t1, const void *t2) +{ +	return t1-t2; +} +  static void timeout_handlers_check(GMainContext *context)  {  	struct slist *l = context->ltimeout; @@ -249,9 +254,17 @@ static void timeout_handlers_check(GMainContext *context)  			continue;  		if (t->function(t->data)) { -			/* if false/expired: remove it from the list */ -			context->ltimeout = slist_remove(context->ltimeout, t); -			free(t); +			struct slist *match; +			/* if false/expired: remove it from the list +			 * Before remove check again in order to cover the situation +			 * when the handler is removed/freed by the callback function +			 */ +			match = slist_find(context->ltimeout, t, timeout_cmp); +			if (match) { +				t = match->data; +				context->ltimeout = slist_remove(context->ltimeout, t); +				free(t); +			}  		} else {  			glong secs, msecs;  			/* update the next expiration time */ | 
