Переглянути джерело

core: dns cache - print status as field in rpc structure

Daniel-Constantin Mierla 7 роки тому
батько
коміт
1822d974ff
1 змінених файлів з 22 додано та 2 видалено
  1. 22 2
      src/core/dns_cache.c

+ 22 - 2
src/core/dns_cache.c

@@ -4030,24 +4030,44 @@ void dns_cache_flush(int del_permanent)
 /* deletes all the non-permanent entries from the cache */
 /* deletes all the non-permanent entries from the cache */
 void dns_cache_delete_all(rpc_t* rpc, void* ctx)
 void dns_cache_delete_all(rpc_t* rpc, void* ctx)
 {
 {
+	void *th;
+
 	if (!cfg_get(core, core_cfg, use_dns_cache)){
 	if (!cfg_get(core, core_cfg, use_dns_cache)){
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
 		return;
 		return;
 	}
 	}
 	dns_cache_flush(0);
 	dns_cache_flush(0);
-	rpc->rpl_printf(ctx, "OK");
+
+	if(rpc->add(ctx, "{", &th) < 0) {
+		rpc->fault(ctx, 500, "Internal error - root structure");
+		return;
+	}
+	if(rpc->struct_add(th, "s", "status", "ok") < 0) {
+		rpc->fault(ctx, 500, "Internal error - status");
+		return;
+	}
 }
 }
 
 
 /* deletes all the entries from the cache,
 /* deletes all the entries from the cache,
  * even the permanent ones */
  * even the permanent ones */
 void dns_cache_delete_all_force(rpc_t* rpc, void* ctx)
 void dns_cache_delete_all_force(rpc_t* rpc, void* ctx)
 {
 {
+	void *th;
+
 	if (!cfg_get(core, core_cfg, use_dns_cache)){
 	if (!cfg_get(core, core_cfg, use_dns_cache)){
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
 		return;
 		return;
 	}
 	}
 	dns_cache_flush(1);
 	dns_cache_flush(1);
-	rpc->rpl_printf(ctx, "OK");
+
+	if(rpc->add(ctx, "{", &th) < 0) {
+		rpc->fault(ctx, 500, "Internal error - root structure");
+		return;
+	}
+	if(rpc->struct_add(th, "s", "status", "ok") < 0) {
+		rpc->fault(ctx, 500, "Internal error - status");
+		return;
+	}
 }
 }
 
 
 /* clones an entry and extends its memory area to hold a new rr.
 /* clones an entry and extends its memory area to hold a new rr.