summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2014-02-10 12:16:04 -0500
committerRandolph Tan <randolph@10gen.com>2014-02-13 10:22:22 -0500
commit78b5eeb13142f0d9bcb43e67848d5fec2f29366d (patch)
tree7e95858944e9384ecb4009a427790287d61872ac /src
parentdb7b5a93e9bdfee1826a91b94a9f8b904be89813 (diff)
downloadmongo-78b5eeb13142f0d9bcb43e67848d5fec2f29366d.tar.gz
SERVER-12596 writeConcern {} and writeConcern {wtimeout: 1000} treated like {w: 0}
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp10
-rw-r--r--src/mongo/db/write_concern_options.cpp4
2 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index f80b313fdb7..5d6ac60f105 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -109,12 +109,18 @@ namespace mongo {
// TODO: Lift write concern parsing out of this entirely.
WriteConcernOptions writeConcern;
Status status = Status::OK();
+
+ BSONObj wcDoc;
if ( request.isWriteConcernSet() ) {
- status = writeConcern.parse( request.getWriteConcern() );
+ wcDoc = request.getWriteConcern();
}
- else {
+
+ if ( wcDoc.isEmpty() ) {
status = writeConcern.parse( _defaultWriteConcern );
}
+ else {
+ status = writeConcern.parse( wcDoc );
+ }
if ( status.isOK() ) {
status = validateWriteConcern( writeConcern );
diff --git a/src/mongo/db/write_concern_options.cpp b/src/mongo/db/write_concern_options.cpp
index 2658797e5e3..db18073a3ac 100644
--- a/src/mongo/db/write_concern_options.cpp
+++ b/src/mongo/db/write_concern_options.cpp
@@ -37,6 +37,9 @@ namespace mongo {
const BSONObj WriteConcernOptions::Unacknowledged(BSON("w" << W_NONE));
Status WriteConcernOptions::parse( const BSONObj& obj ) {
+ if ( obj.isEmpty() ) {
+ return Status( ErrorCodes::BadValue, "write concern object cannot be empty" );
+ }
bool j = obj["j"].trueValue();
bool fsync = obj["fsync"].trueValue();
@@ -61,6 +64,7 @@ namespace mongo {
else if ( e.eoo() ||
e.type() == jstNULL ||
e.type() == Undefined ) {
+ wNumNodes = 1;
}
else {
return Status( ErrorCodes::BadValue, "w has to be a number or a string" );