- API: use localtime_r() instead of localtime()

svn path=/trunk/boinc/; revision=22784
This commit is contained in:
David Anderson 2010-12-01 18:04:18 +00:00
parent 3fa1f8d94d
commit 556e319ca1
5 changed files with 42 additions and 21 deletions

View File

@ -195,35 +195,32 @@ static int start_worker_signals();
char* boinc_msg_prefix(char* sbuf, int len) {
char buf[256];
struct tm* tm;
struct tm tm;
int n;
time_t x = time(0);
if(x == (time_t)-1) {
*sbuf='\0'; // make sure there is a valid (empty) string returned
if (x == -1) {
strcpy(sbuf, "time() failed");
return sbuf;
}
if(!(tm = localtime(&x))) {
*sbuf='\0'; // make sure there is a valid (empty) string returned
if (localtime_r(&x, &tm) == NULL) {
strcpy(sbuf, "localtime() failed");
return sbuf;
}
if(!strftime(buf, sizeof(buf)-1, "%H:%M:%S", tm)) {
*sbuf='\0'; // make sure there is a valid (empty) string returned
if (strftime(buf, sizeof(buf)-1, "%H:%M:%S", &tm) == 0) {
strcpy(sbuf, "strftime() failed");
return sbuf;
}
#ifdef _WIN32
if(_snprintf(sbuf, len, "%s (%d):", buf, GetCurrentProcessId()) < 0)
n = _snprintf(sbuf, len, "%s (%d):", buf, GetCurrentProcessId());
#else
if(snprintf(sbuf, len, "%s (%d):", buf, getpid()) < 0)
n = snprintf(sbuf, len, "%s (%d):", buf, getpid());
#endif
{
*sbuf='\0'; // make sure there is a valid (empty) string returned
if (n < 0) {
strcpy(sbuf, "sprintf() failed");
return sbuf;
}
sbuf[len-1] = '\0'; // just in case
}
sbuf[len-1] = 0; // just in case
return sbuf;
}

View File

@ -8531,3 +8531,12 @@ Rom 01 Dec 2010
clientgui/
sg_StatImageLoader.cpp
David 1 Dec 2010
- API: use localtime_r() instead of localtime()
api/
boinc_api.cpp
client/
acct_mgr_cpp
client_types.h

View File

@ -74,9 +74,7 @@ int ACCT_MGR_OP::do_rpc(
boinc_delete_file(ACCT_MGR_LOGIN_FILENAME);
error_num = 0;
for (i=0; i<gstate.projects.size(); i++) {
PROJECT* p = gstate.projects[i];
p->attached_via_acct_mgr = false;
p->ams_resource_share = -1;
gstate.projects[i]->detach_ams();
}
return 0;
}

View File

@ -235,7 +235,14 @@ struct PROJECT : PROJ_AM {
bool no_cuda_apps;
bool no_ati_apps;
// the following are from the account manager, if any
//
bool no_cpu_ams;
bool no_cuda_ams;
bool no_ati_ams;
// the following set dynamically
//
bool cuda_defer_sched;
// This project has a CUDA job for which there's insuff. video RAM.
// Don't fetch more CUDA jobs; they might have same problem
@ -455,6 +462,15 @@ struct PROJECT : PROJ_AM {
void abort_not_started();
// abort unstarted jobs
// clear AMS-related fields
inline void detach_ams() {
attached_via_acct_mgr = false;
ams_resource_share = -1;
no_cpu_ams = false;
no_cuda_ams = false;
no_ati_ams = false;
}
#ifdef SIM
RANDOM_PROCESS available;
int index;

View File

@ -4,6 +4,7 @@
BOINC_DIR = ../..
BOINC_API_DIR = $(BOINC_DIR)/api
BOINC_LIB_DIR = $(BOINC_DIR)/lib
RAPPTURE_DIR = ~/rappture/rappture/src/core
CXXFLAGS = -g \
-I$(BOINC_DIR) \