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

« back to all changes in this revision

Viewing changes to src/mongo/db/curop.h

  • 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:
19
19
 
20
20
#pragma once
21
21
 
22
 
#include "namespace-inl.h"
23
 
#include "client.h"
24
 
#include "../bson/util/atomic_int.h"
25
 
#include "../util/concurrency/spin_lock.h"
26
 
#include "../util/time_support.h"
27
 
#include "../util/net/hostandport.h"
28
 
#include "../util/progress_meter.h"
 
22
#include <vector>
 
23
 
 
24
#include "mongo/bson/util/atomic_int.h"
 
25
#include "mongo/db/client.h"
 
26
#include "mongo/db/namespace-inl.h"
 
27
#include "mongo/util/concurrency/spin_lock.h"
 
28
#include "mongo/util/net/hostandport.h"
 
29
#include "mongo/util/progress_meter.h"
 
30
#include "mongo/util/time_support.h"
29
31
 
30
32
namespace mongo {
31
33
 
37
39
        OpDebug() : ns(""){ reset(); }
38
40
 
39
41
        void reset();
40
 
        
 
42
 
 
43
        void recordStats();
 
44
 
41
45
        string report( const CurOp& curop ) const;
42
 
        void append( const CurOp& curop, BSONObjBuilder& b ) const;
 
46
 
 
47
        /**
 
48
         * Appends stored data and information from curop to the builder.
 
49
         *
 
50
         * @param curop information about the current operation which will be
 
51
         *     use to append data to the builder.
 
52
         * @param builder the BSON builder to use for appending data. Data can
 
53
         *     still be appended even if this method returns false.
 
54
         * @param maxSize the maximum allowed combined size for the query object
 
55
         *     and update object
 
56
         *
 
57
         * @return false if the sum of the sizes for the query object and update
 
58
         *     object exceeded maxSize
 
59
         */
 
60
        bool append(const CurOp& curop, BSONObjBuilder& builder, size_t maxSize) const;
43
61
 
44
62
        // -------------------
45
63
        
64
82
        bool scanAndOrder;   // scanandorder query plan aspect was used
65
83
        long long  nupdated; // number of records updated
66
84
        long long  nmoved;   // updates resulted in a move (moves are expensive)
 
85
        long long  ninserted;
 
86
        long long  ndeleted;
67
87
        bool fastmod;
68
88
        bool fastmodinsert;  // upsert of an $operation. builds a default object
69
89
        bool upsert;         // true if the update actually did an insert
152
172
        ~CurOp();
153
173
 
154
174
        bool haveQuery() const { return _query.have(); }
155
 
        BSONObj query() { return _query.get();  }
 
175
        BSONObj query() const { return _query.get();  }
156
176
        void appendQuery( BSONObjBuilder& b , const StringData& name ) const { _query.append( b , name ); }
157
177
        
158
178
        void ensureStarted();
201
221
        void setQuery(const BSONObj& query) { _query.set( query ); }
202
222
        Client * getClient() const { return _client; }
203
223
        BSONObj info();
204
 
        BSONObj infoNoauth();
205
224
        string getRemoteString( bool includePort = true ) { return _remote.toString(includePort); }
206
 
        ProgressMeter& setMessage( const char * msg , unsigned long long progressMeterTotal = 0 , int secondsBetween = 3 );
 
225
        ProgressMeter& setMessage(const char * msg,
 
226
                                  std::string name = "Progress",
 
227
                                  unsigned long long progressMeterTotal = 0,
 
228
                                  int secondsBetween = 3);
207
229
        string getMessage() const { return _message.toString(); }
208
230
        ProgressMeter& getProgressMeter() { return _progressMeter; }
209
231
        CurOp *parent() const { return _wrapped; }
210
 
        void kill() { _killed = true; }
211
 
        bool killed() const { return _killed; }
 
232
        void kill(bool* pNotifyFlag = NULL); 
 
233
        bool killPendingStrict() const { return _killPending.load(); }
 
234
        bool killPending() const { return _killPending.loadRelaxed(); }
212
235
        void yielded() { _numYields++; }
213
236
        int numYields() const { return _numYields; }
214
237
        void suppressFromCurop() { _suppressFromCurop = true; }
220
243
        
221
244
        const LockStat& lockStat() const { return _lockStat; }
222
245
        LockStat& lockStat() { return _lockStat; }
 
246
 
 
247
        void setKillWaiterFlags();
223
248
    private:
224
249
        friend class Client;
225
250
        void _reset();
241
266
        OpDebug _debug;
242
267
        ThreadSafeString _message;
243
268
        ProgressMeter _progressMeter;
244
 
        volatile bool _killed;
 
269
        AtomicInt32 _killPending;
245
270
        int _numYields;
246
271
        LockStat _lockStat;
 
272
        // _notifyList is protected by the global killCurrentOp's mtx.
 
273
        std::vector<bool*> _notifyList;
247
274
        
248
275
        // this is how much "extra" time a query might take
249
276
        // a writebacklisten for example will block for 30s 
250
277
        // so this should be 30000 in that case
251
278
        long long _expectedLatencyMs; 
252
 
                                     
253
 
 
254
279
    };
255
 
 
256
 
    /* _globalKill: we are shutting down
257
 
       otherwise kill attribute set on specified CurOp
258
 
       this class does not handle races between interruptJs and the checkForInterrupt functions - those must be
259
 
       handled by the client of this class
260
 
    */
261
 
    extern class KillCurrentOp {
262
 
    public:
263
 
        void killAll();
264
 
        void kill(AtomicUInt i);
265
 
 
266
 
        /** @return true if global interrupt and should terminate the operation */
267
 
        bool globalInterruptCheck() const { return _globalKill; }
268
 
 
269
 
        /**
270
 
         * @param heedMutex if true and have a write lock, won't kill op since it might be unsafe
271
 
         */
272
 
        void checkForInterrupt( bool heedMutex = true );
273
 
 
274
 
        /** @return "" if not interrupted.  otherwise, you should stop. */
275
 
        const char *checkForInterruptNoAssert();
276
 
 
277
 
    private:
278
 
        void interruptJs( AtomicUInt *op );
279
 
        volatile bool _globalKill;
280
 
    } killCurrentOp;
281
 
 
282
280
}