summaryrefslogtreecommitdiff
path: root/src/mongo/s/request.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2015-04-08 12:08:28 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2015-04-10 14:21:01 -0400
commit46d97a12a533ef20bf43a39c7d8860a80f9b423b (patch)
tree11dfe7843a087adf09319790ceefd09e5630efa4 /src/mongo/s/request.cpp
parent299935f27852884ec9af3fd372fc5e6c98bb5133 (diff)
downloadmongo-46d97a12a533ef20bf43a39c7d8860a80f9b423b.tar.gz
SERVER-17933 Invalid database name check should not close the connection
Diffstat (limited to 'src/mongo/s/request.cpp')
-rw-r--r--src/mongo/s/request.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/mongo/s/request.cpp b/src/mongo/s/request.cpp
index 7827cc17161..c463e19a49f 100644
--- a/src/mongo/s/request.cpp
+++ b/src/mongo/s/request.cpp
@@ -62,25 +62,30 @@ namespace mongo {
}
void Request::init() {
- if ( _didInit )
+ if (_didInit) {
return;
- _didInit = true;
- reset();
- _clientInfo->getAuthorizationSession()->startRequest(NULL);
- }
+ }
- // Deprecated, will move to the strategy itself
- void Request::reset() {
_m.header().setId(_id);
ClusterLastErrorInfo::get(_clientInfo).clearRequestInfo();
- if ( !_d.messageShouldHaveNs()) {
- return;
+ if (_d.messageShouldHaveNs()) {
+ const NamespaceString nss(getns());
+
+ uassert(ErrorCodes::IllegalOperation,
+ "can't use 'local' database through mongos",
+ nss.db() != "local");
+
+ uassert(ErrorCodes::InvalidNamespace,
+ str::stream() << "Invalid ns [" << nss.ns() << "]",
+ nss.isValid());
}
- uassert( 13644 , "can't use 'local' database through mongos" , ! str::startsWith( getns() , "local." ) );
+ _clientInfo->getAuthorizationSession()->startRequest(NULL);
- grid.getDBConfig( getns() );
+ grid.getDBConfig(getns());
+
+ _didInit = true;
}
void Request::process( int attempt ) {
@@ -88,7 +93,7 @@ namespace mongo {
int op = _m.operation();
verify( op > dbMsg );
- int msgId = (int)(_m.header().getId());
+ const MSGID msgId = _m.header().getId();
Timer t;
LOG(3) << "Request::process begin ns: " << getns()