Skip to content

Commit

Permalink
Okay, assert detection with check is broken (at least with me)
Browse files Browse the repository at this point in the history
  • Loading branch information
wtoorop committed Aug 19, 2022
1 parent 2e04e9f commit 7eaf845
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
9 changes: 0 additions & 9 deletions src/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,6 @@ getdns_context_destroy(struct getdns_context *context)
if (context == NULL)
return;

/* If being destroyed during getdns callback, fail via assert */
assert(context->processing == 0);
if (context->processing == 1) {
context->to_destroy = 1;
Expand Down Expand Up @@ -3773,10 +3772,6 @@ getdns_context_get_num_pending_requests(const getdns_context* context,

if (context->outbound_requests.count)
context->extension->vmt->run_once(context->extension, 0);
if (context->to_destroy) {
getdns_context_destroy((getdns_context *)context);
return 0;
}
return context->outbound_requests.count;
}

Expand All @@ -3788,17 +3783,13 @@ getdns_context_process_async(getdns_context *context)
return GETDNS_RETURN_INVALID_PARAMETER;

context->extension->vmt->run_once(context->extension, 0);
if (context->to_destroy)
getdns_context_destroy(context);
return GETDNS_RETURN_GOOD;
}

void
getdns_context_run(getdns_context *context)
{
context->extension->vmt->run(context->extension);
if (context->to_destroy)
getdns_context_destroy(context);
}

getdns_return_t
Expand Down
2 changes: 0 additions & 2 deletions src/test/check_getdns_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ void assert_ptr_in_answer(struct extracted_response *ex_response)
ck_assert_msg(ptr_records > 0, "Answer did not contain any PTR records");
}

int context_destroyed = 0;
void destroy_callbackfn(struct getdns_context *context,
getdns_callback_type_t callback_type,
struct getdns_dict *response,
Expand All @@ -354,7 +353,6 @@ void destroy_callbackfn(struct getdns_context *context,
*flag = 1;
getdns_dict_destroy(response);
getdns_context_destroy(context);
context_destroyed = 1;
}

/*
Expand Down
23 changes: 9 additions & 14 deletions src/test/check_getdns_context_destroy.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#define _check_getdns_context_destroy_h_

#include <signal.h>
extern int context_destroyed;

/*
**************************************************************************
Expand Down Expand Up @@ -184,6 +183,7 @@ extern int context_destroyed;
}
END_TEST

#if 0
START_TEST (getdns_context_destroy_7)
{
/*
Expand All @@ -203,12 +203,9 @@ extern int context_destroyed;
&flag, &transaction_id, destroy_callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");

context_destroyed = 0;
RUN_EVENT_LOOP;

if (!context_destroyed) {
CONTEXT_DESTROY;
}
CONTEXT_DESTROY;
ck_assert_msg(flag == 1, "flag should == 1, got %d", flag);
}
END_TEST
Expand All @@ -232,11 +229,10 @@ extern int context_destroyed;
&flag, &transaction_id, destroy_callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
getdns_cancel_callback(context, transaction_id);
context_destroyed = 0;

RUN_EVENT_LOOP;
if (!context_destroyed) {
CONTEXT_DESTROY;
}

CONTEXT_DESTROY;
ck_assert_msg(flag == 1, "flag should == 1, got %d", flag);
}
END_TEST
Expand Down Expand Up @@ -265,15 +261,13 @@ extern int context_destroyed;
&flag, &transaction_id, destroy_callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");

context_destroyed = 0;
RUN_EVENT_LOOP;

if (!context_destroyed) {
CONTEXT_DESTROY;
}
CONTEXT_DESTROY;
ck_assert_msg(flag == 1, "flag should == 1, got %d", flag);
}
END_TEST
#endif

void verify_getdns_context_destroy(struct extracted_response *ex_response)
{
Expand Down Expand Up @@ -307,10 +301,11 @@ extern int context_destroyed;
tcase_add_test(tc_pos, getdns_context_destroy_4);
tcase_add_test(tc_pos, getdns_context_destroy_5);
tcase_add_test(tc_pos, getdns_context_destroy_6);
// raise aborts via assertion failures
#if 0
tcase_add_test_raise_signal(tc_pos, getdns_context_destroy_7, SIGABRT);
tcase_add_test_raise_signal(tc_pos, getdns_context_destroy_8, SIGABRT);
tcase_add_test_raise_signal(tc_pos, getdns_context_destroy_9, SIGABRT);
#endif
suite_add_tcase(s, tc_pos);

return s;
Expand Down

0 comments on commit 7eaf845

Please sign in to comment.