cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-1999181 ] CLOCK_MONOTONIC always fails on some systems

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Sat, 21 Jun 2008 20:19:34 +0000

Bugs item #1999181, was opened at 2008-06-21 00:29
Message generated for change (Comment added) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1999181&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: compile or build problem
Group: wrong behaviour
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: John Lightsey (jlightsey)
Assigned to: Daniel Stenberg (bagder)
Summary: CLOCK_MONOTONIC always fails on some systems

Initial Comment:
I've seen several Centos 3 i386 systems with this particular problem.

clock_gettime(CLOCK_MONOTONIC) compiles and links correctly, but at runtime it will always fail and return -1. This causes curl to timeout before opening a socket when creating a https connection.

verbose output:
root@centos3edge [~]# /opt/curlssl/bin/curl -G https://www.google.com -v
* About to connect() to www.google.com port 443 (#0)
* Connection time-out
* Closing connection #0
curl: (28) Connection time-out

The attached patch checks for broken CLOCK_MONOTONIC support at configure time so that curl will fallback on gettimeofday() on these systems.

----------------------------------------------------------------------

>Comment By: Daniel Stenberg (bagder)
Date: 2008-06-21 22:19

Message:
Logged In: YES
user_id=1110
Originator: NO

The monotonic clock support is "optional" according to that opengroup.org
page, so to me it seems that a POSIX-compliant OS can still fail at
run-time
even though clock_gettime is present.

Is the _POSIX_MONOTONIC_CLOCK mandatory for POSIX systems that implement
CLOCK_MONOTONIC? If not, I think a run-time check is unavoidable...

----------------------------------------------------------------------

Comment By: Yang Tse (yangtse)
Date: 2008-06-21 05:09

Message:
Logged In: YES
user_id=1590006
Originator: NO

I still maintain what I've said before. But...

It could also be possible that libcurl's configuration compilation check
should also be verifying definition of _POSIX_MONOTONIC_CLOCK.

Can you verify if the following patch improves the situation or if it does
not change ?

Index: acinclude.m4
===================================================================
RCS file: /cvsroot/curl/curl/acinclude.m4,v
retrieving revision 1.158
diff -u -r1.158 acinclude.m4
--- acinclude.m4 20 Jun 2008 18:09:48 -0000 1.158
+++ acinclude.m4 21 Jun 2008 02:57:58 -0000
@@ -1986,6 +1986,9 @@
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #ifdef TIME_WITH_SYS_TIME
@@ -1997,8 +2000,13 @@
 #endif
 #endif
     ]],[[
+#if !defined(CLOCK_MONOTONIC) || \
+ !defined(_POSIX_MONOTONIC_CLOCK) || (_POSIX_MONOTONIC_CLOCK < 0)
+ HAVE_CLOCK_GETTIME_MONOTONIC shall not be defined.
+#else
       struct timespec ts;
       (void)clock_gettime(CLOCK_MONOTONIC, &ts);
+#endif
     ]])
   ],[
     AC_MSG_RESULT([yes])

----------------------------------------------------------------------

Comment By: Yang Tse (yangtse)
Date: 2008-06-21 03:18

Message:
Logged In: YES
user_id=1590006
Originator: NO

My point of view...

Linking of libcurl using function clock_gettime() is only possible if the
system libraries actually provide an implementation of the clock_gettime(),
otherwise linking would fail and curl would not build.

Compilation of libcurl using function clock_gettime() and clock_id
CLOCK_MONOTONIC is only possible if the system header files provide both a
prototype for function clock_gettime() and the clock_id definition for
CLOCK_MONOTONIC, otherwise compilation would fail.

Both checks mentioned above are done at libcurl configuration time, and if
any of them fail libcurl will be configured to not use the clock_gettime()
function, and simply use gettimeofday().

If a system provides bogus information in its system header files relative
to the actual capabilities of its libraries implementation it is a system
library or system header file issue. No application will be capable of
building properly using that system. The OS provider can fix the header
files or fix the system library implementation. Or not fix it and expect
the rest of the world to workaround the system bugs.

It could also be possible that there is no problem on the OS provided
system header files and the OS provided system libraries. But it could
happen that someone could have 'ugraded' the system header files without
'upgrading' the system libraries creating and unexpected problem for any
application that is built on that 'unbalanced' system.

The IEEE and The Open Group [1] are very clear at this point. The
clock_gettime() function shall fail if the clock_id argument does not
specify a known clock.

From what you are describing the system header files do define a clock_id
for CLOCK_MONOTONIC, that implies that the system headers _know_ the
CLOCK_MONOTONIC clock, but later on the system libraries do not _know_ it
and fail at runtime.

Could you verify/discard if its just an accidental mismatch between system
libraries and header files ?

If not, then, could you provide further information on which system
library version and provider has the problem ? And if it has already been
fixed in a further version ? Or a pointer to the bug/fix record ?

[1]
http://www.opengroup.org/onlinepubs/009695399/functions/clock_getres.html

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1999181&group_id=976
Received on 2008-06-21

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET