X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FWHOHandler.c;h=f8769decabbce38aa79444156a7b1006b3450e83;hb=c32e8254ec4ed0d77757e32f8aa5aabcdb494057;hp=63232f7c7998d0be5451118cecb9cedfb662172b;hpb=eba9bbb5fb73ad2bd0c420e03199a828b6eabc5f;p=NeonServV5.git diff --git a/src/WHOHandler.c b/src/WHOHandler.c index 63232f7..f8769de 100644 --- a/src/WHOHandler.c +++ b/src/WHOHandler.c @@ -39,11 +39,6 @@ struct WHOQueueEntry { struct WHOQueueEntry *next; void *callback[MAXCALLBACKS]; void *data[MAXCALLBACKS]; - #ifdef HAVE_THREADS - unsigned long lock_tid; - pthread_mutex_t lock_mutex; - int lock_count; - #endif }; static int checkWHOID(struct ClientSocket *client, int whoid) { @@ -74,11 +69,6 @@ static struct WHOQueueEntry* addWHOQueueEntry(struct ClientSocket *client) { } entry->next = NULL; entry->whoid = whoid; - #ifdef HAVE_THREADS - entry->lock_tid = 0; - THREAD_MUTEX_INIT(entry->lock_mutex); - entry->lock_count = 0; - #endif if(client->whoqueue_last) { client->whoqueue_last->next = entry; } else { @@ -106,15 +96,6 @@ static struct WHOQueueEntry* getNextWHOQueueEntry(struct ClientSocket *client, i if(entry == client->whoqueue_last) { client->whoqueue_last = NULL; } - #ifdef HAVE_THREADS - entry->lock_tid = -1; - if(entry->lock_count) { - int i; - for(i = 0; i < entry->lock_count; i++) { - DESYNCHRONIZE(entry->lock_mutex); //unlock ALL - } - } - #endif } DESYNCHRONIZE(whohandler_sync); return entry; @@ -126,15 +107,6 @@ void clear_whoqueue(struct ClientSocket *client) { struct WHOQueueEntry *entry, *next; for(entry = client->whoqueue_first; entry; entry = next) { next = entry->next; - #ifdef HAVE_THREADS - entry->lock_tid = -1; - if(entry->lock_count) { - int i; - for(i = 0; i < entry->lock_count; i++) { - DESYNCHRONIZE(entry->lock_mutex); //unlock ALL - } - } - #endif free(entry); } client->whoqueue_last = NULL; @@ -142,21 +114,6 @@ void clear_whoqueue(struct ClientSocket *client) { DESYNCHRONIZE(whohandler_sync); } -#if HAVE_THREADS -void whohandler_end_of_recv(struct ClientSocket *client) { - SYNCHRONIZE(whohandler_sync); - unsigned long tid = syscall(SYS_gettid); - struct WHOQueueEntry *entry; - for(entry = client->whoqueue_first; entry; entry = entry->next) { - if(entry->lock_tid == tid) { - entry->lock_tid = 0; - DESYNCHRONIZE(entry->lock_mutex); - } - } - DESYNCHRONIZE(whohandler_sync); -} -#endif - void get_userlist(struct ChanNode *chan, userlist_callback_t callback, void *data) { struct ClientSocket *bot; for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) { @@ -286,13 +243,8 @@ static void _recv_whohandler_354(struct ClientSocket *client, char **argv, unsig if(entry == NULL) return; #ifdef HAVE_THREADS unsigned long tid = syscall(SYS_gettid); - if(entry->lock_tid != tid) { - entry->lock_count++; - SYNCHRONIZE(entry->lock_mutex); - if(entry->lock_tid == -1) { - return; //entry has been destroyed - } - entry->lock_tid = tid; + while(!clientsocket_parseorder_top(tid)) { + usleep(1000); //1ms } #endif if(entry->type & WHOQUEUETYPE_USERLIST) { @@ -327,9 +279,11 @@ static void _recv_whohandler_354(struct ClientSocket *client, char **argv, unsig struct UserNode *user = getUserByNick(argv[5]); struct ChanUser *chanuser; - if((chanuserflags & CHANUSERFLAG_INVISIBLE) && (!user || !isBot(user))) { - user = createTempUser(argv[5]); - user->flags |= USERFLAG_ISTMPUSER; + if((chanuserflags & CHANUSERFLAG_INVISIBLE)) { + if(!user) { + user = createTempUser(argv[5]); + user->flags |= USERFLAG_ISTMPUSER; + } chan->flags |= CHANFLAG_HAVE_INVISIBLES; chanuser = addInvisibleChanUser(chan, user); chanuser->flags = (chanuser->flags & ~CHANUSERFLAG_OPPED_OR_VOICED) | chanuserflags; @@ -385,13 +339,8 @@ static void _recv_whohandler_315(struct ClientSocket *client, char **argv, unsig if(entry == NULL) return; #ifdef HAVE_THREADS unsigned long tid = syscall(SYS_gettid); - if(entry->lock_tid != tid) { - entry->lock_count++; - SYNCHRONIZE(entry->lock_mutex); - if(entry->lock_tid == -1) { - return; //entry has been destroyed - } - entry->lock_tid = tid; + while(!clientsocket_parseorder_top(tid)) { + usleep(1000); //1ms } #endif getNextWHOQueueEntry(client, type, 1);