Skip to content

Commit 1908821

Browse files
committed
Clean up bad response logic a bit
1 parent e7f66f8 commit 1908821

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

src/lib.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ impl InnerConnection {
417417
}
418418

419419
fn read_message(&mut self) -> IoResult<BackendMessage> {
420-
debug_assert!(!self.desynchronized);
421420
loop {
422421
match try!(self.read_message_with_notification()) {
423422
NotificationResponse { pid, channel, payload } => {
@@ -460,19 +459,13 @@ impl InnerConnection {
460459
| AuthenticationGSS
461460
| AuthenticationSSPI => return Err(ConnectError::UnsupportedAuthentication),
462461
ErrorResponse { fields } => return DbError::new_connect(fields),
463-
_ => {
464-
self.desynchronized = true;
465-
return Err(ConnectError::BadResponse);
466-
}
462+
_ => return Err(ConnectError::BadResponse)
467463
}
468464

469465
match try!(self.read_message()) {
470466
AuthenticationOk => Ok(()),
471467
ErrorResponse { fields } => return DbError::new_connect(fields),
472-
_ => {
473-
self.desynchronized = true;
474-
return Err(ConnectError::BadResponse);
475-
}
468+
_ => return Err(ConnectError::BadResponse)
476469
}
477470
}
478471

@@ -584,10 +577,7 @@ impl InnerConnection {
584577
let resp = match try!(self.read_message()) {
585578
CloseComplete => Ok(()),
586579
ErrorResponse { fields } => DbError::new(fields),
587-
_ => {
588-
self.desynchronized = true;
589-
return Err(Error::BadResponse);
590-
}
580+
_ => bad_response!(self)
591581
};
592582
try!(self.wait_for_ready());
593583
resp

0 commit comments

Comments
 (0)