~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to src/mongo/db/commands.cpp

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include "pch.h"
21
 
#include "jsobj.h"
22
 
#include "commands.h"
23
 
#include "client.h"
24
 
#include "replutil.h"
 
21
 
 
22
#include "mongo/db/commands.h"
 
23
 
 
24
#include <string>
 
25
#include <vector>
 
26
 
 
27
#include "mongo/db/auth/action_set.h"
 
28
#include "mongo/db/auth/action_type.h"
 
29
#include "mongo/db/auth/authorization_manager.h"
 
30
#include "mongo/db/auth/privilege.h"
 
31
#include "mongo/db/client.h"
 
32
#include "mongo/db/jsobj.h"
 
33
#include "mongo/db/replutil.h"
 
34
#include "mongo/db/server_parameters.h"
25
35
 
26
36
namespace mongo {
27
37
 
29
39
    map<string,Command*> * Command::_webCommands;
30
40
    map<string,Command*> * Command::_commands;
31
41
 
 
42
    int Command::testCommandsEnabled = 0;
 
43
 
 
44
    namespace {
 
45
        ExportedServerParameter<int> testCommandsParameter(ServerParameterSet::getGlobal(),
 
46
                                                           "enableTestCommands",
 
47
                                                           &Command::testCommandsEnabled,
 
48
                                                           true,
 
49
                                                           false);
 
50
    }
 
51
 
32
52
    string Command::parseNsFullyQualified(const string& dbname, const BSONObj& cmdObj) const { 
33
53
        string s = cmdObj.firstElement().valuestr();
34
54
        NamespaceString nss(s);
153
173
        return i->second;
154
174
    }
155
175
 
156
 
 
157
176
    Command::LockType Command::locktype( const string& name ) {
158
177
        Command * c = findCommand( name );
159
178
        if ( ! c )
161
180
        return c->locktype();
162
181
    }
163
182
 
 
183
    void Command::appendCommandStatus(BSONObjBuilder& result, bool ok, const std::string& errmsg) {
 
184
        BSONObj tmp = result.asTempObj();
 
185
        bool have_ok = tmp.hasField("ok");
 
186
        bool have_errmsg = tmp.hasField("errmsg");
 
187
 
 
188
        if (!have_ok)
 
189
            result.append( "ok" , ok ? 1.0 : 0.0 );
 
190
 
 
191
        if (!ok && !have_errmsg) {
 
192
            result.append("errmsg", errmsg);
 
193
        }
 
194
    }
 
195
 
164
196
    void Command::logIfSlow( const Timer& timer, const string& msg ) {
165
197
        int ms = timer.millis();
166
198
        if ( ms > cmdLine.slowMS ) {
181
213
        PoolFlushCmd() : Command( "connPoolSync" , false , "connpoolsync" ) {}
182
214
        virtual void help( stringstream &help ) const { help<<"internal"; }
183
215
        virtual LockType locktype() const { return NONE; }
 
216
        virtual void addRequiredPrivileges(const std::string& dbname,
 
217
                                           const BSONObj& cmdObj,
 
218
                                           std::vector<Privilege>* out) {
 
219
            ActionSet actions;
 
220
            actions.addAction(ActionType::connPoolSync);
 
221
            out->push_back(Privilege(AuthorizationManager::SERVER_RESOURCE_NAME, actions));
 
222
        }
184
223
        virtual bool run(const string&, mongo::BSONObj&, int, std::string&, mongo::BSONObjBuilder& result, bool) {
185
224
            pool.flush();
186
225
            return true;
196
235
        PoolStats() : Command( "connPoolStats" ) {}
197
236
        virtual void help( stringstream &help ) const { help<<"stats about connection pool"; }
198
237
        virtual LockType locktype() const { return NONE; }
 
238
        virtual void addRequiredPrivileges(const std::string& dbname,
 
239
                                           const BSONObj& cmdObj,
 
240
                                           std::vector<Privilege>* out) {
 
241
            ActionSet actions;
 
242
            actions.addAction(ActionType::connPoolStats);
 
243
            out->push_back(Privilege(AuthorizationManager::SERVER_RESOURCE_NAME, actions));
 
244
        }
199
245
        virtual bool run(const string&, mongo::BSONObj&, int, std::string&, mongo::BSONObjBuilder& result, bool) {
200
246
            pool.appendInfo( result );
201
247
            result.append( "numDBClientConnection" , DBClientConnection::getNumConnections() );