diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-03-29 23:43:54 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-03-29 23:43:54 +0000 |
commit | c8604fef7bb4043e36726d7eeaa6afd068012334 (patch) | |
tree | 01704d0c0a00ed61530cb1fcd840808ae6996531 /nuttx/sched/mq_timedsend.c | |
parent | 79749b135bef212fe96e7d17ade0bb65a14f8340 (diff) | |
download | px4-nuttx-c8604fef7bb4043e36726d7eeaa6afd068012334.tar.gz px4-nuttx-c8604fef7bb4043e36726d7eeaa6afd068012334.tar.bz2 px4-nuttx-c8604fef7bb4043e36726d7eeaa6afd068012334.zip |
Fix bugs detected by timed mqueue test.
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@178 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/mq_timedsend.c')
-rw-r--r-- | nuttx/sched/mq_timedsend.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/nuttx/sched/mq_timedsend.c b/nuttx/sched/mq_timedsend.c index a35edb9f8..05b7ea5d2 100644 --- a/nuttx/sched/mq_timedsend.c +++ b/nuttx/sched/mq_timedsend.c @@ -240,7 +240,6 @@ int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio, else { sint32 ticks; - int result; /* We are not in an interupt handler and the message queue is full. * set up a timed wait for the message queue to become non-full. @@ -249,7 +248,7 @@ int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio, * disabled here so that this time stays valid until the wait begins. */ - result = clock_abstime2ticks(CLOCK_REALTIME, abstime, &ticks); + int result = clock_abstime2ticks(CLOCK_REALTIME, abstime, &ticks); /* If the time has already expired and the message queue is empty, * return immediately. @@ -262,6 +261,14 @@ int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio, /* Handle any time-related errors */ + if (result != OK) + { + *get_errno_ptr() = result; + ret = ERROR; + } + + /* Start the watchdog and begin the wait for MQ not full */ + if (result == OK) { /* Start the watchdog */ @@ -270,7 +277,7 @@ int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio, /* And wait for the message queue to be non-empty */ - result = mq_waitsend(mqdes); + ret = mq_waitsend(mqdes); /* This may return with an error and errno set to either EINTR * or ETIMEOUT. Cancel the watchdog timer in any event. @@ -288,11 +295,7 @@ int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio, * the message structure. */ - if (result != OK) - { - *get_errno_ptr() = result; - } - else + if (ret == OK) { mqmsg = mq_msgalloc(); } @@ -305,7 +308,7 @@ int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio, if (mqmsg) { - /* Yes, peforrm the message send. */ + /* Yes, peform the message send. */ ret = mq_dosend(mqdes, mqmsg, msg, msglen, prio); } |