1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-10 23:08:07 +00:00

Get rid of the flaky time_lock and use the thread safe localtime_r instead.

This commit is contained in:
Con Kolivas 2011-07-11 22:45:19 +10:00
parent c836b5bf01
commit 43ef5f5d3f
3 changed files with 2 additions and 9 deletions

3
main.c
View File

@ -153,7 +153,6 @@ static int work_thr_id;
int longpoll_thr_id;
static int stage_thr_id;
struct work_restart *work_restart = NULL;
pthread_mutex_t time_lock;
static pthread_mutex_t hash_lock;
static pthread_mutex_t qd_lock;
static pthread_mutex_t stgd_lock;
@ -1740,8 +1739,6 @@ int main (int argc, char *argv[])
unsigned int i, j = 0;
char name[32];
if (unlikely(pthread_mutex_init(&time_lock, NULL)))
return 1;
if (unlikely(pthread_mutex_init(&hash_lock, NULL)))
return 1;
if (unlikely(pthread_mutex_init(&qd_lock, NULL)))

View File

@ -226,7 +226,6 @@ struct work_restart {
char padding[128 - sizeof(unsigned long)];
};
extern pthread_mutex_t time_lock;
extern int hw_errors;
extern bool use_syslog;
extern struct thr_info *thr_info;

7
util.c
View File

@ -71,14 +71,11 @@ void vapplog(int prio, const char *fmt, va_list ap)
char *f;
int len;
struct timeval tv = { };
struct tm tm, *tm_p;
struct tm tm;
gettimeofday(&tv, NULL);
pthread_mutex_lock(&time_lock);
tm_p = localtime(&tv.tv_sec);
memcpy(&tm, tm_p, sizeof(tm));
pthread_mutex_unlock(&time_lock);
localtime_r(&tv.tv_sec, &tm);
len = 40 + strlen(fmt) + 2;
f = alloca(len);