server: Make timer id allocation algorithm conform to the Windows one

Dmitry Timoshkov dmitry at codeweavers.com
Tue Nov 13 06:41:01 CST 2007


Hello,

this patch should fix the problem reported in the bug 10343. My test which
calls SetTimer in an infinite loop shows that XP starts to allocate timer ids
at 0x7fff and goes backwards to 0x101, then restarts from 0x7fff.

Changelog:
    server: Make timer id allocation algorithm conform to the Windows one.
---
 server/queue.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/queue.c b/server/queue.c
index 51315fd..f6d6ca4 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -269,7 +269,7 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_
         queue->paint_count     = 0;
         queue->quit_message    = 0;
         queue->recv_result     = NULL;
-        queue->next_timer_id   = 1;
+        queue->next_timer_id   = 0x7fff;
         queue->timeout         = NULL;
         queue->input           = (struct thread_input *)grab_object( input );
         queue->hooks           = NULL;
@@ -1950,7 +1950,7 @@ DECL_HANDLER(set_win_timer)
             do
             {
                 id = queue->next_timer_id;
-                if (++queue->next_timer_id >= 0x10000) queue->next_timer_id = 1;
+                if (--queue->next_timer_id <= 0x100) queue->next_timer_id = 0x7fff;
             }
             while (find_timer( queue, 0, req->msg, id ));
         }
-- 
1.5.3.4






More information about the wine-patches mailing list