mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-08 22:08:02 +00:00
Replace all references to the old n*sleep functions with the equivalent cgsleep_*s replacements.
This commit is contained in:
parent
7d448cd754
commit
eeac9d81fc
2
adl.c
2
adl.c
@ -1399,7 +1399,7 @@ updated:
|
||||
clear_logwin();
|
||||
return;
|
||||
}
|
||||
nmsleep(1000);
|
||||
cgsleep_ms(1000);
|
||||
goto updated;
|
||||
}
|
||||
#endif
|
||||
|
4
api.c
4
api.c
@ -4317,7 +4317,7 @@ void api(int api_thr_id)
|
||||
|
||||
/* This should be done before curl in needed
|
||||
* to ensure curl has already called WSAStartup() in windows */
|
||||
nmsleep(opt_log_interval*1000);
|
||||
cgsleep_ms(opt_log_interval*1000);
|
||||
|
||||
*apisock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (*apisock == INVSOCK) {
|
||||
@ -4363,7 +4363,7 @@ void api(int api_thr_id)
|
||||
break;
|
||||
else {
|
||||
applog(LOG_WARNING, "API bind to port %d failed - trying again in 30sec", port);
|
||||
nmsleep(30000);
|
||||
cgsleep_ms(30000);
|
||||
}
|
||||
} else
|
||||
bound = 1;
|
||||
|
24
cgminer.c
24
cgminer.c
@ -2592,7 +2592,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
|
||||
}
|
||||
applog(LOG_WARNING, "Pool %d communication failure, caching submissions", pool->pool_no);
|
||||
}
|
||||
nmsleep(5000);
|
||||
cgsleep_ms(5000);
|
||||
goto out;
|
||||
} else if (pool_tclear(pool, &pool->submit_fail))
|
||||
applog(LOG_WARNING, "Pool %d communication resumed, submitting work", pool->pool_no);
|
||||
@ -5057,7 +5057,7 @@ static void *stratum_rthread(void *userdata)
|
||||
while (!restart_stratum(pool)) {
|
||||
if (pool->removed)
|
||||
goto out;
|
||||
nmsleep(30000);
|
||||
cgsleep_ms(30000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5097,7 +5097,7 @@ static void *stratum_rthread(void *userdata)
|
||||
while (!restart_stratum(pool)) {
|
||||
if (pool->removed)
|
||||
goto out;
|
||||
nmsleep(30000);
|
||||
cgsleep_ms(30000);
|
||||
}
|
||||
stratum_resumed(pool);
|
||||
continue;
|
||||
@ -6314,7 +6314,7 @@ retry_pool:
|
||||
if (!pool) {
|
||||
applog(LOG_WARNING, "No suitable long-poll found for %s", cp->rpc_url);
|
||||
while (!pool) {
|
||||
nmsleep(60000);
|
||||
cgsleep_ms(60000);
|
||||
pool = select_longpoll_pool(cp);
|
||||
}
|
||||
}
|
||||
@ -6390,7 +6390,7 @@ retry_pool:
|
||||
continue;
|
||||
if (failures == 1)
|
||||
applog(LOG_WARNING, "longpoll failed for %s, retrying every 30s", lp_url);
|
||||
nmsleep(30000);
|
||||
cgsleep_ms(30000);
|
||||
}
|
||||
|
||||
if (pool != cp) {
|
||||
@ -6502,7 +6502,7 @@ static void *watchpool_thread(void __maybe_unused *userdata)
|
||||
switch_pools(NULL);
|
||||
}
|
||||
|
||||
nmsleep(30000);
|
||||
cgsleep_ms(30000);
|
||||
|
||||
}
|
||||
return NULL;
|
||||
@ -7329,13 +7329,13 @@ static void *hotplug_thread(void __maybe_unused *userdata)
|
||||
|
||||
hotplug_mode = true;
|
||||
|
||||
nmsleep(5000);
|
||||
cgsleep_ms(5000);
|
||||
|
||||
while (0x2a) {
|
||||
// Version 0.1 just add the devices on - worry about using nodev later
|
||||
|
||||
if (hotplug_time == 0)
|
||||
nmsleep(5000);
|
||||
cgsleep_ms(5000);
|
||||
else {
|
||||
new_devices = 0;
|
||||
new_threads = 0;
|
||||
@ -7364,7 +7364,7 @@ static void *hotplug_thread(void __maybe_unused *userdata)
|
||||
hotplug_process();
|
||||
|
||||
// hotplug_time >0 && <=9999
|
||||
nmsleep(hotplug_time * 1000);
|
||||
cgsleep_ms(hotplug_time * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7919,7 +7919,7 @@ retry:
|
||||
while (!pool->stratum_active || !pool->stratum_notify) {
|
||||
struct pool *altpool = select_pool(true);
|
||||
|
||||
nmsleep(5000);
|
||||
cgsleep_ms(5000);
|
||||
if (altpool != pool) {
|
||||
pool = altpool;
|
||||
goto retry;
|
||||
@ -7935,7 +7935,7 @@ retry:
|
||||
while (pool->idle) {
|
||||
struct pool *altpool = select_pool(true);
|
||||
|
||||
nmsleep(5000);
|
||||
cgsleep_ms(5000);
|
||||
if (altpool != pool) {
|
||||
pool = altpool;
|
||||
goto retry;
|
||||
@ -7969,7 +7969,7 @@ retry:
|
||||
* requests but is up as we'll keep hammering it */
|
||||
if (++pool->seq_getfails > mining_threads + opt_queue)
|
||||
pool_died(pool);
|
||||
nmsleep(5000);
|
||||
cgsleep_ms(5000);
|
||||
push_curl_entry(ce, pool);
|
||||
pool = select_pool(!opt_fail_only);
|
||||
goto retry;
|
||||
|
@ -227,7 +227,7 @@ static bool avalon_decode_nonce(struct thr_info *thr, struct cgpu_info *avalon,
|
||||
static void wait_avalon_ready(struct cgpu_info *avalon)
|
||||
{
|
||||
while (avalon_buffer_full(avalon)) {
|
||||
nmsleep(40);
|
||||
cgsleep_ms(40);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1048,7 +1048,7 @@ static void *avalon_send_tasks(void *userdata)
|
||||
int64_t us_timeout;
|
||||
|
||||
while (avalon_buffer_full(avalon))
|
||||
nmsleep(40);
|
||||
cgsleep_ms(40);
|
||||
|
||||
avalon_adjust_freq(info, avalon);
|
||||
|
||||
@ -1133,14 +1133,14 @@ static void *bitburner_send_tasks(void *userdata)
|
||||
bool idled = false;
|
||||
|
||||
while (avalon_buffer_full(avalon))
|
||||
nmsleep(40);
|
||||
cgsleep_ms(40);
|
||||
|
||||
avalon_adjust_freq(info, avalon);
|
||||
|
||||
/* Give other threads a chance to acquire qlock. */
|
||||
i = 0;
|
||||
do {
|
||||
nmsleep(40);
|
||||
cgsleep_ms(40);
|
||||
} while (!avalon->shutdown && i++ < 15
|
||||
&& avalon->queued < avalon_get_work_count);
|
||||
|
||||
@ -1149,7 +1149,7 @@ static void *bitburner_send_tasks(void *userdata)
|
||||
end_count = start_count + avalon_get_work_count;
|
||||
for (i = start_count, j = 0; i < end_count; i++, j++) {
|
||||
while (avalon_buffer_full(avalon))
|
||||
nmsleep(40);
|
||||
cgsleep_ms(40);
|
||||
|
||||
if (likely(j < avalon->queued && !info->overheat && avalon->works[i])) {
|
||||
avalon_init_task(&at, 0, 0, info->fan_pwm,
|
||||
|
@ -734,7 +734,7 @@ reinit:
|
||||
applog(LOG_WARNING, "%s detect (%s) 2nd init failed (%d:%d) - retrying",
|
||||
bflsc->drv->dname, bflsc->device_path, amount, err);
|
||||
}
|
||||
nmsleep(init_sleep);
|
||||
cgsleep_ms(init_sleep);
|
||||
if ((init_sleep * 2) <= REINIT_TIME_MAX_MS)
|
||||
init_sleep *= 2;
|
||||
goto reinit;
|
||||
@ -783,7 +783,7 @@ reinit:
|
||||
if (++tries > 2)
|
||||
goto unshin;
|
||||
|
||||
nmsleep(40);
|
||||
cgsleep_ms(40);
|
||||
}
|
||||
|
||||
switch (sc_info->driver_version) {
|
||||
@ -1849,7 +1849,7 @@ static bool bflsc_get_stats(struct cgpu_info *bflsc)
|
||||
return false;
|
||||
|
||||
if (i < (sc_info->sc_count - 1))
|
||||
nmsleep(BFLSC_TEMP_SLEEPMS);
|
||||
cgsleep_ms(BFLSC_TEMP_SLEEPMS);
|
||||
}
|
||||
|
||||
bflsc_set_fanspeed(bflsc);
|
||||
|
@ -199,7 +199,7 @@ reinit:
|
||||
applog(LOG_WARNING, "%s detect (%s) 2nd init failed (%d:%d) - retrying",
|
||||
bitforce->drv->dname, bitforce->device_path, amount, err);
|
||||
}
|
||||
nmsleep(init_sleep);
|
||||
cgsleep_ms(init_sleep);
|
||||
if ((init_sleep * 2) <= REINIT_TIME_MAX_MS)
|
||||
init_sleep *= 2;
|
||||
goto reinit;
|
||||
@ -333,7 +333,7 @@ static void bitforce_flash_led(struct cgpu_info *bitforce)
|
||||
} else {
|
||||
/* However, this stops anything else getting a reply
|
||||
* So best to delay any other access to the BFL */
|
||||
nmsleep(4000);
|
||||
cgsleep_ms(4000);
|
||||
}
|
||||
|
||||
/* Once we've tried - don't do it until told to again */
|
||||
@ -462,7 +462,7 @@ re_send:
|
||||
|
||||
if (amount == 0 || !buf[0] || !strncasecmp(buf, "B", 1)) {
|
||||
mutex_unlock(&bitforce->device_mutex);
|
||||
nmsleep(WORK_CHECK_INTERVAL_MS);
|
||||
cgsleep_ms(WORK_CHECK_INTERVAL_MS);
|
||||
goto re_send;
|
||||
} else if (unlikely(strncasecmp(buf, "OK", 2))) {
|
||||
mutex_unlock(&bitforce->device_mutex);
|
||||
@ -574,7 +574,7 @@ static int64_t bitforce_get_result(struct thr_info *thr, struct work *work)
|
||||
|
||||
/* if BFL is throttling, no point checking so quickly */
|
||||
delay_time_ms = (buf[0] ? BITFORCE_CHECK_INTERVAL_MS : 2 * WORK_CHECK_INTERVAL_MS);
|
||||
nmsleep(delay_time_ms);
|
||||
cgsleep_ms(delay_time_ms);
|
||||
bitforce->wait_ms += delay_time_ms;
|
||||
}
|
||||
|
||||
@ -721,7 +721,7 @@ static bool bitforce_thread_init(struct thr_info *thr)
|
||||
wait = thr->id * MAX_START_DELAY_MS;
|
||||
applog(LOG_DEBUG, "%s%d: Delaying start by %dms",
|
||||
bitforce->drv->name, bitforce->device_id, wait / 1000);
|
||||
nmsleep(wait);
|
||||
cgsleep_ms(wait);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ static bool modminer_fpga_upload_bitstream(struct cgpu_info *modminer)
|
||||
modminer->drv->name, modminer->device_id, devmsg);
|
||||
|
||||
// Give it a 2/3s delay after programming
|
||||
nmsleep(666);
|
||||
cgsleep_ms(666);
|
||||
|
||||
usb_set_dev_start(modminer);
|
||||
|
||||
@ -1016,7 +1016,7 @@ tryagain:
|
||||
break;
|
||||
|
||||
// 1/10th sec to lower CPU usage
|
||||
nmsleep(100);
|
||||
cgsleep_ms(100);
|
||||
if (work_restart(thr))
|
||||
break;
|
||||
}
|
||||
@ -1065,7 +1065,7 @@ static int64_t modminer_scanhash(struct thr_info *thr, struct work *work, int64_
|
||||
return 0;
|
||||
|
||||
// Give it 1s rest then check again
|
||||
nmsleep(1000);
|
||||
cgsleep_ms(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ static int64_t ztex_scanhash(struct thr_info *thr, struct work *work,
|
||||
if (i < 0) {
|
||||
// Something wrong happened in send
|
||||
applog(LOG_ERR, "%s: Failed to send hash data with err %d, retrying", ztex->repr, i);
|
||||
nmsleep(500);
|
||||
cgsleep_ms(500);
|
||||
i = libztex_sendHashData(ztex, sendbuf);
|
||||
if (i < 0) {
|
||||
// And there's nothing we can do about it
|
||||
@ -233,7 +233,7 @@ static int64_t ztex_scanhash(struct thr_info *thr, struct work *work,
|
||||
|
||||
int sleepcount = 0;
|
||||
while (thr->work_restart == 0 && sleepcount < 25) {
|
||||
nmsleep(10);
|
||||
cgsleep_ms(10);
|
||||
sleepcount += 1;
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ static int64_t ztex_scanhash(struct thr_info *thr, struct work *work,
|
||||
if (i < 0) {
|
||||
// Something wrong happened in read
|
||||
applog(LOG_ERR, "%s: Failed to read hash data with err %d, retrying", ztex->repr, i);
|
||||
nmsleep(500);
|
||||
cgsleep_ms(500);
|
||||
i = libztex_readHashData(ztex, &hdata[0]);
|
||||
if (i < 0) {
|
||||
// And there's nothing we can do about it
|
||||
|
@ -421,7 +421,7 @@ static int libztex_configureFpgaHS(struct libztex_device *ztex, const char* firm
|
||||
|
||||
libusb_release_interface(ztex->hndl, settings[1]);
|
||||
|
||||
nmsleep(200);
|
||||
cgsleep_ms(200);
|
||||
applog(LOG_INFO, "%s: HS FPGA configuration done", ztex->repr);
|
||||
return 0;
|
||||
}
|
||||
@ -486,7 +486,7 @@ static int libztex_configureFpgaLS(struct libztex_device *ztex, const char* firm
|
||||
return -3;
|
||||
}
|
||||
|
||||
nmsleep(200);
|
||||
cgsleep_ms(200);
|
||||
applog(LOG_INFO, "%s: FPGA configuration done", ztex->repr);
|
||||
return 0;
|
||||
}
|
||||
|
20
usbutils.c
20
usbutils.c
@ -1262,7 +1262,7 @@ static bool cgminer_usb_lock_bd(struct device_drv *drv, uint8_t bus_number, uint
|
||||
|
||||
// TODO: add a timeout fail - restart the resource thread?
|
||||
while (true) {
|
||||
nmsleep(50);
|
||||
cgsleep_ms(50);
|
||||
|
||||
mutex_lock(&cgusbres_lock);
|
||||
if (res_reply_head) {
|
||||
@ -1961,7 +1961,7 @@ void usb_detect(struct device_drv *drv, bool (*device_detect)(struct libusb_devi
|
||||
if (count == 0)
|
||||
applog(LOG_DEBUG, "USB scan devices: found no devices");
|
||||
else
|
||||
nmsleep(166);
|
||||
cgsleep_ms(166);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (total_count >= total_limit) {
|
||||
@ -2429,7 +2429,7 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro
|
||||
if (need > 0.0 && need < 1.0) {
|
||||
cgpu->usbinfo.read_delay_count++;
|
||||
cgpu->usbinfo.total_read_delay += need;
|
||||
nmsleep((unsigned int)(need * 1000.0));
|
||||
cgsleep_ms((unsigned int)(need * 1000.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2535,7 +2535,7 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro
|
||||
if (need > 0.0 && need < 1.0) {
|
||||
cgpu->usbinfo.read_delay_count++;
|
||||
cgpu->usbinfo.total_read_delay += need;
|
||||
nmsleep((unsigned int)(need * 1000.0));
|
||||
cgsleep_ms((unsigned int)(need * 1000.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2674,7 +2674,7 @@ int _usb_write(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pr
|
||||
if (need > 0.0 && need < 1.0) {
|
||||
cgpu->usbinfo.write_delay_count++;
|
||||
cgpu->usbinfo.total_write_delay += need;
|
||||
nmsleep((unsigned int)(need * 1000.0));
|
||||
cgsleep_ms((unsigned int)(need * 1000.0));
|
||||
}
|
||||
}
|
||||
cgtime(&(usbdev->last_write_tv));
|
||||
@ -2770,7 +2770,7 @@ int __usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bReques
|
||||
if (need > 0.0 && need < 1.0) {
|
||||
cgpu->usbinfo.write_delay_count++;
|
||||
cgpu->usbinfo.total_write_delay += need;
|
||||
nmsleep((unsigned int)(need * 1000.0));
|
||||
cgsleep_ms((unsigned int)(need * 1000.0));
|
||||
}
|
||||
}
|
||||
cgtime(&(usbdev->last_write_tv));
|
||||
@ -2848,7 +2848,7 @@ int _usb_transfer_read(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRe
|
||||
if (need > 0.0 && need < 1.0) {
|
||||
cgpu->usbinfo.read_delay_count++;
|
||||
cgpu->usbinfo.total_read_delay += need;
|
||||
nmsleep((unsigned int)(need * 1000.0));
|
||||
cgsleep_ms((unsigned int)(need * 1000.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3119,7 +3119,7 @@ void usb_cleanup()
|
||||
|
||||
hotplug_time = 0;
|
||||
|
||||
nmsleep(10);
|
||||
cgsleep_ms(10);
|
||||
|
||||
count = 0;
|
||||
for (i = 0; i < total_devices; i++) {
|
||||
@ -3149,7 +3149,7 @@ void usb_cleanup()
|
||||
|
||||
cgtime(&start);
|
||||
while (42) {
|
||||
nmsleep(50);
|
||||
cgsleep_ms(50);
|
||||
|
||||
mutex_lock(&cgusbres_lock);
|
||||
|
||||
@ -3528,7 +3528,7 @@ fail:
|
||||
}
|
||||
if (opt.buf->sem_otime != 0)
|
||||
break;
|
||||
nmsleep(1);
|
||||
cgsleep_ms(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
13
util.c
13
util.c
@ -991,19 +991,6 @@ void cgsleep_us(int64_t us)
|
||||
cgsleep_us_r(&ts_start, us);
|
||||
}
|
||||
|
||||
/* Provide a ms based sleep that uses nanosleep to avoid poor usleep accuracy
|
||||
* on SMP machines */
|
||||
void nmsleep(unsigned int msecs)
|
||||
{
|
||||
cgsleep_ms((int)msecs);
|
||||
}
|
||||
|
||||
/* Same for usecs */
|
||||
void nusleep(unsigned int usecs)
|
||||
{
|
||||
cgsleep_us((int64_t)usecs);
|
||||
}
|
||||
|
||||
/* Returns the microseconds difference between end and start times as a double */
|
||||
double us_tdiff(struct timeval *end, struct timeval *start)
|
||||
{
|
||||
|
2
util.h
2
util.h
@ -72,8 +72,6 @@ enum dev_reason;
|
||||
struct cgpu_info;
|
||||
int thr_info_create(struct thr_info *thr, pthread_attr_t *attr, void *(*start) (void *), void *arg);
|
||||
void thr_info_cancel(struct thr_info *thr);
|
||||
void nmsleep(unsigned int msecs);
|
||||
void nusleep(unsigned int usecs);
|
||||
void cgtime(struct timeval *tv);
|
||||
void subtime(struct timeval *a, struct timeval *b);
|
||||
void addtime(struct timeval *a, struct timeval *b);
|
||||
|
Loading…
Reference in New Issue
Block a user