-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from adickson66/NF-918
NF-918 Guard log statements in RpcWrapper from dereferencing null ses…
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Guard log statements in RpcWrapper from dereferencing null session pointers | ||
|
||
From: nobody <nobody@nowhere> | ||
|
||
|
||
--- | ||
src/RpcWrapper.cc | 12 +++++++++--- | ||
1 file changed, 9 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/src/RpcWrapper.cc b/src/RpcWrapper.cc | ||
index 60b6cb45..fc2c8ff4 100644 | ||
--- a/src/RpcWrapper.cc | ||
+++ b/src/RpcWrapper.cc | ||
@@ -183,7 +183,7 @@ RpcWrapper::isReady() { | ||
|| (responseHeader->status == STATUS_OK)) { | ||
LOG(ERROR, "Response from %s for %s RPC is too short " | ||
"(needed at least %d bytes, got %d)", | ||
- session->serviceLocator.c_str(), | ||
+ session ? session->serviceLocator.c_str() : "(no session)", | ||
WireFormat::opcodeSymbol(&request), | ||
responseHeaderLength, | ||
downCast<int>(response->size())); | ||
@@ -192,6 +192,12 @@ RpcWrapper::isReady() { | ||
// Extend the response buffer to be at least responseHeaderLength | ||
// bytes long. | ||
if (response->size() < responseHeaderLength) { | ||
+ LOG(NOTICE, "Response from %s for %s RPC is too short " | ||
+ "(needed at least %d bytes, got %d) - Extending to required size.", | ||
+ session ? session->serviceLocator.c_str() : "(no session)", | ||
+ WireFormat::opcodeSymbol(&request), | ||
+ responseHeaderLength, | ||
+ downCast<int>(response->size())); | ||
response->alloc(responseHeaderLength - response->size()); | ||
} | ||
} | ||
@@ -217,13 +223,13 @@ RpcWrapper::isReady() { | ||
} | ||
RAMCLOUD_CLOG(NOTICE, | ||
"Server %s returned STATUS_RETRY from %s request: %s", | ||
- session->serviceLocator.c_str(), | ||
+ session ? session->serviceLocator.c_str() : "(no session)", | ||
WireFormat::opcodeSymbol(&request), | ||
message); | ||
} else { | ||
RAMCLOUD_CLOG(NOTICE, | ||
"Server %s returned STATUS_RETRY from %s request", | ||
- session->serviceLocator.c_str(), | ||
+ session ? session->serviceLocator.c_str() : "(no session)", | ||
WireFormat::opcodeSymbol(&request)); | ||
} | ||
retry(retryResponse->minDelayMicros, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters