|
@@ -16,7 +16,7 @@
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
|
|
|
|
- #define _GNU_SOURCE
|
|
|
+#define _GNU_SOURCE
|
|
|
|
|
|
#include "smartdns/lib/bitops.h"
|
|
|
#include <pthread.h>
|
|
@@ -169,7 +169,6 @@ void tw_add_timer(struct tw_base *base, struct tw_timer_list *timer)
|
|
|
int tw_del_timer(struct tw_base *base, struct tw_timer_list *timer)
|
|
|
{
|
|
|
int ret = 0;
|
|
|
- int call_del = 0;
|
|
|
|
|
|
pthread_spin_lock(&base->lock);
|
|
|
{
|
|
@@ -177,16 +176,16 @@ int tw_del_timer(struct tw_base *base, struct tw_timer_list *timer)
|
|
|
ret = 1;
|
|
|
_tw_detach_timer(timer);
|
|
|
if (timer->del_function) {
|
|
|
- call_del = 1;
|
|
|
+ tw_del_func del_func = timer->del_function;
|
|
|
+ timer->del_function = NULL;
|
|
|
+ pthread_spin_unlock(&base->lock);
|
|
|
+ del_func(base, timer, timer->data);
|
|
|
+ pthread_spin_lock(&base->lock);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
pthread_spin_unlock(&base->lock);
|
|
|
|
|
|
- if (call_del) {
|
|
|
- timer->del_function(base, timer, timer->data);
|
|
|
- }
|
|
|
-
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
@@ -287,8 +286,10 @@ static inline void run_timers(struct tw_base *base)
|
|
|
|
|
|
pthread_spin_lock(&base->lock);
|
|
|
if ((timer_pending(timer) == 0 && timer->del_function)) {
|
|
|
+ tw_del_func del_func = timer->del_function;
|
|
|
+ timer->del_function = NULL;
|
|
|
pthread_spin_unlock(&base->lock);
|
|
|
- timer->del_function(base, timer, timer->data);
|
|
|
+ del_func(base, timer, timer->data);
|
|
|
pthread_spin_lock(&base->lock);
|
|
|
}
|
|
|
}
|