X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Ftimeq.c;h=b71bb7569f42480450017870cb693b063f49c3e0;hb=05c8f77dd9d441e588b8a3ec2547bb1874ac0914;hp=335032519f52a837b01c9f5e58bce5cc88face4e;hpb=0c43c53ca2aa3431c06ff8d865e6faeab3d63aa6;p=NeonServV5.git diff --git a/src/timeq.c b/src/timeq.c index 3350325..b71bb75 100644 --- a/src/timeq.c +++ b/src/timeq.c @@ -29,6 +29,7 @@ static IOHANDLER_CALLBACK(timeq_callback) { switch(event->type) { case IOEVENT_TIMEOUT: entry->callback(entry->data); + entry->iofd = NULL; timeq_del(entry); break; default: @@ -48,10 +49,12 @@ struct timeq_entry* timeq_uadd(int useconds, int module_id, timeq_callback_t *ca perror("malloc() failed"); return NULL; } + #ifdef HAVE_THREADS if(!pthread_mutex_initialized) { THREAD_MUTEX_INIT(synchronized); pthread_mutex_initialized = 1; } + #endif gettimeofday(&timeout, NULL); SYNCHRONIZE(synchronized); timeout.tv_usec += (useconds % 1000); @@ -82,7 +85,9 @@ struct timeq_entry* timeq_uadd_name(char *name, int useconds, int module_id, tim } int timeq_del(struct timeq_entry* entry) { + #ifdef HAVE_THREADS if(!pthread_mutex_initialized) return 0; + #endif SYNCHRONIZE(synchronized); if(entry->next) entry->next->prev = entry->prev; @@ -92,7 +97,8 @@ int timeq_del(struct timeq_entry* entry) { timeq_events = entry->next; if(entry->name) free(entry->name); - iohandler_close(entry->iofd); + if(entry->iofd) + iohandler_close(entry->iofd); free(entry); DESYNCHRONIZE(synchronized); return 1;