I use libs3 w/pthreads in my app, and was seeing frequent requests whose time was Jan 1, 1970. After some digging I found that it's using a stdlib routine which is not thread safe to grab the time. Replacing w/a thread-safe version fixes the multithreaded case and works fine for single-threaded as well. The commit message is below.
Thanks,
-Earle F. Philhower, III
gmtime() is used to convert the system time to GMT so that the S3
request time can be appended to the headers. It returns a pointer
to a library static struct tm. This works fine in the single-
threaded case, but can cause request times to be corrupted should
libs3 be called in a multithreaded use case.
Replaces the gmtime() with a gmtime_r() call which takes a pointer
to a thread-local struct tm, fixing the issue.
Howdy,
I use libs3 w/pthreads in my app, and was seeing frequent requests whose time was Jan 1, 1970. After some digging I found that it's using a stdlib routine which is not thread safe to grab the time. Replacing w/a thread-safe version fixes the multithreaded case and works fine for single-threaded as well. The commit message is below.
Thanks, -Earle F. Philhower, III
gmtime() is used to convert the system time to GMT so that the S3 request time can be appended to the headers. It returns a pointer to a library static struct tm. This works fine in the single- threaded case, but can cause request times to be corrupted should libs3 be called in a multithreaded use case.
Replaces the gmtime() with a gmtime_r() call which takes a pointer to a thread-local struct tm, fixing the issue.