Ticket #1428: mw_uid.patch

File mw_uid.patch, 1.6 KB (added by Allan Hessenflow, on Jun 19, 2009 at 11:57:33 PM)

corrects uid_read_message short timeouts

Line 
1Index: cpukit/libmisc/mw-fb/mw_uid.c
2===================================================================
3RCS file: /usr1/CVS/rtems/cpukit/libmisc/mw-fb/mw_uid.c,v
4retrieving revision 1.11
5diff -c -3 -p -r1.11 mw_uid.c
6*** cpukit/libmisc/mw-fb/mw_uid.c       2 Jan 2009 13:01:21 -0000       1.11
7--- cpukit/libmisc/mw-fb/mw_uid.c       20 Jun 2009 00:43:57 -0000
8*************** int uid_read_message( struct MW_UID_MESS
9*** 86,99 ****
10  {
11    rtems_status_code status;
12    size_t            size = 0;
13-   unsigned long micro_secs = timeout*1000;
14    int wait = ( timeout != 0 );
15 
16    status = rtems_message_queue_receive( queue_id,
17                                         (void*)m,
18                                         &size,
19                                         wait ? RTEMS_WAIT : RTEMS_NO_WAIT,
20!                                        RTEMS_MICROSECONDS_TO_TICKS(micro_secs));
21 
22    if( status == RTEMS_SUCCESSFUL )
23    {
24--- 86,105 ----
25  {
26    rtems_status_code status;
27    size_t            size = 0;
28    int wait = ( timeout != 0 );
29+   int ticks = RTEMS_MICROSECONDS_TO_TICKS(timeout * 1000);
30 
31+   if (timeout == (unsigned long) -1)
32+     ticks = RTEMS_NO_TIMEOUT;
33+   else if (timeout && ticks == 0)
34+     /* if timeout greater than 0 and smaller than a tick, round up to avoid
35+        unintentionally RTEMS_NO_TIMEOUT */
36+     ticks = 1;
37    status = rtems_message_queue_receive( queue_id,
38                                         (void*)m,
39                                         &size,
40                                         wait ? RTEMS_WAIT : RTEMS_NO_WAIT,
41!                                        ticks);
42 
43    if( status == RTEMS_SUCCESSFUL )
44    {