First time we initialize counters and figure where we're up to */
| 1335 | |
| 1336 | /* First time we initialize counters and figure where we're up to */ |
| 1337 | static void watch_init(struct command *cmd, |
| 1338 | struct table_desc *td, |
| 1339 | const char *indexname, |
| 1340 | u64 *max) |
| 1341 | { |
| 1342 | struct json_out *params = json_out_new(NULL); |
| 1343 | const jsmntok_t *result, *valtok; |
| 1344 | const char *buf; |
| 1345 | u64 val; |
| 1346 | |
| 1347 | json_out_start(params, NULL, '{'); |
| 1348 | json_out_addstr(params, "subsystem", td->waitname); |
| 1349 | json_out_addstr(params, "indexname", indexname); |
| 1350 | json_out_add(params, "nextvalue", false, "0"); |
| 1351 | json_out_end(params, '}'); |
| 1352 | |
| 1353 | result = jsonrpc_request_sync(tmpctx, cmd, "wait", take(params), &buf); |
| 1354 | |
| 1355 | valtok = json_get_member(buf, result, indexname); |
| 1356 | if (!valtok || !json_to_u64(buf, valtok, &val)) { |
| 1357 | plugin_err(cmd->plugin, |
| 1358 | "Invalid wait reply for %s %s: '%.*s'", |
| 1359 | td->name, indexname, |
| 1360 | json_tok_full_len(result), |
| 1361 | json_tok_full(buf, result)); |
| 1362 | } |
| 1363 | |
| 1364 | if (max != NULL) |
| 1365 | *max = val; |
| 1366 | |
| 1367 | /* Place watch for when it increases */ |
| 1368 | watch_for(sql_of(cmd->plugin), td, indexname, val + 1); |
| 1369 | } |
| 1370 | |
| 1371 | static struct command_result *refresh_tables(struct command *cmd, |
| 1372 | struct db_query *dbq) |
no test coverage detected