Skip to content

Commit

Permalink
Replace all references to the old n*sleep functions with the equivale…
Browse files Browse the repository at this point in the history
…nt cgsleep_*s replacements.
  • Loading branch information
ckolivas committed Aug 20, 2013
1 parent 7d448cd commit eeac9d8
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 61 deletions.
2 changes: 1 addition & 1 deletion adl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ void change_gpusettings(int gpu)
clear_logwin();
return;
}
nmsleep(1000);
cgsleep_ms(1000);
goto updated;
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
24 changes: 12 additions & 12 deletions cgminer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -5057,7 +5057,7 @@ static void *stratum_rthread(void *userdata)
while (!restart_stratum(pool)) {
if (pool->removed)
goto out;
nmsleep(30000);
cgsleep_ms(30000);
}
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -6314,7 +6314,7 @@ static void *longpoll_thread(void *userdata)
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);
}
}
Expand Down Expand Up @@ -6390,7 +6390,7 @@ static void *longpoll_thread(void *userdata)
continue;
if (failures == 1)
applog(LOG_WARNING, "longpoll failed for %s, retrying every 30s", lp_url);
nmsleep(30000);
cgsleep_ms(30000);
}

if (pool != cp) {
Expand Down Expand Up @@ -6502,7 +6502,7 @@ static void *watchpool_thread(void __maybe_unused *userdata)
switch_pools(NULL);
}

nmsleep(30000);
cgsleep_ms(30000);

}
return NULL;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -7919,7 +7919,7 @@ int main(int argc, char *argv[])
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;
Expand All @@ -7935,7 +7935,7 @@ int main(int argc, char *argv[])
while (pool->idle) {
struct pool *altpool = select_pool(true);

nmsleep(5000);
cgsleep_ms(5000);
if (altpool != pool) {
pool = altpool;
goto retry;
Expand Down Expand Up @@ -7969,7 +7969,7 @@ int main(int argc, char *argv[])
* 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;
Expand Down
10 changes: 5 additions & 5 deletions driver-avalon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions driver-bflsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ static bool bflsc_detect_one(struct libusb_device *dev, struct usb_find_devices
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;
Expand Down Expand Up @@ -783,7 +783,7 @@ static bool bflsc_detect_one(struct libusb_device *dev, struct usb_find_devices
if (++tries > 2)
goto unshin;

nmsleep(40);
cgsleep_ms(40);
}

switch (sc_info->driver_version) {
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions driver-bitforce.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static bool bitforce_detect_one(struct libusb_device *dev, struct usb_find_devic
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;
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -462,7 +462,7 @@ static bool bitforce_send_work(struct thr_info *thr, struct work *work)

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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions driver-modminer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -1016,7 +1016,7 @@ static uint64_t modminer_process_results(struct thr_info *thr, struct work *work
break;

// 1/10th sec to lower CPU usage
nmsleep(100);
cgsleep_ms(100);
if (work_restart(thr))
break;
}
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions driver-ztex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libztex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit eeac9d8

Please sign in to comment.