mirror of
https://github.com/NLnetLabs/unbound.git
synced 2024-09-21 06:37:08 +00:00
- in testcode, free async ids, initialise array, and check for null
pointer during test of the test. And use exit for return to note irregular program stop. git-svn-id: file:///svn/unbound/trunk@4897 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
9a82526b91
commit
fe8b22caa1
@ -4,6 +4,9 @@
|
||||
- free memory leaks in config strlist and str2list insert functions.
|
||||
- do not move unused argv variable after getopt.
|
||||
- Remove unused if clause in testcode.
|
||||
- in testcode, free async ids, initialise array, and check for null
|
||||
pointer during test of the test. And use exit for return to note
|
||||
irregular program stop.
|
||||
|
||||
11 September 2018: Wouter
|
||||
- Fixed unused return value warnings in contrib/fastrpz.patch for
|
||||
|
@ -182,6 +182,8 @@ struct ext_thr_info {
|
||||
char** argv;
|
||||
/** number of queries to do */
|
||||
int numq;
|
||||
/** list of ids to free once threads are done */
|
||||
struct track_id* id_list;
|
||||
};
|
||||
|
||||
/** if true, we are testing against 'localhost' and extra checking is done */
|
||||
@ -309,6 +311,7 @@ ext_thread(void* arg)
|
||||
for(i=0; i<inf->numq; i++) {
|
||||
lock_basic_init(&async_ids[i].lock);
|
||||
}
|
||||
inf->id_list = async_ids;
|
||||
}
|
||||
for(i=0; i<inf->numq; i++) {
|
||||
if(async_ids) {
|
||||
@ -347,14 +350,6 @@ ext_thread(void* arg)
|
||||
/* if these locks are destroyed, or if the async_ids is freed, then
|
||||
a use-after-free happens in another thread.
|
||||
The allocation is only part of this test, though. */
|
||||
/*
|
||||
if(async_ids) {
|
||||
for(i=0; i<inf->numq; i++) {
|
||||
lock_basic_destroy(&async_ids[i].lock);
|
||||
}
|
||||
}
|
||||
free(async_ids);
|
||||
*/
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -375,6 +370,7 @@ ext_test(struct ub_ctx* ctx, int argc, char** argv)
|
||||
inf[i].argc = argc;
|
||||
inf[i].argv = argv;
|
||||
inf[i].numq = 100;
|
||||
inf[i].id_list = NULL;
|
||||
ub_thread_create(&inf[i].tid, ext_thread, &inf[i]);
|
||||
}
|
||||
/* the work happens here */
|
||||
@ -382,6 +378,16 @@ ext_test(struct ub_ctx* ctx, int argc, char** argv)
|
||||
ub_thread_join(inf[i].tid);
|
||||
}
|
||||
printf("extended test end\n");
|
||||
/* free the id lists */
|
||||
for(i=0; i<NUMTHR; i++) {
|
||||
if(inf[i].id_list) {
|
||||
int j;
|
||||
for(j=0; j<inf->numq; j++) {
|
||||
lock_basic_destroy(&inf[i].id_list[j].lock);
|
||||
}
|
||||
free(inf[i].id_list);
|
||||
}
|
||||
}
|
||||
ub_ctx_delete(ctx);
|
||||
checklock_stop();
|
||||
return 0;
|
||||
|
@ -1195,6 +1195,7 @@ struct serviced_query* outnet_serviced_query(struct outside_network* outnet,
|
||||
/* create packet with EDNS */
|
||||
pend->buffer = sldns_buffer_new(512);
|
||||
log_assert(pend->buffer);
|
||||
log_assert(pend->buffer->_data);
|
||||
sldns_buffer_write_u16(pend->buffer, 0); /* id */
|
||||
sldns_buffer_write_u16(pend->buffer, flags);
|
||||
sldns_buffer_write_u16(pend->buffer, 1); /* qdcount */
|
||||
|
@ -532,6 +532,7 @@ qlist_add_line(struct perfinfo* info, char* line, int no)
|
||||
printf("error parsing query %d: %s\n", no, line);
|
||||
exit(1);
|
||||
}
|
||||
log_assert(info->buf->_data);
|
||||
sldns_buffer_write_u16_at(info->buf, 0, (uint16_t)info->qlist_size);
|
||||
if(info->qlist_size + 1 > info->qlist_capacity) {
|
||||
qlist_grow_capacity(info);
|
||||
@ -610,7 +611,7 @@ int main(int argc, char* argv[])
|
||||
case 'd':
|
||||
if(atoi(optarg)==0 && strcmp(optarg, "0")!=0) {
|
||||
printf("-d not a number %s", optarg);
|
||||
return 1;
|
||||
exit(1);
|
||||
}
|
||||
info.duration = atoi(optarg);
|
||||
break;
|
||||
@ -635,11 +636,11 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
if(!extstrtoaddr(argv[0], &info.dest, &info.destlen)) {
|
||||
printf("Could not parse ip: %s\n", argv[0]);
|
||||
return 1;
|
||||
exit(1);
|
||||
}
|
||||
if(info.qlist_size == 0) {
|
||||
printf("No queries to make, use -f or -a.\n");
|
||||
return 1;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* do the performance test */
|
||||
|
@ -155,6 +155,7 @@ static void analyze(sldns_buffer* pkt)
|
||||
{
|
||||
uint16_t i, f, qd, an, ns, ar;
|
||||
int rrnum = 0;
|
||||
log_assert(pkt && pkt->_data);
|
||||
printf("packet length %d\n", (int)sldns_buffer_limit(pkt));
|
||||
if(sldns_buffer_limit(pkt) < 12) return;
|
||||
|
||||
|
@ -458,6 +458,8 @@ replay_scenario_read(FILE* in, const char* name, int* lineno)
|
||||
if(parse_keyword(&parse, ";"))
|
||||
continue; /* comment */
|
||||
if(parse_keyword(&parse, "SCENARIO_BEGIN")) {
|
||||
if(scen)
|
||||
fatal_exit("%d: double SCENARIO_BEGIN", *lineno);
|
||||
scen = make_scenario(parse);
|
||||
if(!scen)
|
||||
fatal_exit("%d: could not make scen", *lineno);
|
||||
@ -801,14 +803,19 @@ macro_expand(rbtree_type* store, struct replay_runtime* runtime, char** text)
|
||||
|
||||
/* check for functions */
|
||||
if(strcmp(buf, "time") == 0) {
|
||||
snprintf(buf, sizeof(buf), ARG_LL "d", (long long)runtime->now_secs);
|
||||
if(runtime)
|
||||
snprintf(buf, sizeof(buf), ARG_LL "d", (long long)runtime->now_secs);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), ARG_LL "d", (long long)0);
|
||||
*text += len;
|
||||
return strdup(buf);
|
||||
} else if(strcmp(buf, "timeout") == 0) {
|
||||
time_t res = 0;
|
||||
struct fake_timer* t = first_timer(runtime);
|
||||
if(t && (time_t)t->tv.tv_sec >= runtime->now_secs)
|
||||
res = (time_t)t->tv.tv_sec - runtime->now_secs;
|
||||
if(runtime) {
|
||||
struct fake_timer* t = first_timer(runtime);
|
||||
if(t && (time_t)t->tv.tv_sec >= runtime->now_secs)
|
||||
res = (time_t)t->tv.tv_sec - runtime->now_secs;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), ARG_LL "d", (long long)res);
|
||||
*text += len;
|
||||
return strdup(buf);
|
||||
|
@ -118,6 +118,8 @@ static void get_random_data(char** fromp, char** top, char* zname)
|
||||
int labnum1[10], labnum2[10];
|
||||
int i;
|
||||
char* p;
|
||||
memset(labnum1, 0, sizeof(int)*10);
|
||||
memset(labnum2, 0, sizeof(int)*10);
|
||||
|
||||
*fromp = buf1;
|
||||
*top = buf2;
|
||||
|
Loading…
Reference in New Issue
Block a user