[openib-general] Re: [PATCH] uDAPL dapl_os_wait_object_wait()
Arlin Davis
ardavis at ichips.intel.com
Wed Aug 3 10:50:57 PDT 2005
James Lentini wrote:
>
>
> On Tue, 2 Aug 2005, Arlin Davis wrote:
>
>> James Lentini wrote:
>>
>>>
>>>
>>> On Mon, 25 Jul 2005, Arlin Davis wrote:
>>>
>>>> James,
>>>>
>>>> Here is a patch to fix dapl_os_wait_object_wait() returning
>>>> EINVAL when passing nsec == 1000000000 to pthread_cond_timedwait().
>>>> Hit a rare case where _microsecs was exactly 1000000.
>>>
>>>
>>>
>>> What was the timeout_val being passed to dapl_os_wait_object_wait()?
>>> Was it 1000000000 or 1000000?
>>
>>
>> It was the calculated time of microsecs that resulted in exactly
>> 1000000 (1 sec) not timeout_val..
>>
>
> I understand now. I think the code can be simplified further. Can you
> look over the patch below (and attached) and let me know if you see
> any problems?
No problems. Looks good.
>
> Index: dapl/udapl/linux/dapl_osd.c
> ===================================================================
> --- dapl/udapl/linux/dapl_osd.c (revision 2949)
> +++ dapl/udapl/linux/dapl_osd.c (working copy)
> @@ -241,17 +241,10 @@
> unsigned int microsecs;
>
> gettimeofday (&now, &tz);
> - microsecs = now.tv_usec + (timeout_val % 1000000);
> - if (microsecs > 1000000)
> - {
> - now.tv_sec = now.tv_sec + timeout_val / 1000000 + 1;
> - now.tv_usec = microsecs - 1000000;
> - }
> - else
> - {
> - now.tv_sec = now.tv_sec + timeout_val / 1000000;
> - now.tv_usec = microsecs;
> - }
> +#define USEC_PER_SEC 1000000
> + microsecs = now.tv_usec + timeout_val;
> + now.tv_sec = now.tv_sec + microsecs/USEC_PER_SEC;
> + now.tv_usec = microsecs % USEC_PER_SEC;
>
> /* Convert timeval to timespec */
> future.tv_sec = now.tv_sec;
>
>------------------------------------------------------------------------
>
>Index: dapl/udapl/linux/dapl_osd.c
>===================================================================
>--- dapl/udapl/linux/dapl_osd.c (revision 2949)
>+++ dapl/udapl/linux/dapl_osd.c (working copy)
>@@ -241,17 +241,10 @@
> unsigned int microsecs;
>
> gettimeofday (&now, &tz);
>- microsecs = now.tv_usec + (timeout_val % 1000000);
>- if (microsecs > 1000000)
>- {
>- now.tv_sec = now.tv_sec + timeout_val / 1000000 + 1;
>- now.tv_usec = microsecs - 1000000;
>- }
>- else
>- {
>- now.tv_sec = now.tv_sec + timeout_val / 1000000;
>- now.tv_usec = microsecs;
>- }
>+#define USEC_PER_SEC 1000000
>+ microsecs = now.tv_usec + timeout_val;
>+ now.tv_sec = now.tv_sec + microsecs/USEC_PER_SEC;
>+ now.tv_usec = microsecs % USEC_PER_SEC;
>
> /* Convert timeval to timespec */
> future.tv_sec = now.tv_sec;
>
>
More information about the general
mailing list