diff --git a/daemon/remote.c b/daemon/remote.c index 02558139b..5f6142162 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -1056,6 +1056,14 @@ do_flush_stats(SSL* ssl, struct worker* worker) send_ok(ssl); } +/** flush requestlist */ +static void +do_flush_requestlist(SSL* ssl, struct worker* worker) +{ + mesh_delete_all(worker->env.mesh); + send_ok(ssl); +} + /** * Local info for deletion functions */ @@ -1404,10 +1412,14 @@ execute_cmd(struct daemon_remote* rc, SSL* ssl, char* cmd, return; } else if(strncmp(p, "flush_stats", 11) == 0) { /* must always distribute this cmd */ - if(rc) - distribute_cmd(rc, ssl, cmd); + if(rc) distribute_cmd(rc, ssl, cmd); do_flush_stats(ssl, worker); return; + } else if(strncmp(p, "flush_requestlist", 17) == 0) { + /* must always distribute this cmd */ + if(rc) distribute_cmd(rc, ssl, cmd); + do_flush_requestlist(ssl, worker); + return; } else if(strncmp(p, "lookup", 6) == 0) { do_lookup(ssl, worker, skipwhite(p+6)); return; diff --git a/doc/Changelog b/doc/Changelog index 714245b7c..9951d8e2c 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -3,6 +3,7 @@ - small refactor of stats clearing. - #227: flush_stats feature for unbound-control. - stats_noreset feature for unbound-control. + - flush_requestlist feature for unbound-control. 10 February 2009: Wouter - keys with rfc5011 REVOKE flag are skipped and not considered when diff --git a/doc/unbound-control.8.in b/doc/unbound-control.8.in index 7bc3a05df..3b0471e69 100644 --- a/doc/unbound-control.8.in +++ b/doc/unbound-control.8.in @@ -123,6 +123,13 @@ This needs to walk and inspect the entire cache, and is a slow operation. .B flush_stats Reset statistics to zero. .TP +.B flush_requestlist +Drop the queries that are worked on. Stops working on the queries that the +server is working on now. The cache is unaffected. No reply is sent for +those queries, probably making those users request again later. +Useful to make the server restart working on queries with new settings, +such as a higher verbosity level. +.TP .B dump_requestlist Show what is worked on. Prints all queries that the server is currently working on. Prints the time that users have been waiting. For internal diff --git a/services/mesh.c b/services/mesh.c index 8573b7795..c7a0f837d 100644 --- a/services/mesh.c +++ b/services/mesh.c @@ -205,6 +205,25 @@ mesh_delete(struct mesh_area* mesh) free(mesh); } +void +mesh_delete_all(struct mesh_area* mesh) +{ + /* free all query states */ + traverse_postorder(&mesh->all, &mesh_delete_helper, NULL); + mesh->stats_dropped += mesh->num_reply_addrs; + /* clear mesh area references */ + rbtree_init(&mesh->run, &mesh_state_compare); + rbtree_init(&mesh->all, &mesh_state_compare); + mesh->num_reply_addrs = 0; + mesh->num_reply_states = 0; + mesh->num_detached_states = 0; + mesh->num_forever_states = 0; + mesh->forever_first = NULL; + mesh->forever_last = NULL; + mesh->jostle_first = NULL; + mesh->jostle_last = NULL; +} + int mesh_make_new_space(struct mesh_area* mesh) { struct mesh_state* m = mesh->jostle_last; diff --git a/services/mesh.h b/services/mesh.h index 0a0d7de79..52ab99982 100644 --- a/services/mesh.h +++ b/services/mesh.h @@ -391,6 +391,12 @@ struct mesh_state* mesh_state_create(struct module_env* env, */ void mesh_state_cleanup(struct mesh_state* mstate); +/** + * Delete all mesh states from the mesh. + * @param mesh: the mesh area to clear + */ +void mesh_delete_all(struct mesh_area* mesh); + /** * Find a mesh state in the mesh area. Pass relevant flags. * diff --git a/smallapp/unbound-control.c b/smallapp/unbound-control.c index 83afa89f1..2d90a05e7 100644 --- a/smallapp/unbound-control.c +++ b/smallapp/unbound-control.c @@ -61,6 +61,7 @@ usage() printf(" start start server; runs unbound(8)\n"); printf(" stop stops the server\n"); printf(" reload reloads the server\n"); + printf(" (this flushes data, stats, requestlist)\n"); printf(" stats print statistics\n"); printf(" stats_noreset peek at statistics\n"); printf(" status display status of server\n"); @@ -80,6 +81,7 @@ usage() printf(" flush_zone [name] flush everything at or under name\n"); printf(" from rr and dnssec caches\n"); printf(" flush_stats flush statistics, make zero\n"); + printf(" flush_requestlist drop queries that are worked on\n"); printf(" dump_requestlist show what is worked on\n"); printf("Version %s\n", PACKAGE_VERSION); printf("BSD licensed, see LICENSE in source package for details.\n");