diff --git a/src/context.c b/src/context.c index 65e627d8..19e57421 100644 --- a/src/context.c +++ b/src/context.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "context.h" #include "types-internal.h" @@ -532,19 +533,17 @@ getdns_context_create(struct getdns_context ** context, int set_from_os) * Call this to dispose of resources associated with a context once you * are done with it. */ -getdns_return_t +void getdns_context_destroy(struct getdns_context *context) { if (context == NULL) { - return GETDNS_RETURN_INVALID_PARAMETER; + return; } // If being destroyed during getdns callback, - // return an error - if (context->processing > 0) { - return GETDNS_RETURN_INVALID_PARAMETER; - } + // fail via assert + assert(context->processing == 0); if (context->destroying) { - return GETDNS_RETURN_BAD_CONTEXT; + return ; } context->destroying = 1; cancel_outstanding_requests(context, 1); @@ -582,7 +581,6 @@ getdns_context_destroy(struct getdns_context *context) GETDNS_FREE(context->my_mf, context->timeouts_by_time); GETDNS_FREE(context->my_mf, context); - return GETDNS_RETURN_GOOD; } /* getdns_context_destroy */ /* diff --git a/src/dict.c b/src/dict.c index c5d17c93..a69bbdcd 100644 --- a/src/dict.c +++ b/src/dict.c @@ -373,16 +373,15 @@ getdns_dict_item_free(ldns_rbnode_t * node, void *arg) } /* getdns_dict_item_free */ /*---------------------------------------- getdns_dict_destroy */ -getdns_return_t +void getdns_dict_destroy(struct getdns_dict *dict) { if (!dict) - return GETDNS_RETURN_INVALID_PARAMETER; + return; ldns_traverse_postorder(&(dict->root), getdns_dict_item_free, dict); GETDNS_FREE(dict->mf, dict); - return GETDNS_RETURN_GOOD; } /* getdns_dict_destroy */ /*---------------------------------------- getdns_dict_set_dict */ diff --git a/src/getdns/getdns.h.in b/src/getdns/getdns.h.in index 24e8848a..fed905a4 100644 --- a/src/getdns/getdns.h.in +++ b/src/getdns/getdns.h.in @@ -649,7 +649,7 @@ getdns_list *getdns_list_create_with_extended_memory_functions( * you MUST copy those instances BEFORE you destroy the list else * unpleasant things will happen at run-time */ -getdns_return_t getdns_list_destroy(getdns_list *this_list); +void getdns_list_destroy(getdns_list *this_list); /** * assign the child_dict to an item in a parent list, the parent list copies @@ -716,7 +716,7 @@ getdns_dict *getdns_dict_create_with_extended_memory_functions( * be aware that if you have fetched any data from the dictionary it will * no longer be available (you are likely to experience bad things if you try) */ -getdns_return_t getdns_dict_destroy(getdns_dict *this_dict); +void getdns_dict_destroy(getdns_dict *this_dict); getdns_return_t getdns_dict_set_dict(getdns_dict *this_dict, const char *name, const getdns_dict *child_dict); @@ -815,7 +815,7 @@ getdns_context_create_with_extended_memory_functions( void (*free) (void *userarg, void *) ); -getdns_return_t getdns_context_destroy(getdns_context *context); +void getdns_context_destroy(getdns_context *context); getdns_return_t getdns_cancel_callback(getdns_context *context, diff --git a/src/list.c b/src/list.c index 95165cae..207f41b6 100644 --- a/src/list.c +++ b/src/list.c @@ -323,13 +323,13 @@ getdns_list_destroy_item(struct getdns_list *list, size_t index) } /*---------------------------------------- getdns_list_destroy */ -getdns_return_t +void getdns_list_destroy(struct getdns_list *list) { size_t i; if (!list) - return GETDNS_RETURN_INVALID_PARAMETER; + return; for (i = 0; i < list->numinuse; i++) getdns_list_destroy_item(list, i); @@ -337,7 +337,6 @@ getdns_list_destroy(struct getdns_list *list) if (list->items) GETDNS_FREE(list->mf, list->items); GETDNS_FREE(list->mf, list); - return GETDNS_RETURN_GOOD; } /* getdns_list_destroy */ /*---------------------------------------- getdns_list_add_item */ diff --git a/src/test/check_getdns_common.c b/src/test/check_getdns_common.c index 8fc9033d..f122d1fa 100644 --- a/src/test/check_getdns_common.c +++ b/src/test/check_getdns_common.c @@ -266,8 +266,7 @@ void destroy_callbackfn(struct getdns_context *context, int* flag = (int*)userarg; *flag = 1; getdns_dict_destroy(response); - ck_assert_msg(getdns_context_destroy(context) != GETDNS_RETURN_GOOD, - "Expected getdns_context_destroy to not succeed"); + getdns_context_destroy(context); } /* diff --git a/src/test/check_getdns_common.h b/src/test/check_getdns_common.h index c00ef97a..4639ec39 100644 --- a/src/test/check_getdns_common.h +++ b/src/test/check_getdns_common.h @@ -86,9 +86,7 @@ * destroy the current context. */ #define CONTEXT_DESTROY \ - ASSERT_RC(getdns_context_destroy(context), \ - GETDNS_RETURN_GOOD, \ - "Return code from getdns_context_destroy()"); + getdns_context_destroy(context); /* * The EVENT_BASE_CREATE macro is used to diff --git a/src/test/check_getdns_context_destroy.h b/src/test/check_getdns_context_destroy.h index e772cb07..582fe842 100644 --- a/src/test/check_getdns_context_destroy.h +++ b/src/test/check_getdns_context_destroy.h @@ -294,9 +294,10 @@ 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); - tcase_add_test(tc_pos, getdns_context_destroy_7); - tcase_add_test(tc_pos, getdns_context_destroy_8); - tcase_add_test(tc_pos, getdns_context_destroy_9); + // raise aborts via assertion failures + 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); suite_add_tcase(s, tc_pos); return s;