Changeset 5626

Show
Ignore:
Timestamp:
10/29/09 16:57:02 (4 weeks ago)
Author:
goodell
Message:

Fix errhandler leak in C++ introduced in r850.

The fix so that MPI::ERRORS_THROW_EXCEPTIONS actually throws (r850)
caused us to leak errhandlers in C++ when using Call_errhandler because
Get_errhandler (correctly) adds a reference to the errhandler that must
be released by calling Errhandler::Free.

Reviewed by robl@.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • mpich2/trunk/src/binding/cxx/buildiface

    r5253 r5626  
    25292529void Comm::Call_errhandler( int errorcode ) const 
    25302530{ 
    2531     if (Get_errhandler() == ERRORS_THROW_EXCEPTIONS) { 
     2531    // we must free the Errhandler object returned from Get_errhandler because 
     2532    // Get_errhandler adds a reference (the MPI Standard says as though a new 
     2533    // object were created) 
     2534    Errhandler current = Get_errhandler(); 
     2535    if (current == ERRORS_THROW_EXCEPTIONS) { 
     2536        current.Free(); 
    25322537        throw Exception(errorcode); // throw by value, catch by reference 
     2538    } 
     2539    else { 
     2540        current.Free(); 
    25332541    } 
    25342542    MPIX_CALL( MPI_Comm_call_errhandler( (MPI_Comm) the_real_comm, errorcode )); 
     
    25372545void Win::Call_errhandler( int errorcode ) const 
    25382546{ 
    2539     if (Get_errhandler() == ERRORS_THROW_EXCEPTIONS) { 
     2547    // we must free the Errhandler object returned from Get_errhandler because 
     2548    // Get_errhandler adds a reference (the MPI Standard says as though a new 
     2549    // object were created) 
     2550    Errhandler current = Get_errhandler(); 
     2551    if (current == ERRORS_THROW_EXCEPTIONS) { 
     2552        current.Free(); 
    25402553        throw Exception(errorcode); // throw by value, catch by reference 
     2554    } 
     2555    else { 
     2556        current.Free(); 
    25412557    } 
    25422558    MPIX_CALL( MPI_Win_call_errhandler( (MPI_Win) the_real_win, errorcode )); 
     
    25462562void File::Call_errhandler( int errorcode ) const 
    25472563{ 
    2548     if (Get_errhandler() == ERRORS_THROW_EXCEPTIONS) { 
     2564    // we must free the Errhandler object returned from Get_errhandler because 
     2565    // Get_errhandler adds a reference (the MPI Standard says as though a new 
     2566    // object were created) 
     2567    Errhandler current = Get_errhandler(); 
     2568    if (current == ERRORS_THROW_EXCEPTIONS) { 
     2569        current.Free(); 
    25492570        throw Exception(errorcode); // throw by value, catch by reference 
     2571    } 
     2572    else { 
     2573        current.Free(); 
    25502574    } 
    25512575    MPIX_CALL( MPI_File_call_errhandler( (MPI_File) the_real_file, errorcode ));