Skip to content
This repository was archived by the owner on Jul 27, 2022. It is now read-only.

Commit 8bc35ce

Browse files
bors[bot]tomtau
andauthored
Merge #672
672: Problem: random broken pipe failures in sgx-cargo-1804-hw2 r=tomtau a=tomtau Solution: added more details to error messages to know where exactly it failed + explicit flushing after writing to streams Co-authored-by: Tomas Tauber <[email protected]>
2 parents 637e803 + 1091f5f commit 8bc35ce

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

chain-tx-enclave/tx-query/enclave/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ fn handle_decryption_request(
100100
let _ = tls.sock.shutdown(Shutdown::Both);
101101
return sgx_status_t::SGX_ERROR_UNEXPECTED;
102102
}
103+
let _ = tls.flush();
103104

104105
match tls.read(&mut plain) {
105106
Ok(l) => {
@@ -113,6 +114,7 @@ fn handle_decryption_request(
113114
}
114115
if let Some(reply) = process_decryption_request(&dr.body) {
115116
let _ = tls.write(&reply.encode());
117+
let _ = tls.flush();
116118
} else {
117119
let _ = tls.sock.shutdown(Shutdown::Both);
118120
return sgx_status_t::SGX_ERROR_INVALID_PARAMETER;
@@ -246,6 +248,7 @@ fn handle_encryption_request(
246248
let _ = tls.write(&EncryptionResponse { resp: Err(e) }.encode());
247249
}
248250
};
251+
let _ = tls.flush();
249252
sgx_status_t::SGX_SUCCESS
250253
}
251254
_ => {

client-core/src/cipher/default.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,15 @@ impl TransactionObfuscation for DefaultTransactionObfuscation {
8181
.chain(|| {
8282
(
8383
ErrorKind::IoError,
84-
"Unable to write to TQE connection stream",
84+
"Unable to write to TQE connection stream (init decrypt)",
8585
)
8686
})?;
87+
tls.flush().chain(|| {
88+
(
89+
ErrorKind::IoError,
90+
"Unable to write to TQE connection stream (init decrypt flush)",
91+
)
92+
})?;
8793
let mut challenge = [0u8; 33];
8894
tls.read_exact(&mut challenge).chain(|| {
8995
(
@@ -112,10 +118,15 @@ impl TransactionObfuscation for DefaultTransactionObfuscation {
112118
tls.write_all(&request.encode()).chain(|| {
113119
(
114120
ErrorKind::IoError,
115-
"Unable to write to TQE connection stream",
121+
"Unable to write to TQE connection stream (decrypt request)",
122+
)
123+
})?;
124+
tls.flush().chain(|| {
125+
(
126+
ErrorKind::IoError,
127+
"Unable to write to TQE connection stream (decrypt request flush)",
116128
)
117129
})?;
118-
119130
let mut plaintext = Vec::new();
120131
let result = match tls.read_to_end(&mut plaintext) {
121132
Ok(_) => {
@@ -186,7 +197,13 @@ impl TransactionObfuscation for DefaultTransactionObfuscation {
186197
tls.write_all(&request.encode()).chain(|| {
187198
(
188199
ErrorKind::IoError,
189-
"Unable to write to TQE connection stream",
200+
"Unable to write to TQE connection stream (encrypt request)",
201+
)
202+
})?;
203+
tls.flush().chain(|| {
204+
(
205+
ErrorKind::IoError,
206+
"Unable to write to TQE connection stream (encrypt request flush)",
190207
)
191208
})?;
192209
let mut plaintext = Vec::new();

0 commit comments

Comments
 (0)