From debf4842ebd1cb08e3d6a119939d1a6ac456f882 Mon Sep 17 00:00:00 2001 From: Tim Woodall Date: Tue, 10 Aug 2004 21:02:36 +0000 Subject: [PATCH] cleanup close/finalize This commit was SVN r2013. --- src/mca/oob/base/oob_base_close.c | 23 +++++---------- src/mca/oob/cofs/src/oob_cofs.h | 2 +- src/mca/oob/cofs/src/oob_cofs_component.c | 8 ++--- src/mca/oob/oob.h | 36 +++++++++++++---------- src/mca/oob/tcp/oob_tcp.c | 10 +++---- src/mca/oob/tcp/oob_tcp.h | 2 +- 6 files changed, 39 insertions(+), 42 deletions(-) diff --git a/src/mca/oob/base/oob_base_close.c b/src/mca/oob/base/oob_base_close.c index 21bff5f45f..51fba828f9 100644 --- a/src/mca/oob/base/oob_base_close.c +++ b/src/mca/oob/base/oob_base_close.c @@ -16,26 +16,19 @@ int mca_oob_base_close(void) { ompi_list_item_t* item; - /* Finalize all the ptl components and free their list items */ - - for (item = ompi_list_remove_first(&mca_oob_base_components); - NULL != item; - item = ompi_list_remove_first(&mca_oob_base_components)) { - mca_base_component_list_item_t* component = (mca_base_component_list_item_t *) item; - - /* Blatently ignore the return code (what would we do to recover, - anyway? This component is going away, so errors don't matter - anymore) */ - - ((mca_oob_base_component_t*)component->cli_component)->oob_finalize(); - free(component); + + /* Finalize all the oob modules and free their list items */ + for (item = ompi_list_remove_first(&mca_oob_base_modules); + item != NULL; + item = ompi_list_remove_first(&mca_oob_base_modules)) { + mca_oob_base_info_t* base = (mca_oob_base_info_t *) item; + base->oob_module->oob_finalize(base->oob_module); } /* Close all remaining available modules (may be one if this is a OMPI RTE program, or [possibly] multiple if this is ompi_info) */ - mca_base_components_close(mca_oob_base_output, &mca_oob_base_components, - NULL); + mca_base_components_close(mca_oob_base_output, &mca_oob_base_components, NULL); OBJ_DESTRUCT(&mca_oob_base_modules); OBJ_DESTRUCT(&mca_oob_base_components); diff --git a/src/mca/oob/cofs/src/oob_cofs.h b/src/mca/oob/cofs/src/oob_cofs.h index a0d8235d31..f70ef3d653 100644 --- a/src/mca/oob/cofs/src/oob_cofs.h +++ b/src/mca/oob/cofs/src/oob_cofs.h @@ -22,7 +22,7 @@ int mca_oob_cofs_close(void); * Startup / Shutdown */ mca_oob_t* mca_oob_cofs_init(bool *allow_multi_user_threads, bool *have_hidden_threads); -int mca_oob_cofs_finalize(void); +int mca_oob_cofs_finalize(mca_oob_t*); diff --git a/src/mca/oob/cofs/src/oob_cofs_component.c b/src/mca/oob/cofs/src/oob_cofs_component.c index 07c066049c..e779a8df2d 100644 --- a/src/mca/oob/cofs/src/oob_cofs_component.c +++ b/src/mca/oob/cofs/src/oob_cofs_component.c @@ -37,15 +37,15 @@ mca_oob_base_component_1_0_0_t mca_oob_cofs_component = { { false /* checkpoint / restart */ }, - mca_oob_cofs_init, /* module init */ - mca_oob_cofs_finalize + mca_oob_cofs_init /* module init */ }; mca_oob_t mca_oob_cofs = { mca_oob_cofs_send, mca_oob_cofs_recv, mca_oob_cofs_send_nb, - mca_oob_cofs_recv_nb + mca_oob_cofs_recv_nb, + mca_oob_cofs_finalize }; char mca_oob_cofs_comm_loc[OMPI_PATH_MAX]; @@ -90,7 +90,7 @@ mca_oob_t* mca_oob_cofs_init(bool *allow_multi_user_threads, bool *have_hidden_t } -int mca_oob_cofs_finalize(void) +int mca_oob_cofs_finalize(mca_oob_t* oob) { return OMPI_SUCCESS; } diff --git a/src/mca/oob/oob.h b/src/mca/oob/oob.h index 2c8457e70f..b54fccc56f 100644 --- a/src/mca/oob/oob.h +++ b/src/mca/oob/oob.h @@ -14,6 +14,19 @@ #include "include/types.h" #include "mca/mca.h" #include "mca/oob/base/base.h" + +struct mca_oob_1_0_0_t; + +/** + * Convenience Typedef + */ +typedef struct mca_oob_1_0_0_t mca_oob_1_0_0_t; +/** + * Convenience typedef + */ +typedef struct mca_oob_1_0_0_t mca_oob_t; + + /******** * NOTE: these are functions and prototypes for the use of the modules * and components. @@ -108,6 +121,11 @@ typedef int (*mca_oob_base_module_recv_nb_fn_t)( mca_oob_callback_fn_t cbfunc, void* cbdata); +/** + * OOB finalize function + */ +typedef int (*mca_oob_base_module_finalize_fn_t)(mca_oob_t*); + /** * OOB Module */ @@ -116,16 +134,8 @@ struct mca_oob_1_0_0_t { mca_oob_base_module_recv_fn_t oob_recv; mca_oob_base_module_send_nb_fn_t oob_send_nb; mca_oob_base_module_recv_nb_fn_t oob_recv_nb; + mca_oob_base_module_finalize_fn_t oob_finalize; }; -/** - * Convenience Typedef - */ -typedef struct mca_oob_1_0_0_t mca_oob_1_0_0_t; -/** - * Convenience typedef - */ -typedef struct mca_oob_1_0_0_t mca_oob_t; - /** * OOB Component */ @@ -133,21 +143,15 @@ typedef mca_oob_t* (*mca_oob_base_component_init_fn_t)( bool *allow_multi_user_threads, bool *have_hidden_threads); -/** - * OOB finalize function - */ -typedef int (*mca_oob_base_component_finalize_fn_t)(void); - /** * the standard component data structure */ struct mca_oob_base_component_1_0_0_t { mca_base_component_t oob_version; mca_base_component_data_1_0_0_t oob_data; - mca_oob_base_component_init_fn_t oob_init; - mca_oob_base_component_finalize_fn_t oob_finalize; }; + /** * Convenience Typedef */ diff --git a/src/mca/oob/tcp/oob_tcp.c b/src/mca/oob/tcp/oob_tcp.c index aa9c266fb5..20c122a8c2 100644 --- a/src/mca/oob/tcp/oob_tcp.c +++ b/src/mca/oob/tcp/oob_tcp.c @@ -33,8 +33,7 @@ mca_oob_tcp_component_t mca_oob_tcp_component = { { false /* checkpoint / restart */ }, - mca_oob_tcp_init, /* module init */ - mca_oob_tcp_finalize + mca_oob_tcp_init /* module init */ } }; @@ -42,7 +41,8 @@ static mca_oob_t mca_oob_tcp = { mca_oob_tcp_send, mca_oob_tcp_recv, mca_oob_tcp_send_nb, - mca_oob_tcp_recv_nb + mca_oob_tcp_recv_nb, + mca_oob_tcp_finalize }; @@ -279,7 +279,7 @@ mca_oob_t* mca_oob_tcp_init(bool *allow_multi_user_threads, bool *have_hidden_th 8, /* increment to grow by */ NULL); /* use default allocator */ -#if 0 +#if 1 /* intialize event library */ memset(&mca_oob_tcp_component.tcp_recv_event, 0, sizeof(ompi_event_t)); memset(&mca_oob_tcp_component.tcp_send_event, 0, sizeof(ompi_event_t)); @@ -303,7 +303,7 @@ mca_oob_t* mca_oob_tcp_init(bool *allow_multi_user_threads, bool *have_hidden_th /* * Module cleanup. */ -int mca_oob_tcp_finalize(void) +int mca_oob_tcp_finalize(mca_oob_t* oob) { int optval; mca_oob_tcp_peer_t * peer; diff --git a/src/mca/oob/tcp/oob_tcp.h b/src/mca/oob/tcp/oob_tcp.h index cabf095801..70751e8e10 100644 --- a/src/mca/oob/tcp/oob_tcp.h +++ b/src/mca/oob/tcp/oob_tcp.h @@ -31,7 +31,7 @@ extern "C" { int mca_oob_tcp_open(void); int mca_oob_tcp_close(void); mca_oob_t* mca_oob_tcp_init(bool *allow_multi_user_threads, bool *have_hidden_threads); -int mca_oob_tcp_finalize(void); +int mca_oob_tcp_finalize(mca_oob_t*); /** * Convert process name from network to host byte order.