Ignore:
Timestamp:
08/04/16 16:24:20 (8 years ago)
Author:
rlacroix
Message:

Fix the client/server communication protocol.

In the some extreme cases a deadlock could occur. To fix this, the number of buffered events must be properly limited.

If you noticed decreased performance due to this commit, please let us know about it.

Fixes ticket #91.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/buffer_client.cpp

    r732 r917  
    1212  size_t CClientBuffer::maxRequestSize = 0; 
    1313 
    14   CClientBuffer::CClientBuffer(MPI_Comm interComm_, int serverRank_, StdSize bfSize) 
     14  CClientBuffer::CClientBuffer(MPI_Comm interComm, int serverRank, StdSize bufferSize, StdSize maxBufferedEvents) 
     15    : interComm(interComm) 
     16    , serverRank(serverRank) 
     17    , bufferSize(bufferSize) 
     18    , current(0) 
     19    , count(0) 
     20    , bufferedEvents(0) 
     21    , maxBufferedEvents(maxBufferedEvents) 
     22    , pending(false) 
    1523  { 
    16     interComm = interComm_; 
    17     serverRank = serverRank_; 
    18     bufferSize = bfSize; 
    1924    buffer[0] = new char[bufferSize]; // transform it with MPI_ALLOC_MEM later 
    2025    buffer[1] = new char[bufferSize]; 
    21     current = 0; 
    22     count = 0; 
    23     pending = false; 
    2426    retBuffer = new CBufferOut(buffer[current], bufferSize); 
    25     info(10) << "CClientBuffer: allocated " << bufferSize << " bytes for server " << serverRank_ << endl; 
     27    info(10) << "CClientBuffer: allocated 2 x " << bufferSize << " bytes for server " << serverRank << " with a maximum of " << maxBufferedEvents << " buffered events" << endl; 
    2628  } 
    2729 
     
    4648            << "The requested size (" << size << " bytes) is too big to fit the buffer (" << bufferSize << " bytes), please increase the client buffer size." << endl); 
    4749 
    48     return (size <= remain()); 
     50    return (size <= remain() && bufferedEvents < maxBufferedEvents); 
    4951  } 
    5052 
     
    5658      retBuffer->realloc(buffer[current] + count, size); 
    5759      count += size; 
     60      bufferedEvents++; 
    5861      return retBuffer; 
    5962    } 
     
    8891        else current = 1; 
    8992        count = 0; 
     93        bufferedEvents = 0; 
    9094      } 
    9195    } 
Note: See TracChangeset for help on using the changeset viewer.