mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 02:37:10 +00:00 
			
		
		
		
	Allow "dundi flush" to flush statistics too
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4077 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -1972,10 +1972,36 @@ static int dundi_do_store_history(int fd, int argc, char *argv[]) | ||||
|  | ||||
| static int dundi_flush(int fd, int argc, char *argv[]) | ||||
| { | ||||
| 	if (argc != 2) | ||||
| 	int stats=0; | ||||
| 	if ((argc < 2) || (argc > 3)) | ||||
| 		return RESULT_SHOWUSAGE; | ||||
| 	ast_db_deltree("dundi/cache", NULL); | ||||
| 	ast_cli(fd, "DUNDi Cache Flushed\n"); | ||||
| 	if (argc > 2) { | ||||
| 		if (!strcasecmp(argv[2], "stats")) | ||||
| 			stats = 1; | ||||
| 		else | ||||
| 			return RESULT_SHOWUSAGE; | ||||
| 	} | ||||
| 	if (stats) { | ||||
| 		/* Flush statistics */ | ||||
| 		struct dundi_peer *p; | ||||
| 		int x; | ||||
| 		ast_mutex_lock(&peerlock); | ||||
| 		p = peers; | ||||
| 		while(p) { | ||||
| 			for (x=0;x<DUNDI_TIMING_HISTORY;x++) { | ||||
| 				if (p->lookups[x]) | ||||
| 					free(p->lookups[x]); | ||||
| 				p->lookups[x] = NULL; | ||||
| 				p->lookuptimes[x] = 0; | ||||
| 			} | ||||
| 			p->avgms = 0; | ||||
| 			p = p->next; | ||||
| 		} | ||||
| 		ast_mutex_unlock(&peerlock); | ||||
| 	} else { | ||||
| 		ast_db_deltree("dundi/cache", NULL); | ||||
| 		ast_cli(fd, "DUNDi Cache Flushed\n"); | ||||
| 	} | ||||
| 	return RESULT_SUCCESS; | ||||
| } | ||||
|  | ||||
| @@ -2410,8 +2436,10 @@ static char query_usage[] = | ||||
| "e164 if none is specified).\n"; | ||||
|  | ||||
| static char flush_usage[] = | ||||
| "Usage: dundi flush\n" | ||||
| "       Flushes DUNDi answer cache, used primarily for debug.\n"; | ||||
| "Usage: dundi flush [stats]\n" | ||||
| "       Flushes DUNDi answer cache, used primarily for debug.  If\n" | ||||
| "'stats' is present, clears timer statistics instead of normal\n" | ||||
| "operation.\n"; | ||||
|  | ||||
| static struct ast_cli_entry  cli_debug = | ||||
| 	{ { "dundi", "debug", NULL }, dundi_do_debug, "Enable DUNDi debugging", debug_usage }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user