[Pvfs2-cvs] commit by slang in pvfs2/src/common/mgmt: pint-queue.c
CVS commit program
cvs at parl.clemson.edu
Thu Aug 14 18:11:16 EDT 2008
Update of /projects/cvsroot/pvfs2/src/common/mgmt
In directory parlweb1:/tmp/cvs-serv23717/src/common/mgmt
Modified Files:
Tag: directio-branch
pint-queue.c
Log Message:
fixes from Phil's comments for timeout values and cond signal/braodcast.
Index: pint-queue.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/common/mgmt/Attic/pint-queue.c,v
diff -p -u -r1.1.2.1 -r1.1.2.2
--- pint-queue.c 29 Jul 2008 22:48:56 -0000 1.1.2.1
+++ pint-queue.c 14 Aug 2008 22:11:16 -0000 1.1.2.2
@@ -419,8 +419,7 @@ int PINT_queue_wait_for_entry(PINT_queue
{
struct PINT_queue_s *queue;
int ret = 0, cond_ret = 0;
- struct timespec tv;
- struct timeval last, now;
+ struct timespec timeout;
ret = PINT_queue_search_and_remove(queue_id, find, user_ptr, entry);
if(0 == ret)
@@ -435,27 +434,13 @@ int PINT_queue_wait_for_entry(PINT_queue
queue = id_gen_fast_lookup(queue_id);
-
/* queue does not have entry, wait for signal of addition */
- gettimeofday(&last, NULL);
+ timeout = PINT_util_get_abs_timespec(microsecs);
do
{
- gettimeofday(&now, NULL);
- microsecs -= ((now.tv_sec * 1e6) + now.tv_usec -
- (last.tv_sec * 1e6) + last.tv_usec);
- if(microsecs <= 0)
- {
- cond_ret = ETIMEDOUT;
- break;
- }
-
- last = now;
- tv.tv_sec = (microsecs / 1e6);
- tv.tv_nsec = (microsecs - (tv.tv_sec * 1e6)) * 1e3;
-
gen_mutex_lock(&queue->mutex);
- cond_ret = gen_cond_timedwait(&queue->cond, &queue->mutex, &tv);
+ cond_ret = gen_cond_timedwait(&queue->cond, &queue->mutex, &timeout);
gen_mutex_unlock(&queue->mutex);
/* either the condition variable gets signalled, we have
@@ -498,8 +483,7 @@ int PINT_queue_timedwait(PINT_queue_id q
{
struct PINT_queue_s *queue;
int ret = 0;
- struct timespec tv;
- struct timeval last, now;
+ struct timespec timeout;
queue = id_gen_fast_lookup(queue_id);
@@ -515,24 +499,15 @@ int PINT_queue_timedwait(PINT_queue_id q
/* queue is empty, wait for signal of addition */
- gettimeofday(&last, NULL);
+ timeout = PINT_util_get_abs_timespec(microsecs);
do
{
- gettimeofday(&now, NULL);
- microsecs -= ((now.tv_sec * 1e6) + now.tv_usec -
- (last.tv_sec * 1e6) + last.tv_usec);
- if(microsecs < 0)
+ ret = gen_cond_timedwait(&queue->cond, &queue->mutex, &timeout);
+ if(ret == EINVAL)
{
- ret = ETIMEDOUT;
- break;
+ gossip_lerr("gen_cond_timedwait returned EINVAL!\n");
}
-
- last = now;
- tv.tv_sec = (microsecs / 1e6);
- tv.tv_nsec = (microsecs - (tv.tv_sec * 1e6)) * 1e3;
-
- ret = gen_cond_timedwait(&queue->cond, &queue->mutex, &tv);
/* either the condition variable gets signalled, we have
* a spurious wakeup, or the timeout was reached.
More information about the Pvfs2-cvs
mailing list