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

« back to all changes in this revision

Viewing changes to src/mongo/db/repl_block.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:
44
44
 
45
45
        struct Ident {
46
46
 
47
 
            Ident(const BSONObj& r, const string& h, const string& n) {
 
47
            Ident(const BSONObj& r, const BSONObj& config, const string& n) {
48
48
                BSONObjBuilder b;
49
49
                b.appendElements( r );
50
 
                b.append( "host" , h );
 
50
                b.append( "config" , config );
51
51
                b.append( "ns" , n );
52
52
                obj = b.obj();
53
53
            }
115
115
            _slaves.clear();
116
116
        }
117
117
 
118
 
        void update( const BSONObj& rid , const string& host , const string& ns , OpTime last ) {
119
 
            REPLDEBUG( host << " " << rid << " " << ns << " " << last );
 
118
        void update( const BSONObj& rid , const BSONObj config , const string& ns , OpTime last ) {
 
119
            REPLDEBUG( config << " " << rid << " " << ns << " " << last );
120
120
 
121
 
            Ident ident(rid,host,ns);
 
121
            Ident ident(rid, config, ns);
122
122
 
123
123
            scoped_lock mylk(_mutex);
124
124
 
206
206
            return numSlaves <= 0;
207
207
        }
208
208
 
 
209
        std::vector<BSONObj> getHostsAtOp(OpTime& op) {
 
210
            std::vector<BSONObj> result;
 
211
            if (theReplSet) {
 
212
                result.push_back(theReplSet->myConfig().asBson());
 
213
            }
 
214
 
 
215
            scoped_lock mylk(_mutex);
 
216
            for (map<Ident,OpTime>::iterator i = _slaves.begin(); i != _slaves.end(); i++) {
 
217
                OpTime replicatedTo = i->second;
 
218
                if (replicatedTo >= op) {
 
219
                    result.push_back(i->first.obj["config"].Obj());
 
220
                }
 
221
            }
 
222
 
 
223
            return result;
 
224
        }
209
225
 
210
226
        unsigned getSlaveCount() const {
211
227
            scoped_lock mylk(_mutex);
238
254
        if ( rid.isEmpty() )
239
255
            return;
240
256
 
241
 
        slaveTracking.update( rid , curop.getRemoteString( false ) , ns , lastOp );
 
257
        BSONObj handshake = c->getHandshake();
 
258
        if (handshake.hasField("config")) {
 
259
            slaveTracking.update(rid, handshake["config"].Obj(), ns, lastOp);
 
260
        }
 
261
        else {
 
262
            BSONObjBuilder bob;
 
263
            bob.append("host", curop.getRemoteString());
 
264
            bob.append("upgradeNeeded", true);
 
265
            slaveTracking.update(rid, bob.done(), ns, lastOp);
 
266
        }
242
267
 
243
268
        if (theReplSet && !theReplSet->isPrimary()) {
244
269
            // we don't know the slave's port, so we make the replica set keep
260
285
        return slaveTracking.waitForReplication( op, w, maxSecondsToWait );
261
286
    }
262
287
 
 
288
    vector<BSONObj> getHostsWrittenTo(OpTime& op) {
 
289
        return slaveTracking.getHostsAtOp(op);
 
290
    }
263
291
 
264
292
    void resetSlaveCache() {
265
293
        slaveTracking.reset();