mirror of https://github.com/debauchee/barrier.git
checkpoint. automake changes for reentrant functions.
This commit is contained in:
parent
9c7e863d77
commit
8a103ce63c
|
@ -45,6 +45,8 @@ dnl AC_TYPE_SIGNAL
|
|||
dnl AC_FUNC_FORK
|
||||
AC_FUNC_MEMCMP
|
||||
AC_FUNC_STRFTIME
|
||||
AC_CHECK_FUNCS(gmtime_r)
|
||||
AC_CHECK_FUNCS(getpwuid_r)
|
||||
dnl use AC_REPLACE_FUNCS() for stuff in string.h
|
||||
dnl AC_HEADER_SYS_WAIT
|
||||
|
||||
|
|
|
@ -273,14 +273,18 @@ CHTTPProtocol::reply(IOutputStream* stream, CHTTPReply& reply)
|
|||
// get date
|
||||
// FIXME -- should use C++ locale stuff but VC++ time_put is broken.
|
||||
// FIXME -- double check that VC++ is broken
|
||||
// FIXME -- should mutex gmtime() since the return value may not
|
||||
// be thread safe
|
||||
char date[30];
|
||||
{
|
||||
const char* oldLocale = setlocale(LC_TIME, "C");
|
||||
time_t t = time(NULL);
|
||||
struct tm* tm = gmtime(&t);
|
||||
strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S GMT", tm);
|
||||
#if HAVE_GMTIME_R
|
||||
struct tm tm;
|
||||
struct tm* tmp = &tm;
|
||||
gmtime_r(&t, tmp);
|
||||
#else
|
||||
struct tm* tmp = gmtime(&t);
|
||||
#endif
|
||||
strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S GMT", tmp);
|
||||
setlocale(LC_TIME, oldLocale);
|
||||
}
|
||||
|
||||
|
|
|
@ -161,10 +161,18 @@ CUnixPlatform::getBasename(const char* pathname) const
|
|||
CString
|
||||
CUnixPlatform::getUserDirectory() const
|
||||
{
|
||||
// FIXME -- use geteuid? shouldn't run this setuid anyway.
|
||||
struct passwd* pwent = getpwuid(getuid());
|
||||
if (pwent != NULL && pwent->pw_dir != NULL) {
|
||||
return pwent->pw_dir;
|
||||
#if HAVE_GETPWUID_R
|
||||
struct passwd pwent;
|
||||
struct passwd* pwentp;
|
||||
long size = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||||
char* buffer = new char[size];
|
||||
getpwuid_r(getuid(), &pwent, buffer, size, &pwentp);
|
||||
delete[] buffer;
|
||||
#else
|
||||
struct passwd* pwentp = getpwuid(getuid());
|
||||
#endif
|
||||
if (pwentp != NULL && pwentp->pw_dir != NULL) {
|
||||
return pwentp->pw_dir;
|
||||
}
|
||||
else {
|
||||
return CString();
|
||||
|
|
Loading…
Reference in New Issue