From 0ebc20205668423748d84786afd9eaeb6a2d7472 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 18 Jan 2001 01:42:11 +0000 Subject: [PATCH] update to implement equivalent of ref count git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12911 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/et/ChangeLog | 7 +++++++ src/util/et/ISSUES | 17 ++++++++++++++--- src/util/et/error_message.c | 27 ++++++--------------------- src/util/et/t_com_err.c | 6 ++++++ 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/util/et/ChangeLog b/src/util/et/ChangeLog index f88ea5c2c..0ab189198 100644 --- a/src/util/et/ChangeLog +++ b/src/util/et/ChangeLog @@ -1,3 +1,10 @@ +2001-01-17 Ken Raeburn + + * error_message.c (add_error_table, remove_error_table): Allow + tables to be entered and removed multiple times, keeping the count + correct. + * t_com_err.c (main): Update to reflect new semantics. + 2001-01-16 Ken Raeburn * Makefile.in (test1.c, test2.c, et1.c, et2.c, test1.h, test2.h, diff --git a/src/util/et/ISSUES b/src/util/et/ISSUES index 1bf9e1087..2197fb7af 100644 --- a/src/util/et/ISSUES +++ b/src/util/et/ISSUES @@ -19,18 +19,24 @@ API divergence: Transarc and Heimdal both have APIs that are different from this version. (Specifics?) +Karl Ramm has offered to try to combine them. + Workaround: -No reference counting: +Reference counting: If libraries are dynamically loaded and unloaded, and the init/fini functions add and remove error tables for *other* libraries they depend on (e.g., if a dynamically loadable Zephyr library's fini function removes the krb4 library error table and then dlcloses the krb4 library, while another dlopen reference keeps the krb4 library -around), the error table is gone, even if the library is still in use. +around), the error table is kept; a table must be removed the same +number of times it was added before the library itself can be +discarded. + +It's not implemented as a reference count, but the effect is the same. -Workaround: None. +Fix needed: Update documentation. 64-bit support: @@ -47,3 +53,8 @@ to keep in mind.... Workaround: Always use signed types of at least 32 bits for error codes. +man page: + +No documentation on add_error_table/remove_error_table interfaces, +even though they're the new, preferred interface. + diff --git a/src/util/et/error_message.c b/src/util/et/error_message.c index 0c9ce1869..1afdeb863 100644 --- a/src/util/et/error_message.c +++ b/src/util/et/error_message.c @@ -1,5 +1,5 @@ /* - * Copyright 1997 by Massachusetts Institute of Technology + * Copyright 1997,2000,2001 by Massachusetts Institute of Technology * * Copyright 1987, 1988 by MIT Student Information Processing Board * @@ -235,19 +235,8 @@ KRB5_DLLIMP errcode_t KRB5_CALLCONV add_error_table(et) /*@dependent@*/ const struct error_table FAR * et; { - struct et_list *el; struct dynamic_et_list *del; - /* Always check both lists, because the old interface code - wouldn't check the dynamically maintained list before adding an - entry to the static list. */ - for (el = _et_list; el != NULL; el = el->next) - if (el->table != NULL && el->table->base == et->base) - return EEXIST; - for (del = et_list_dynamic; del != NULL; del = del->next) - if (del->table->base == et->base) - return EEXIST; - #ifdef _MSDOS if (etl_used < PREALLOCATE_ETL) { el = &etl[etl_used++]; @@ -274,18 +263,15 @@ remove_error_table(et) { struct dynamic_et_list **del; struct et_list **el; - errcode_t ret = ENOENT; - /* Always check both lists, because the old interface code - wouldn't check the dynamically maintained list before adding an - entry to the static list. */ + /* Remove the first occurrance we can find. Prefer dynamic + entries, but if there are none, check for a static one too. */ for (del = &et_list_dynamic; *del; del = &(*del)->next) if ((*del)->table->base == et->base) { /*@only@*/ struct dynamic_et_list *old = *del; *del = old->next; free (old); - ret = 0; - break; + return 0; } for (el = &_et_list; *el; el = &(*el)->next) if ((*el)->table != NULL && (*el)->table->base == et->base) { @@ -297,8 +283,7 @@ remove_error_table(et) if ((old >= etl) && (old < &etl[PREALLOCATE_ETL-1])) /* do something? */; #endif - ret = 0; - break; + return 0; } - return ret; + return ENOENT; } diff --git a/src/util/et/t_com_err.c b/src/util/et/t_com_err.c index f86c31797..c6095cfe1 100644 --- a/src/util/et/t_com_err.c +++ b/src/util/et/t_com_err.c @@ -78,6 +78,8 @@ int main (/*@unused@*/ int argc, /*@unused@*/ char *argv[]) (void) add_error_table (&et_et1_error_table); try_em (1, 0); (void) remove_error_table (&et_et1_error_table); + try_em (1, 0); + (void) remove_error_table (&et_et1_error_table); try_em (0, 0); initialize_et1_error_table (); @@ -87,6 +89,8 @@ int main (/*@unused@*/ int argc, /*@unused@*/ char *argv[]) (void) add_error_table (&et_et2_error_table); try_em (1, 1); (void) remove_error_table (&et_et1_error_table); + try_em (1, 1); + (void) remove_error_table (&et_et1_error_table); try_em (0, 1); (void) remove_error_table (&et_et2_error_table); try_em (0, 0); @@ -102,6 +106,8 @@ int main (/*@unused@*/ int argc, /*@unused@*/ char *argv[]) (void) remove_error_table (&et_et1_error_table); try_em (0, 1); (void) remove_error_table (&et_et2_error_table); + try_em (0, 1); + (void) remove_error_table (&et_et2_error_table); try_em (0, 0); return fail; -- 2.26.2