kanoi 10 years ago
parent
commit
0217a4c3c4
  1. 8
      src/generator.c
  2. 18
      src/jansson-2.6/src/dump.c
  3. 1
      src/jansson-2.6/src/jansson.h
  4. 5
      src/jansson-2.6/src/strbuffer.c
  5. 8
      src/stratifier.c

8
src/generator.c

@ -263,7 +263,7 @@ retry:
send_unix_msg(sockd, "Failed");
goto reconnect;
} else {
char *s = json_dumps(gbt->json, 0);
char *s = json_dumps(gbt->json, JSON_NO_UTF8);
send_unix_msg(sockd, s);
free(s);
@ -915,7 +915,7 @@ static void send_subscribe(proxy_instance_t *proxi, int sockd)
json_msg = json_pack("{sssi}", "enonce1", proxi->enonce1,
"nonce2len", proxi->nonce2len);
msg = json_dumps(json_msg, 0);
msg = json_dumps(json_msg, JSON_NO_UTF8);
json_decref(json_msg);
send_unix_msg(sockd, msg);
free(msg);
@ -944,7 +944,7 @@ static void send_notify(proxy_instance_t *proxi, int sockd)
"clean", ni->clean);
mutex_unlock(&proxi->notify_lock);
msg = json_dumps(json_msg, 0);
msg = json_dumps(json_msg, JSON_NO_UTF8);
json_decref(json_msg);
send_unix_msg(sockd, msg);
free(msg);
@ -957,7 +957,7 @@ static void send_diff(proxy_instance_t *proxi, int sockd)
char *msg;
json_msg = json_pack("{sf}", "diff", proxi->diff);
msg = json_dumps(json_msg, 0);
msg = json_dumps(json_msg, JSON_NO_UTF8);
json_decref(json_msg);
send_unix_msg(sockd, msg);
free(msg);

18
src/jansson-2.6/src/dump.c

@ -65,6 +65,21 @@ static int dump_indent(size_t flags, int depth, int space, json_dump_callback_t
return 0;
}
static inline const char *noutf8_iterate(const char *buffer, int32_t *codepoint)
{
int32_t value;
if(!*buffer)
return buffer;
value = (unsigned char)buffer[0];
if(codepoint)
*codepoint = value;
return buffer + 1;
}
static int dump_string(const char *str, json_dump_callback_t dump, void *data, size_t flags)
{
const char *pos, *end;
@ -82,6 +97,9 @@ static int dump_string(const char *str, json_dump_callback_t dump, void *data, s
while(*end)
{
if(flags & JSON_NO_UTF8)
end = noutf8_iterate(pos, &codepoint);
else
end = utf8_iterate(pos, &codepoint);
if(!end)
return -1;

1
src/jansson-2.6/src/jansson.h

@ -260,6 +260,7 @@ json_t *json_load_callback(json_load_callback_t callback, void *data, size_t fla
#define JSON_PRESERVE_ORDER 0x100
#define JSON_ENCODE_ANY 0x200
#define JSON_ESCAPE_SLASH 0x400
#define JSON_NO_UTF8 0x800
typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data);

5
src/jansson-2.6/src/strbuffer.c

@ -86,13 +86,10 @@ int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size)
new_size = max(strbuff->size * STRBUFFER_FACTOR,
strbuff->length + size + 1);
new_value = jsonp_malloc(new_size);
new_value = realloc(strbuff->value, new_size);
if(!new_value)
return -1;
memcpy(new_value, strbuff->value, strbuff->length);
jsonp_free(strbuff->value);
strbuff->value = new_value;
strbuff->size = new_size;
}

8
src/stratifier.c

@ -2368,7 +2368,7 @@ static void *statsupdate(void *arg)
"runtime", diff.tv_sec,
"Users", stats.users,
"Workers", stats.workers);
s = json_dumps(val, 0);
s = json_dumps(val, JSON_NO_UTF8);
json_decref(val);
LOGNOTICE("Pool:%s", s);
fprintf(fp, "%s\n", s);
@ -2381,7 +2381,7 @@ static void *statsupdate(void *arg)
"hashrate1hr", suffix60,
"hashrate6hr", suffix360,
"hashrate1d", suffix1440);
s = json_dumps(val, 0);
s = json_dumps(val, JSON_NO_UTF8);
json_decref(val);
LOGNOTICE("Pool:%s", s);
fprintf(fp, "%s\n", s);
@ -2392,7 +2392,7 @@ static void *statsupdate(void *arg)
"SPS5m", sps5,
"SPS15m", sps15,
"SPS1h", sps60);
s = json_dumps(val, 0);
s = json_dumps(val, JSON_NO_UTF8);
json_decref(val);
LOGNOTICE("Pool:%s", s);
fprintf(fp, "%s\n", s);
@ -2439,7 +2439,7 @@ static void *statsupdate(void *arg)
LOGERR("Failed to fopen %s", fname);
continue;
}
s = json_dumps(val, 0);
s = json_dumps(val, JSON_NO_UTF8);
fprintf(fp, "%s\n", s);
/* Only display the status of connected users to the
* console log. */

Loading…
Cancel
Save