[rtems commit] mw_uid: corrects uid_read_message short timeouts
Gedare Bloom
gedare at rtems.org
Thu Jan 9 15:03:58 UTC 2014
Module: rtems
Branch: master
Commit: 66bf2cc9095feb424eadbe1018f704d13a026e5d
Changeset: http://git.rtems.org/rtems/commit/?id=66bf2cc9095feb424eadbe1018f704d13a026e5d
Author: Allan Hessenflow <allanh at kallisti.com>
Date: Wed Dec 18 18:54:53 2013 -0600
mw_uid: corrects uid_read_message short timeouts
---
cpukit/libmisc/fb/mw_uid.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/cpukit/libmisc/fb/mw_uid.c b/cpukit/libmisc/fb/mw_uid.c
index cb138dc..a911e09 100644
--- a/cpukit/libmisc/fb/mw_uid.c
+++ b/cpukit/libmisc/fb/mw_uid.c
@@ -90,15 +90,24 @@ int uid_read_message( struct MW_UID_MESSAGE *m, unsigned long timeout )
{
rtems_status_code status;
size_t size = 0;
- unsigned long micro_secs = timeout*1000;
int wait = (timeout != 0);
+ int ticks = RTEMS_MICROSECONDS_TO_TICKS(timeout * 1000);
+
+ if (timeout == (unsigned long) -1) {
+ ticks = RTEMS_NO_TIMEOUT;
+ } else if (timeout && ticks == 0) {
+ /* if timeout greater than 0 and smaller than a tick, round up to avoid
+ * unintentionally RTEMS_NO_TIMEOUT
+ */
+ ticks = 1;
+ }
status = rtems_message_queue_receive(
queue_id,
(void*)m,
&size,
wait ? RTEMS_WAIT : RTEMS_NO_WAIT,
- RTEMS_MICROSECONDS_TO_TICKS(micro_secs)
+ ticks
);
if( status == RTEMS_SUCCESSFUL ) {
More information about the vc
mailing list