diff --git a/arch/x86/include/asm/iRCCE.h b/arch/x86/include/asm/iRCCE.h index 5c0edfc3..7c071d5b 100644 --- a/arch/x86/include/asm/iRCCE.h +++ b/arch/x86/include/asm/iRCCE.h @@ -134,6 +134,7 @@ typedef struct _iRCCE_MAIL_TRASH_BIN { // // Initialize/Finalize functions: int iRCCE_init(void); +int iRCCE_finalize(void); // // Non-blocking send/recv functions: int iRCCE_isend(char *, ssize_t, int, iRCCE_SEND_REQUEST *); diff --git a/arch/x86/scc/iRCCE_admin.c b/arch/x86/scc/iRCCE_admin.c index ba465765..2a28f09e 100644 --- a/arch/x86/scc/iRCCE_admin.c +++ b/arch/x86/scc/iRCCE_admin.c @@ -109,4 +109,23 @@ int iRCCE_init(void) { return (iRCCE_SUCCESS); } +//-------------------------------------------------------------------------------------- +// FUNCTION: iRCCE_finalize +//-------------------------------------------------------------------------------------- +// finalize the library +//-------------------------------------------------------------------------------------- +int iRCCE_finalize(void) { + // empty iRCCE_mail_garbage + iRCCE_MAIL_HEADER* run; + iRCCE_MAIL_HEADER* erase_header; + + for( run = iRCCE_mail_garbage.first; run != NULL; ) { + erase_header = run; + run = run->next; + kfree( erase_header, sizeof(iRCCE_MAIL_HEADER) ); + } + + iRCCE_mail_garbage.first = iRCCE_mail_garbage.last = NULL; + return iRCCE_SUCCESS; +} #endif diff --git a/arch/x86/scc/iRCCE_mailbox.c b/arch/x86/scc/iRCCE_mailbox.c index 4c235da9..8b14480a 100644 --- a/arch/x86/scc/iRCCE_mailbox.c +++ b/arch/x86/scc/iRCCE_mailbox.c @@ -33,6 +33,10 @@ #ifdef CONFIG_ROCKCREEK #include +// forward declaration +static int iRCCE_mailbox_close_one(int rank, int check); + + //------------------------------------------------------------------------------ // FUNCTION: iRCCE_mailbox_print_header //------------------------------------------------------------------------------ @@ -90,8 +94,8 @@ static int iRCCE_mail_fetch( // check if received a last-mail if( header->tag == iRCCE_LAST_MAIL ) { iRCCE_last_mail[rank] = 1; - iRCCE_mailbox_close( rank ); // we can close respective mailbox - kfree( header, sizeof(iRCCE_MAIL_HEADER) ); + iRCCE_mailbox_close_one( rank, 0 ); // we can close respective mailbox + iRCCE_mail_release( &header ); } else { // check mail priority @@ -119,8 +123,7 @@ static int iRCCE_mail_fetch( // routine to check for new mail in mailboxes //------------------------------------------------------------------------------ static int iRCCE_mailbox_check() { - int i, j; - int tmp; + int i; for( i=0; isent ) { + if( check && iRCCE_mailbox_recv[rank]->sent ) { iRCCE_mail_fetch(rank); } @@ -352,11 +355,11 @@ int iRCCE_mailbox_close(int rank) { if( rank == iRCCE_MAILBOX_ALL ) { int i; for( i=0; i