Browse Source

windows: return to normal priority, fix json decref

the jansson error seems only seen in windows debug mode
2upstream
Tanguy Pruvot 10 years ago
parent
commit
35cc5908ee
  1. 23
      ccminer.cpp
  2. 6
      util.cpp
  3. 4
      x11/x11.cu

23
ccminer.cpp

@ -793,7 +793,7 @@ static bool get_mininginfo(CURL *curl, struct work *work)
if (!val && curl_err == -1) { if (!val && curl_err == -1) {
allow_mininginfo = false; allow_mininginfo = false;
if (opt_debug) { if (opt_debug) {
applog(LOG_DEBUG, "getinfo not supported"); applog(LOG_DEBUG, "getmininginfo not supported");
} }
return false; return false;
} else { } else {
@ -805,20 +805,16 @@ static bool get_mininginfo(CURL *curl, struct work *work)
json_t *key = json_object_get(res, "difficulty"); json_t *key = json_object_get(res, "difficulty");
if (key && json_is_real(key)) { if (key && json_is_real(key)) {
global_diff = json_real_value(key); global_diff = json_real_value(key);
json_decref(key);
} }
key = json_object_get(res, "networkhashps"); key = json_object_get(res, "networkhashps");
if (key && json_is_integer(key)) { if (key && json_is_integer(key)) {
net_hashrate = json_integer_value(key); net_hashrate = json_integer_value(key);
json_decref(key);
} }
key = json_object_get(res, "blocks"); key = json_object_get(res, "blocks");
if (key && json_is_integer(key)) { if (key && json_is_integer(key)) {
net_blocks = json_integer_value(key); net_blocks = json_integer_value(key);
json_decref(key);
} }
} }
json_decref(res);
} }
json_decref(val); json_decref(val);
return true; return true;
@ -1168,7 +1164,7 @@ static void *miner_thread(void *userdata)
struct work work; struct work work;
uint64_t loopcnt = 0; uint64_t loopcnt = 0;
uint32_t max_nonce; uint32_t max_nonce;
uint32_t end_nonce = 0xffffffffU / opt_n_threads * (thr_id + 1) - (thr_id + 1); uint32_t end_nonce = UINT32_MAX / opt_n_threads * (thr_id + 1) - (thr_id + 1);
bool work_done = false; bool work_done = false;
bool extrajob = false; bool extrajob = false;
char s[16]; char s[16];
@ -1176,16 +1172,10 @@ static void *miner_thread(void *userdata)
memset(&work, 0, sizeof(work)); // prevent work from being used uninitialized memset(&work, 0, sizeof(work)); // prevent work from being used uninitialized
/* Set worker threads to nice 19 and then preferentially to SCHED_IDLE if (opt_priority > 0) {
* and if that fails, then SCHED_BATCH. No need for this to be an int prio = 2; // default to normal
* error if it fails */
if (opt_benchmark) {
setpriority(PRIO_PROCESS, 0, -1);
drop_policy();
} else {
int prio = 3; // default for ccminer is above normal
#ifndef WIN32 #ifndef WIN32
prio = -1; prio = 0;
// note: different behavior on linux (-19 to 19) // note: different behavior on linux (-19 to 19)
switch (opt_priority) { switch (opt_priority) {
case 0: case 0:
@ -2436,6 +2426,9 @@ int main(int argc, char *argv[])
case 1: case 1:
prio = BELOW_NORMAL_PRIORITY_CLASS; prio = BELOW_NORMAL_PRIORITY_CLASS;
break; break;
case 2:
prio = NORMAL_PRIORITY_CLASS;
break;
case 3: case 3:
prio = ABOVE_NORMAL_PRIORITY_CLASS; prio = ABOVE_NORMAL_PRIORITY_CLASS;
break; break;

6
util.cpp

@ -522,16 +522,15 @@ json_t *json_rpc_call(CURL *curl, const char *url,
if (!res_val || json_is_null(res_val) || if (!res_val || json_is_null(res_val) ||
(err_val && !json_is_null(err_val))) { (err_val && !json_is_null(err_val))) {
char *s; char *s = NULL;
if (err_val) { if (err_val) {
s = json_dumps(err_val, 0);
json_t *msg = json_object_get(err_val, "message"); json_t *msg = json_object_get(err_val, "message");
json_t *err_code = json_object_get(err_val, "code"); json_t *err_code = json_object_get(err_val, "code");
if (curl_err && json_integer_value(err_code)) if (curl_err && json_integer_value(err_code))
*curl_err = (int) json_integer_value(err_code); *curl_err = (int) json_integer_value(err_code);
json_decref(err_code);
s = json_dumps(err_val, 0);
if (json_is_string(msg)) { if (json_is_string(msg)) {
free(s); free(s);
s = strdup(json_string_value(msg)); s = strdup(json_string_value(msg));
@ -546,6 +545,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
else else
s = strdup("(unknown reason)"); s = strdup("(unknown reason)");
if (!curl_err || opt_debug)
applog(LOG_ERR, "JSON-RPC call failed: %s", s); applog(LOG_ERR, "JSON-RPC call failed: %s", s);
free(s); free(s);

4
x11/x11.cu

@ -131,8 +131,8 @@ extern "C" void x11hash(void *output, const void *input)
uint32_t* debugbuf = NULL; \ uint32_t* debugbuf = NULL; \
cudaMallocHost(&debugbuf, 8*sizeof(uint32_t)); \ cudaMallocHost(&debugbuf, 8*sizeof(uint32_t)); \
cudaMemcpy(debugbuf, d_hash[thr_id], 8*sizeof(uint32_t), cudaMemcpyDeviceToHost); \ cudaMemcpy(debugbuf, d_hash[thr_id], 8*sizeof(uint32_t), cudaMemcpyDeviceToHost); \
printf("%s %08x %08x %08x %08x...\n", algo, htobe32(debugbuf[0]), htobe32(debugbuf[1]), \ printf("%s %08x %08x %08x %08x...\n", algo, swab32(debugbuf[0]), swab32(debugbuf[1]), \
htobe32(debugbuf[2]), htobe32(debugbuf[3])); \ swab32(debugbuf[2]), swab32(debugbuf[3])); \
cudaFreeHost(debugbuf); \ cudaFreeHost(debugbuf); \
} \ } \
} }

Loading…
Cancel
Save