server: Make add_timeout() operate on an unsigned timeout value

Dmitry Timoshkov dmitry at codeweavers.com
Mon Jul 17 05:43:45 CDT 2006


Hello,

if you add CursorBlinkRate=-1 to the [windows] section of win.ini in order
to stop cursor blinking the cursor still blinks when you move mouse. That
bug is caused by the fact that server/fd.c,add_timeout() takes a signed
timeout variable. As far as I can see there is no a special meaning for
negative timeout values in the server code, and most timeout variables
are already unsigned, so I've changed the callers of add_timeout() to use
unsigned values.

Changelog:
    server: Make add_timeout() operate on an unsigned timeout value, fix
    the callers to accommodate the change.

diff -up cvs/hq/wine/dlls/ntdll/sync.c wine/dlls/ntdll/sync.c
--- cvs/hq/wine/dlls/ntdll/sync.c	2006-05-24 13:16:16.000000000 +0900
+++ wine/dlls/ntdll/sync.c	2006-07-17 19:07:24.000000000 +0900
@@ -478,7 +478,7 @@ NTSTATUS WINAPI NtSetTimer(IN HANDLE han
 
     SERVER_START_REQ( set_timer )
     {
-        if (!when->u.LowPart && !when->u.HighPart)
+        if (!when->QuadPart)
         {
             /* special case to start timeout on now+period without too many calculations */
             req->expire.sec  = 0;
diff -up cvs/hq/wine/dlls/user/message.c wine/dlls/user/message.c
--- cvs/hq/wine/dlls/user/message.c	2006-07-03 15:48:29.000000000 +0900
+++ wine/dlls/user/message.c	2006-07-17 18:56:53.000000000 +0900
@@ -2160,8 +2160,8 @@ static void wait_message_reply( UINT fla
 static BOOL put_message_in_queue( const struct send_message_info *info, size_t *reply_size )
 {
     struct packed_message data;
-    unsigned int res;
-    int i, timeout = 0;
+    unsigned int res, timeout = 0;
+    int i;
 
     /* Check for INFINITE timeout for compatibility with Win9x,
      * although Windows >= NT does not do so
diff -up cvs/hq/wine/server/fd.c wine/server/fd.c
--- cvs/hq/wine/server/fd.c	2006-06-16 15:44:39.000000000 +0900
+++ wine/server/fd.c	2006-07-17 19:24:49.000000000 +0900
@@ -329,7 +329,7 @@ void remove_timeout_user( struct timeout
 }
 
 /* add a timeout in milliseconds to an absolute time */
-void add_timeout( struct timeval *when, int timeout )
+void add_timeout( struct timeval *when, unsigned int timeout )
 {
     if (timeout)
     {
@@ -1116,7 +1116,7 @@ static void async_callback(void *private
 }
 
 /* create an async on a given queue of a fd */
-struct async *create_async(struct thread *thread, int* timeout, struct list *queue,
+struct async *create_async(struct thread *thread, unsigned int *timeout, struct list *queue,
                            void *io_apc, void *io_user, void* io_sb)
 {
     struct async *async = mem_alloc( sizeof(struct async) );
@@ -1583,7 +1583,7 @@ void default_poll_event( struct fd *fd, 
     wake_up( fd->user, 0 );
 }
 
-void fd_queue_async_timeout( struct fd *fd, void *apc, void *user, void *io_sb, int type, int count, int *timeout )
+void fd_queue_async_timeout( struct fd *fd, void *apc, void *user, void *io_sb, int type, int count, unsigned int *timeout )
 {
     struct list *queue;
     int events;
diff -up cvs/hq/wine/server/file.h wine/server/file.h
--- cvs/hq/wine/server/file.h	2006-05-24 13:17:03.000000000 +0900
+++ wine/server/file.h	2006-07-17 18:47:39.000000000 +0900
@@ -66,7 +66,7 @@ extern void default_fd_remove_queue( str
 extern int default_fd_signaled( struct object *obj, struct thread *thread );
 extern int default_fd_get_poll_events( struct fd *fd );
 extern void default_poll_event( struct fd *fd, int event );
-extern void fd_queue_async_timeout( struct fd *fd, void *apc, void *user, void *io_sb, int type, int count, int *timeout );
+extern void fd_queue_async_timeout( struct fd *fd, void *apc, void *user, void *io_sb, int type, int count, unsigned int *timeout );
 extern void default_fd_queue_async( struct fd *fd, void *apc, void *user, void *io_sb, int type, int count );
 extern void default_fd_cancel_async( struct fd *fd );
 extern int no_flush( struct fd *fd, struct event **event );
@@ -87,7 +87,7 @@ typedef void (*timeout_callback)( void *
 extern struct timeout_user *add_timeout_user( const struct timeval *when,
                                               timeout_callback func, void *private );
 extern void remove_timeout_user( struct timeout_user *user );
-extern void add_timeout( struct timeval *when, int timeout );
+extern void add_timeout( struct timeval *when, unsigned int timeout );
 /* return 1 if t1 is before t2 */
 static inline int time_before( const struct timeval *t1, const struct timeval *t2 )
 {
@@ -117,7 +117,7 @@ extern int is_serial_fd( struct fd *fd )
 extern struct object *create_serial( struct fd *fd, unsigned int options );
 
 /* async I/O functions */
-extern struct async *create_async( struct thread *thread, int* timeout,
+extern struct async *create_async( struct thread *thread, unsigned int *timeout,
                                    struct list *queue, void *, void *, void *);
 extern void async_terminate_head( struct list *queue, int status );
 
diff -up cvs/hq/wine/server/mailslot.c wine/server/mailslot.c
--- cvs/hq/wine/server/mailslot.c	2006-05-24 13:17:03.000000000 +0900
+++ wine/server/mailslot.c	2006-07-17 19:09:45.000000000 +0900
@@ -58,7 +58,7 @@ struct mailslot
     struct fd          *fd;
     struct fd          *write_fd;
     unsigned int        max_msgsize;
-    int                 read_timeout;
+    unsigned int        read_timeout;
     struct list         writers;
 };
 
@@ -249,7 +249,7 @@ static void mailslot_queue_async( struct
                                   void *iosb, int type, int count )
 {
     struct mailslot *mailslot = get_fd_user( fd );
-    int *timeout = NULL;
+    unsigned int *timeout = NULL;
 
     assert(mailslot->obj.ops == &mailslot_ops);
 
@@ -266,7 +266,7 @@ static void mailslot_queue_async( struct
         return;
     }
 
-    if (mailslot->read_timeout != -1) timeout = &mailslot->read_timeout;
+    if (mailslot->read_timeout != INFINITE) timeout = &mailslot->read_timeout;
 
     fd_queue_async_timeout( fd, apc, user, iosb, type, count, timeout );
 }
diff -up cvs/hq/wine/server/named_pipe.c wine/server/named_pipe.c
--- cvs/hq/wine/server/named_pipe.c	2006-06-10 18:45:32.000000000 +0900
+++ wine/server/named_pipe.c	2006-07-17 18:39:49.000000000 +0900
@@ -868,7 +868,8 @@ DECL_HANDLER(wait_named_pipe)
     }
     else
     {
-        int timeout;
+        unsigned int timeout;
+
         if (req->timeout == NMPWAIT_USE_DEFAULT_WAIT)
             timeout = pipe->timeout;
         else
diff -up cvs/hq/wine/server/protocol.def wine/server/protocol.def
--- cvs/hq/wine/server/protocol.def	2006-07-13 12:50:44.000000000 +0900
+++ wine/server/protocol.def	2006-07-17 19:03:53.000000000 +0900
@@ -1407,7 +1407,7 @@ enum char_info_mode
 @REQ(set_timer)
     obj_handle_t handle;        /* handle to the timer */
     abs_time_t   expire;        /* next expiration absolute time */
-    int          period;        /* timer period in ms */
+    unsigned int period;        /* timer period in ms */
     void*        callback;      /* callback function */
     void*        arg;           /* callback argument */
 @REPLY
@@ -1572,7 +1572,7 @@ enum char_info_mode
     int             y;         /* y position */
     unsigned int    time;      /* message time */
     unsigned int    info;      /* extra info */
-    int             timeout;   /* timeout for reply */
+    unsigned int    timeout;   /* timeout for reply */
     void*           callback;  /* callback address */
     VARARG(data,bytes);        /* message data for sent messages */
 @END
diff -up cvs/hq/wine/server/queue.c wine/server/queue.c
--- cvs/hq/wine/server/queue.c	2006-07-13 12:50:44.000000000 +0900
+++ wine/server/queue.c	2006-07-17 19:18:43.000000000 +0900
@@ -519,7 +519,7 @@ static void result_timeout( void *privat
 /* allocate and fill a message result structure */
 static struct message_result *alloc_message_result( struct msg_queue *send_queue,
                                                     struct msg_queue *recv_queue,
-                                                    struct message *msg, int timeout,
+                                                    struct message *msg, unsigned int timeout,
                                                     void *callback, unsigned int callback_data )
 {
     struct message_result *result = mem_alloc( sizeof(*result) );
diff -up cvs/hq/wine/server/registry.c wine/server/registry.c
--- cvs/hq/wine/server/registry.c	2006-07-11 18:15:37.000000000 +0900
+++ wine/server/registry.c	2006-07-17 19:00:03.000000000 +0900
@@ -103,7 +103,7 @@ struct key_value
 /* the root of the registry tree */
 static struct key *root_key;
 
-static const int save_period = 30000;           /* delay between periodic saves (in ms) */
+static const unsigned int save_period = 30000;  /* delay between periodic saves (in ms) */
 static struct timeout_user *save_timeout_user;  /* saving timer */
 
 static void set_periodic_save_timer(void);
diff -up cvs/hq/wine/server/serial.c wine/server/serial.c
--- cvs/hq/wine/server/serial.c	2006-05-24 13:17:03.000000000 +0900
+++ wine/server/serial.c	2006-07-17 18:44:09.000000000 +0900
@@ -246,7 +246,7 @@ static void serial_queue_async( struct f
 {
     struct serial *serial = get_fd_user( fd );
     struct list *queue;
-    int timeout;
+    unsigned int timeout;
     int events;
 
     assert(serial->obj.ops == &serial_ops);
diff -up cvs/hq/wine/server/timer.c wine/server/timer.c
--- cvs/hq/wine/server/timer.c	2006-05-24 13:17:03.000000000 +0900
+++ wine/server/timer.c	2006-07-17 19:03:00.000000000 +0900
@@ -42,7 +42,7 @@ struct timer
     struct object        obj;       /* object header */
     int                  manual;    /* manual reset */
     int                  signaled;  /* current signaled state */
-    int                  period;    /* timer period in ms */
+    unsigned int         period;    /* timer period in ms */
     struct timeval       when;      /* next expiration */
     struct timeout_user *timeout;   /* timeout user */
     struct thread       *thread;    /* thread that set the APC function */
@@ -144,8 +144,8 @@ static int cancel_timer( struct timer *t
 }
 
 /* set the timer expiration and period */
-static int set_timer( struct timer *timer, const abs_time_t *expire, int period,
-                      void *callback, void *arg )
+static int set_timer( struct timer *timer, const abs_time_t *expire,
+                      unsigned int period, void *callback, void *arg )
 {
     int signaled = cancel_timer( timer );
     if (timer->manual)





More information about the wine-patches mailing list