Redefine Close behavior:

- When Participant A was closed by remote side. Then a `disconnect` on `A`
   shall return Ok() (instead of ParticipantDisconected) IF:
   A was already flushed and no data needs to be sended any more.
 so a `disconnect` doesnt differ if the other side initiated the disconnect before or not. it tries to clean things up and returns Ok(()) if both sides agree
This commit is contained in:
Marcel Märtens 2020-08-24 16:09:28 +02:00
parent 91d296cda1
commit 5fe7c05d9c
2 changed files with 5 additions and 6 deletions

View File

@ -667,7 +667,10 @@ impl BParticipant {
sender
.send(match lock.error.take() {
None => Ok(()),
Some(e) => Err(e),
Some(ParticipantError::ProtocolFailedUnrecoverable) => {
Err(ParticipantError::ProtocolFailedUnrecoverable)
},
Some(ParticipantError::ParticipantDisconnected) => Ok(()),
})
.unwrap();

View File

@ -42,11 +42,7 @@ fn close_participant() {
let (_n_a, p1_a, mut s1_a, _n_b, p1_b, mut s1_b) = block_on(network_participant_stream(tcp()));
block_on(p1_a.disconnect()).unwrap();
//As no more read/write is run disconnect is successful or already disconnected
match block_on(p1_b.disconnect()) {
Ok(_) | Err(ParticipantError::ParticipantDisconnected) => (),
e => panic!("wrong disconnect type {:?}", e),
};
block_on(p1_b.disconnect()).unwrap();
assert_eq!(s1_a.send("Hello World"), Err(StreamError::StreamClosed));
assert_eq!(