diff --git a/world/net/library/jsonparser.pike b/world/net/library/jsonparser.pike index dacd0d7..76eb024 100644 --- a/world/net/library/jsonparser.pike +++ b/world/net/library/jsonparser.pike @@ -527,7 +527,9 @@ PROTECTED mixed nextObject() { if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') { int a; float b_; string c_; sscanf(s, "%d%s", a, c_); - if(c_ && sizeof(c_)) { + // some values of json ints exceed the limits of MAX_INT, in that case we need to use float -lynX + // maybe it is more efficient, if we used float in all cases then + if ((c_ && sizeof(c_)) || (a && s != to_string(a))) { #ifdef __PIKE__ sscanf(s, "%f", b_); #else diff --git a/world/net/twitter/polly.c b/world/net/twitter/polly.c index 49260ae..d72a6cb 100644 --- a/world/net/twitter/polly.c +++ b/world/net/twitter/polly.c @@ -5,7 +5,7 @@ #include -persistent int lastid; +persistent float lastid; volatile object feed; @@ -28,15 +28,21 @@ parse(string body, mapping headers) { P4((body)) //#endif unless (pointerp(wurst = parse_json(body))) { - P1(("%O failed to parse its timeline.\n", ME)) + monitor_report("_failure_network_fetch_twitter_empty", + "[_source] failed to parse its timeline"); return; } unless (sizeof(wurst)) { - P1(("%O received an empty structure.\n", ME)) + monitor_report("_failure_network_fetch_twitter_empty", + "[_source] received an empty structure."); return; } + // this used to fail on MAX_INT turning the ints to negative.. interestingly + // it works out of the box now that i convert this to float. funny to run into + // such a weird problem only after months of usage, but if twitter never resets + // its packet ids, that's where you end up.. bignums! if (wurst[0]["id"] <= lastid) { - P1(("%O received %d old updates.\n", ME, sizeof(wurst))) + P1(("%O received %d old updates (id0 %O <= lastid %O).\n", ME, sizeof(wurst), wurst[0]["id"], lastid)) return; } lastid = wurst[0]["id"];