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

« back to all changes in this revision

Viewing changes to src/mongo/db/dur_commitjob.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:
31
31
#endif
32
32
 
33
33
    namespace dur {
34
 
       void ThreadLocalIntents::push(const WriteIntent& x) { 
 
34
 
 
35
        ThreadLocalIntents::~ThreadLocalIntents() {
 
36
            fassert( 16731, intents.size() == 0 );
 
37
        }
 
38
 
 
39
        void ThreadLocalIntents::push(const WriteIntent& x) {
35
40
            if( !commitJob._hasWritten )
36
41
                commitJob._hasWritten = true;
37
 
            if( n == 21 )
38
 
                unspool();
39
 
            i[n++] = x;
 
42
 
 
43
            if( intents.size() == N ) {
 
44
                if ( !condense() ) {
 
45
                    unspool();
 
46
                }
 
47
            }
 
48
 
 
49
            intents.push_back( x );
40
50
#if( CHECK_SPOOLING )
41
51
            nSpooled++;
42
52
#endif
43
53
        }
44
54
        void ThreadLocalIntents::_unspool() {
45
 
            if( n ) { 
46
 
                for( int j = 0; j < n; j++ )
47
 
                    commitJob.note(i[j].start(), i[j].length());
48
 
#if( CHECK_SPOOLING )
49
 
                nSpooled.signedAdd(-n);
50
 
#endif
51
 
                n = 0;
52
 
                dassert( cmdLine.dur );
53
 
            }
54
 
        }
 
55
            if ( intents.size() == 0 )
 
56
                return;
 
57
 
 
58
            for( unsigned j = 0; j < intents.size(); j++ ) {
 
59
                commitJob.note(intents[j].start(), intents[j].length());
 
60
            }
 
61
 
 
62
#if( CHECK_SPOOLING )
 
63
            nSpooled.signedAdd( -1 * static_cast<int>(intents.size()) );
 
64
#endif
 
65
 
 
66
            intents.clear();
 
67
        }
 
68
 
 
69
        bool ThreadLocalIntents::condense() {
 
70
            std::sort( intents.begin(), intents.end() );
 
71
 
 
72
            bool didAnything = false;
 
73
 
 
74
            for ( unsigned x = 0; x < intents.size() - 1 ; x++ ) {
 
75
                if ( intents[x].overlaps( intents[x+1] ) ) {
 
76
                    intents[x].absorb( intents[x+1] );
 
77
                    intents.erase( intents.begin() + x + 1 );
 
78
                    x--;
 
79
                    didAnything = true;
 
80
#if( CHECK_SPOOLING )
 
81
                    nSpooled.signedAdd(-1);
 
82
#endif
 
83
                }
 
84
            }
 
85
 
 
86
            return didAnything;
 
87
        }
 
88
 
55
89
        void ThreadLocalIntents::unspool() {
56
 
            if( n ) { 
 
90
            if ( intents.size() ) {
57
91
                SimpleMutex::scoped_lock lk(commitJob.groupCommitMutex);
58
92
                _unspool();
59
93
            }