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

« back to all changes in this revision

Viewing changes to src/mongo/s/client_info.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:
17
17
 */
18
18
 
19
19
#include "pch.h"
 
20
 
 
21
#include "mongo/db/auth/authorization_manager.h"
 
22
#include "mongo/db/auth/auth_external_state_s.h"
20
23
#include "server.h"
21
24
#include "../util/scopeguard.h"
22
25
#include "../db/commands.h"
 
26
#include "../db/commands/server_status.h"
23
27
#include "../db/dbmessage.h"
24
28
#include "../db/stats/counters.h"
 
29
#include "../db/stats/timer_stats.h"
25
30
 
26
31
#include "../client/connpool.h"
27
32
 
29
34
#include "request.h"
30
35
#include "config.h"
31
36
#include "chunk.h"
32
 
#include "stats.h"
33
37
#include "cursors.h"
34
38
#include "grid.h"
35
39
#include "s/writeback_listener.h"
 
40
#include "mongo/util/mongoutils/str.h"
36
41
 
37
42
namespace mongo {
38
43
 
39
 
    ClientInfo::ClientInfo() {
 
44
    ClientInfo::ClientInfo(AbstractMessagingPort* messagingPort) : ClientBasic(messagingPort) {
40
45
        _cur = &_a;
41
46
        _prev = &_b;
42
47
        _autoSplitOk = true;
43
 
        newRequest();
 
48
        if (messagingPort) {
 
49
            _remote = messagingPort->remote();
 
50
        }
44
51
    }
45
52
 
46
53
    ClientInfo::~ClientInfo() {
70
77
        _cur = _prev;
71
78
        _prev = temp;
72
79
        _cur->clear();
73
 
        _ai.startRequest();
74
 
    }
75
 
 
76
 
    ClientInfo * ClientInfo::get() {
77
 
        ClientInfo * info = _tlInfo.get();
78
 
        if ( ! info ) {
79
 
            info = new ClientInfo();
80
 
            _tlInfo.reset( info );
81
 
            info->newRequest();
 
80
        getAuthorizationManager()->startRequest();
 
81
    }
 
82
 
 
83
    ClientInfo* ClientInfo::create(AbstractMessagingPort* messagingPort) {
 
84
        ClientInfo * info = _tlInfo.get();
 
85
        massert(16472, "A ClientInfo already exists for this thread", !info);
 
86
        info = new ClientInfo(messagingPort);
 
87
        info->setAuthorizationManager(new AuthorizationManager(new AuthExternalStateMongos()));
 
88
        _tlInfo.reset( info );
 
89
        info->newRequest();
 
90
        return info;
 
91
    }
 
92
 
 
93
    ClientInfo * ClientInfo::get(AbstractMessagingPort* messagingPort) {
 
94
        ClientInfo * info = _tlInfo.get();
 
95
        if (!info) {
 
96
            info = create(messagingPort);
82
97
        }
 
98
        massert(16483,
 
99
                mongoutils::str::stream() << "AbstractMessagingPort was provided to ClientInfo::get"
 
100
                        << " but differs from the one stored in the current ClientInfo object. "
 
101
                        << "Current ClientInfo messaging port "
 
102
                        << (info->port() ? "is not" : "is")
 
103
                        << " NULL",
 
104
                messagingPort == NULL || messagingPort == info->port());
83
105
        return info;
84
106
    }
85
107
 
147
169
        _prev = temp;
148
170
    }
149
171
 
 
172
    static TimerStats gleWtimeStats;
 
173
    static ServerStatusMetricField<TimerStats> displayGleLatency( "getLastError.wtime", &gleWtimeStats );
 
174
 
150
175
    bool ClientInfo::getLastError( const string& dbName,
151
176
                                   const BSONObj& options,
152
177
                                   BSONObjBuilder& result,
154
179
                                   bool fromWriteBackListener)
155
180
    {
156
181
 
 
182
        scoped_ptr<TimerHolder> gleTimerHolder;
 
183
        if ( ! fromWriteBackListener ) {
 
184
            bool doTiming = false;
 
185
            const BSONElement& e = options["w"];
 
186
            if ( e.isNumber() ) {
 
187
                doTiming = e.numberInt() > 1;
 
188
            }
 
189
            else if ( e.type() == String ) {
 
190
                doTiming = true;
 
191
            }
 
192
            if ( doTiming ) {
 
193
                gleTimerHolder.reset( new TimerHolder( &gleWtimeStats ) );
 
194
            }
 
195
        }
 
196
 
 
197
 
157
198
        set<string> * shards = getPrev();
158
199
 
159
200
        if ( shards->size() == 0 ) {