Compare commits

...

39 Commits
v4.7 ... r1.2.2

Author SHA1 Message Date
Eliot Horowitz
8a4fb8b1c7 BUMP 1.2.2 2010-01-26 12:56:05 -05:00
Eliot Horowitz
a6d37a6d3e fix: m/r emit error gets spidermonkey into bad state SERVER-570 2010-01-26 10:43:30 -05:00
Eliot Horowitz
41232b6557 better debugging for invalid objects
Conflicts:

	db/jsobj.h
	dbtests/jsobjtests.cpp
2010-01-26 10:06:33 -05:00
dwight
a4f9e4bc12 don't assert in rawout 2010-01-25 16:14:10 -05:00
Eliot Horowitz
6a324b4a98 $set doesn't convert from int to other types SERVER-555 2010-01-20 09:53:48 -05:00
Dwight
04aabf6194 elim warning on windows
(cherry picked from commit 95ba1b843e)
2010-01-19 22:06:41 -05:00
Mathias Stearn
5a2da6b86f Better VirtualMemorySize on windows
(cherry picked from commit 42ec730af2)
2010-01-19 22:04:25 -05:00
Mathias Stearn
c461be6e17 fix uninitialized length for MemoryMapFile on windows.
(cherry picked from commit 32acd37d75)
2010-01-19 22:04:17 -05:00
Eliot Horowitz
7907050da3 don't display client shutdown on --upgrade or repair SERVER-554 2010-01-19 16:43:37 -05:00
Eliot Horowitz
2ce38e3376 use boost sleep on sunos SERVER-548 2010-01-15 09:31:05 -05:00
Eliot Horowitz
5b36ef5cfa use nanosleep on *nix rather than boost, trying to fix os x issue SERVER-539
Conflicts:

	dbtests/basictests.cpp
2010-01-14 16:48:41 -05:00
Eliot Horowitz
56b803b9f2 try to fix win64 memory take 4 SERVER-528 2010-01-11 06:54:39 -05:00
Eliot Horowitz
48c7684617 try to fix win64 memory take 3 SERVER-528 2010-01-11 06:44:32 -05:00
Eliot Horowitz
17a2a93bb5 try to fix win64 memory take 2 SERVER-528 2010-01-11 06:39:01 -05:00
Eliot Horowitz
2b59b7f0c5 try to fix win64 memory SERVER-528 2010-01-11 06:29:40 -05:00
Eliot Horowitz
dc1ebc586e make mem info work on win32 SERVER-528
Conflicts:

	jstests/dbadmin.js
2010-01-11 06:17:06 -05:00
Eliot Horowitz
1c4843d497 don't make running out of threads crash db SERVER-527 2010-01-10 02:21:48 +01:00
Eliot Horowitz
054917e5c4 help people trying to access http on driver port 2010-01-02 21:42:11 -05:00
Eliot Horowitz
209968640d after 1.2.1 2009-12-30 14:44:38 -05:00
Eliot Horowitz
45992de574 BUMP 1.2.1 2009-12-30 13:01:40 -05:00
Mathias Stearn
961d3ab8b2 Backport fix to 1.2 branch. SERVER-410. 2009-12-29 17:13:03 -05:00
Eliot Horowitz
f8f12e8d13 beter error handling in m/r 2009-12-29 14:26:12 -05:00
Eliot Horowitz
720eecdc01 fix compile 2009-12-22 12:58:41 -05:00
Eliot Horowitz
5dc18ddb3b better repl debugging 2009-12-22 11:07:36 -05:00
Eliot Horowitz
9280f63a83 fix compile on gcc 4.4.2 2009-12-20 07:17:54 -05:00
Eliot Horowitz
007da4fdc7 make --quiet not print out connection accepted SERVER-498 2009-12-20 07:17:37 -05:00
Eliot Horowitz
a0d90a4478 make --repair for a full repair 2009-12-15 20:54:02 -05:00
Eliot Horowitz
697c07f8c9 1.2.1- 2009-12-10 21:31:15 -05:00
Eliot Horowitz
2add01f37d BUMP 1.2.0 2009-12-10 10:27:04 -05:00
Aaron
0775d99ea1 SERVER-469 don't crash when authenticate called before getnonce 2009-12-10 10:16:25 -05:00
Eliot Horowitz
d6d9ce8ffe slaves can clone system.js SERVER-466 2009-12-09 10:19:11 -05:00
Eliot Horowitz
306c8c6b98 fix names 2009-12-08 12:19:09 -05:00
Eliot Horowitz
87f324edf8 prefix/postfix 2009-12-06 19:49:54 -05:00
Eliot Horowitz
89b0957a41 versions for build bot finding 2009-12-06 19:18:30 -05:00
Eliot Horowitz
05c32be539 post vs. 1.1.4 2009-12-05 11:54:52 -05:00
Eliot Horowitz
c0b78e37b5 if non master, use branch name in file 2009-12-05 11:54:36 -05:00
Eliot Horowitz
cb39613c0f better tests 2009-12-03 17:25:39 -05:00
Eliot Horowitz
ad7fc89083 BUMP 1.1.4 2009-12-03 15:03:20 -05:00
Eliot Horowitz
3c6a8cf7b7 initial stab at rpm files SERVER-396 2009-12-03 14:21:22 -05:00
33 changed files with 601 additions and 42 deletions

View File

@@ -483,7 +483,7 @@ elif "win32" == os.sys.platform:
env.Append( CPPFLAGS=" /EHsc /W3 " )
env.Append( CPPFLAGS=" /wd4355 /wd4800 " ) #some warnings we don't like
env.Append( CPPDEFINES=["WIN32","_CONSOLE","_CRT_SECURE_NO_WARNINGS","HAVE_CONFIG_H","PCRE_STATIC","_UNICODE","UNICODE","SUPPORT_UCP","SUPPORT_UTF8" ] )
env.Append( CPPDEFINES=["WIN32","_CONSOLE","_CRT_SECURE_NO_WARNINGS","HAVE_CONFIG_H","PCRE_STATIC","_UNICODE","UNICODE","SUPPORT_UCP","SUPPORT_UTF8,PSAPI_VERSION=1" ] )
#env.Append( CPPFLAGS=' /Yu"stdafx.h" ' ) # this would be for pre-compiled headers, could play with it later
@@ -524,12 +524,14 @@ elif "win32" == os.sys.platform:
commonFiles += pcreFiles
allClientFiles += pcreFiles
winLibString = "ws2_32.lib kernel32.lib advapi32.lib"
winLibString = "ws2_32.lib kernel32.lib advapi32.lib Psapi.lib"
if force64:
winLibString += " LIBCMT LIBCPMT "
else:
winLibString += " user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib "
winLibString += " odbc32.lib odbccp32.lib uuid.lib "
env.Append( LIBS=Split(winLibString) )
if force64:
@@ -604,6 +606,29 @@ except OSError:
# --- check system ---
def getGitBranch():
if not os.path.exists( ".git" ):
return None
version = open( ".git/HEAD" ,'r' ).read().strip()
if not version.startswith( "ref: " ):
return version
version = version.split( "/" )
version = version[len(version)-1]
return version
def getGitBranchString( prefix="" , postfix="" ):
t = re.compile( '[/\\\]' ).split( os.getcwd() )
if len(t) > 2 and t[len(t)-1] == "mongo":
t = re.compile( ".*_([vV]\d+\.\d+)$" ).match( t[len(t)-2] )
if t is not None:
return prefix + t.group(1).lower() + postfix
b = getGitBranch()
if b == None or b == "master":
return ""
return prefix + b + postfix
def getGitVersion():
if not os.path.exists( ".git" ):
return "nogitversion"
@@ -1240,7 +1265,9 @@ def getDistName( sofar ):
distName = version
return version
return today.strftime( "%Y-%m-%d" )
return getGitBranchString( "" , "-" ) + today.strftime( "%Y-%m-%d" )
if distBuild:
from datetime import date
@@ -1361,7 +1388,7 @@ def s3push( localName , remoteName=None , remotePrefix=None , fixName=True , pla
if remotePrefix is None:
if distName is None:
remotePrefix = "-latest"
remotePrefix = getGitBranchString( "-" ) + "-latest"
else:
remotePrefix = "-" + distName

View File

@@ -16,6 +16,7 @@
*/
#include "../stdafx.h"
#include "../db/cmdline.h"
namespace mongo {
@@ -23,6 +24,8 @@ namespace mongo {
bool quiet = false;
CmdLine cmdLine;
// Database* database = 0;
bool dbexitCalled = false;

View File

@@ -103,7 +103,7 @@ namespace mongo {
/* must call when a btree bucket going away.
note this is potentially slow
*/
inline void ClientCursor::informAboutToDeleteBucket(const DiskLoc& b) {
void ClientCursor::informAboutToDeleteBucket(const DiskLoc& b) {
recursive_boostlock lock(ccmutex);
RARELY if ( byLoc.size() > 70 ) {
log() << "perf warning: byLoc.size=" << byLoc.size() << " in aboutToDeleteBucket\n";

View File

@@ -216,7 +216,7 @@ namespace mongo {
if( strstr(from_name, ".system.") ) {
/* system.users is cloned -- but nothing else from system. */
if( strstr(from_name, ".system.users") == 0 ){
if( legalClientSystemNS( from_name , true ) == 0 ){
log(2) << "\t\t not cloning because system collection" << endl;
continue;
}

View File

@@ -113,9 +113,16 @@ namespace mongo {
virtual void accepted(MessagingPort *mp) {
assert( grab == 0 );
grab = mp;
boost::thread thr(connThread);
while ( grab )
sleepmillis(1);
try {
boost::thread thr(connThread);
while ( grab )
sleepmillis(1);
}
catch ( boost::thread_resource_error& e ){
log() << "can't create new thread, closing connection" << endl;
mp->shutdown();
grab = 0;
}
}
};
@@ -283,7 +290,7 @@ namespace mongo {
bool doDBUpgrade( const string& dbName , string errmsg , MDFHeader * h ){
static DBDirectClient db;
if ( h->version == 4 && h->versionMinor == 4 ){
if ( forceRepair == false && h->version == 4 && h->versionMinor == 4 ){
assert( VERSION == 4 );
assert( VERSION_MINOR == 5 );
@@ -347,6 +354,7 @@ namespace mongo {
if ( shouldRepairDatabases ){
log() << "finished checking dbs" << endl;
cc().shutdown();
dbexit( EXIT_CLEAN );
}
}

View File

@@ -308,18 +308,24 @@ namespace mongo {
}
{
BSONObjBuilder t( result.subobjStart( "mem" ) );
ProcessInfo p;
if ( p.supported() ){
BSONObjBuilder t;
t.append( "resident" , p.getResidentSize() );
t.append( "virtual" , p.getVirtualMemorySize() );
t.append( "mapped" , MemoryMappedFile::totalMappedLength() / ( 1024 * 1024 ) );
result.append( "mem" , t.obj() );
t.appendBool( "supported" , true );
}
else {
result.append( "mem" , "not support on this platform" );
result.append( "note" , "not all mem info support on this platform" );
t.appendBool( "supported" , false );
}
t.append( "mapped" , MemoryMappedFile::totalMappedLength() / ( 1024 * 1024 ) );
t.done();
}
return true;

View File

@@ -714,8 +714,15 @@ namespace mongo {
_holder.reset( new Holder( data ) );
_objdata = data;
if ( ! isValid() ){
log() << "invalid object size: " << objsize() << endl;
massert( "Invalid BSONObj spec size" , 0 );
stringstream ss;
ss << "Invalid BSONObj spec size: " << objsize();
try {
BSONElement e = firstElement();
ss << " first element:" << e.toString() << " ";
}
catch ( ... ){}
string s = ss.str();
massert( s , 0 );
}
}
#pragma pack(1)

View File

@@ -205,7 +205,13 @@ namespace mongo {
scope->localConnect( setup.dbname.c_str() );
map = scope->createFunction( setup.mapCode.c_str() );
if ( ! map )
throw UserException( (string)"map compile failed: " + scope->getError() );
reduce = scope->createFunction( setup.reduceCode.c_str() );
if ( ! reduce )
throw UserException( (string)"reduce compile failed: " + scope->getError() );
if ( setup.finalizeCode.size() )
finalize = scope->createFunction( setup.finalizeCode.c_str() );
else

View File

@@ -860,7 +860,7 @@ namespace mongo {
if ( replAllDead ) {
// hmmm why is this check here and not at top of this function? does it get set between top and here?
log() << "replAllDead, throwing SyncException\n";
log() << "replAllDead, throwing SyncException: " << replAllDead << endl;
throw SyncException();
}

View File

@@ -97,11 +97,17 @@ namespace mongo {
stringstream digestBuilder;
{
bool reject = false;
nonce *ln = lastNonce.release();
digestBuilder << hex << *ln;
if( ln == 0 || digestBuilder.str() != received_nonce ) {
log() << "auth: bad nonce received. could be a driver bug or a security attack. db:" << cc().database()->name << '\n';
if ( ln == 0 ) {
reject = true;
} else {
digestBuilder << hex << *ln;
reject = digestBuilder.str() != received_nonce;
}
if ( reject ) {
log() << "auth: bad nonce received or getnonce not called. could be a driver bug or a security attack. db:" << cc().database()->name << '\n';
errmsg = "auth fails";
sleepmillis(30);
return false;

View File

@@ -248,6 +248,8 @@ namespace mongo {
if ( !( e.isNumber() && m.elt.isNumber() ) &&
m.elt.valuesize() != e.valuesize() )
inPlacePossible = false;
if ( e.type() != m.elt.type() )
inPlacePossible = false;
break;
case Mod::PUSH:
case Mod::PUSH_ALL:

View File

@@ -110,6 +110,27 @@ namespace BasicTests {
roundTrip( y , 40 );
}
};
class sleeptest {
public:
void run(){
Timer t;
sleepsecs( 1 );
ASSERT_EQUALS( 1 , t.seconds() );
t.reset();
sleepmicros( 1527123 );
ASSERT( t.micros() > 1000000 );
ASSERT( t.micros() < 2000000 );
t.reset();
sleepmillis( 1727 );
ASSERT( t.millis() >= 1000 );
ASSERT( t.millis() <= 2000 );
}
};
class All : public Suite {
public:
@@ -119,6 +140,8 @@ namespace BasicTests {
void setupTests(){
add< Rarely >();
add< Base64Tests >();
add< sleeptest >();
}
} myall;

View File

@@ -1185,6 +1185,40 @@ namespace JsobjTests {
}
};
class InvalidIDFind {
public:
void run(){
BSONObj x = BSON( "_id" << 5 << "t" << 2 );
{
char * crap = (char*)malloc( x.objsize() );
memcpy( crap , x.objdata() , x.objsize() );
BSONObj y( crap , false );
ASSERT_EQUALS( x , y );
free( crap );
}
{
char * crap = (char*)malloc( x.objsize() );
memcpy( crap , x.objdata() , x.objsize() );
int * foo = (int*)crap;
foo[0] = 123123123;
int state = 0;
try {
BSONObj y( crap , false );
state = 1;
}
catch ( std::exception& e ){
state = 2;
ASSERT( strstr( e.what() , "_id: 5" ) > 0 );
}
free( crap );
ASSERT_EQUALS( 2 , state );
}
}
};
class All : public Suite {
public:
All() : Suite( "jsobj" ){
@@ -1269,6 +1303,7 @@ namespace JsobjTests {
add< BSONArrayBuilderTest >();
add< ArrayMacroTest >();
add< NumberParsing >();
add< InvalidIDFind >();
}
} myall;

2
debian/changelog vendored
View File

@@ -1,4 +1,4 @@
mongodb (1.1.3) unstable; urgency=low
mongodb (1.2.2) stable; urgency=low
* Initial release

View File

@@ -3,7 +3,7 @@
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = MongoDB
PROJECT_NUMBER = 1.1.3
PROJECT_NUMBER = 1.2.2
OUTPUT_DIRECTORY = docs
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English

11
jstests/auth2.js Normal file
View File

@@ -0,0 +1,11 @@
db2 = new Mongo( db.getMongo().host ).getDB( db.getName() );
users = db2.getCollection( "system.users" );
users.remove( {} );
pass = "a" + Math.random();
//print( "password [" + pass + "]" );
db2.addUser( "eliot" , pass );
assert.commandFailed( db2.runCommand( { authenticate: 1, user: "eliot", nonce: "foo", key: "bar" } ) );

View File

@@ -134,7 +134,7 @@ if ( true ){
print( "t1: " + Date.timeFunc(
function(){
var out = db.runCommand( { mapreduce : "mr1" , map : m , reduce : r } );
if ( ks == "_id" ) assert( out.ok , "XXX" );
if ( ks == "_id" ) assert( out.ok , "XXX : " + tojson( out ) );
db[out.result].drop();
} , 10 ) + " (~500 on 2.8ghz) - itcount: " + Date.timeFunc( function(){ db.mr1.find().itcount(); } , 10 ) );

View File

@@ -0,0 +1,47 @@
t = db.mr_errorhandling;
t.drop();
t.save( { a : [ 1 , 2 , 3 ] } )
t.save( { a : [ 2 , 3 , 4 ] } )
m_good = function(){
for ( var i=0; i<this.a.length; i++ ){
emit( this.a[i] , 1 );
}
}
m_bad = function(){
for ( var i=0; i<this.a.length; i++ ){
emit( this.a[i] );
}
}
r = function( k , v ){
var total = 0;
for ( var i=0; i<v.length; i++ )
total += v[i];
return total;
}
res = t.mapReduce( m_good , r );
assert.eq( { 1 : 1 , 2 : 2 , 3 : 2 , 4 : 1 } , res.convertToSingleObject() , "A" );
res.drop()
res = null;
theerror = null;
try {
res = t.mapReduce( m_bad , r );
}
catch ( e ){
theerror = e.toString();
}
assert.isnull( res , "B1" );
assert( theerror , "B2" );
assert( theerror.indexOf( "emit" ) >= 0 , "B3" );
// test things are still in an ok state
res = t.mapReduce( m_good , r );
assert.eq( { 1 : 1 , 2 : 2 , 3 : 2 , 4 : 1 } , res.convertToSingleObject() , "A" );
res.drop()

View File

@@ -208,6 +208,7 @@
93A6E10D0F24CFB100DA4EBF /* flushtest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = flushtest.cpp; sourceTree = "<group>"; };
93A6E10E0F24CFD300DA4EBF /* security.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = security.h; sourceTree = "<group>"; };
93A6E10F0F24CFEA00DA4EBF /* security_commands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = security_commands.cpp; sourceTree = "<group>"; };
93A71D2D10D04D15003C9E90 /* auth2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = auth2.js; sourceTree = "<group>"; };
93A8CD170F33B78D00C92B85 /* mmap_mm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mmap_mm.cpp; path = util/mmap_mm.cpp; sourceTree = SOURCE_ROOT; };
93A8CD180F33B7A000C92B85 /* mmap_posix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mmap_posix.cpp; path = util/mmap_posix.cpp; sourceTree = SOURCE_ROOT; };
93A8CD190F33B7AF00C92B85 /* mmap_win.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mmap_win.cpp; path = util/mmap_win.cpp; sourceTree = SOURCE_ROOT; };
@@ -641,6 +642,7 @@
93A8D1D10F37544800C92B85 /* jstests */ = {
isa = PBXGroup;
children = (
93A71D2D10D04D15003C9E90 /* auth2.js */,
935E7B8A0FCF37D40024B2E5 /* sharding */,
936D937F0FCC67C700004410 /* index9.js */,
936D931B0FCC58C900004410 /* regex.js */,

63
rpm/init.d-mongod Normal file
View File

@@ -0,0 +1,63 @@
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 85 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
# config: /etc/mongod.conf
# pidfile: /var/run/mongo/mongo.pid
. /etc/rc.d/init.d/functions
# things from mongod.conf get there by mongod reading it
OPTIONS=" -f /etc/mongod.conf"
mongod=${MONGOD-/usr/bin/mongod}
pidfile=${PIDFILE-/var/run/mongod.pid}
lockfile=${LOCKFILE-/var/lock/subsys/mongod}
start()
{
echo -n $"Starting mongod: "
#daemon --pidfile=${pidfile} $mongod $OPTIONS > /var/log/mongod
$mongod $OPTIONS > /var/log/mongod 2>&1 &
RETVAL=$?
[ $RETVAL = 0 ] && touch ${lockfile}
echo OK
}
stop()
{
echo -n $"Stopping mongod: "
#killproc -p ${pidfile} -d 10 $mongod
#RETVAL=$?
killall mongod > /dev/null 2>&1
#[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
echo OK
}
ulimit -n 12000
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
# status)
# status -p ${pidfile} $mongod
# ;;
*)
echo $"Usage: $0 {start|stop|restart}"
RETVAL=1
esac
exit $RETVAL

128
rpm/mongo.spec Normal file
View File

@@ -0,0 +1,128 @@
Name: mongo
Version: 1.2.2
Release: mongodb_1%{?dist}
Summary: mongo client shell and tools
License: AGPL 3.0
URL: http://www.mongodb.org
Group: Applications/Databases
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: js-devel, readline-devel, boost-devel, pcre-devel
BuildRequires: gcc-c++, scons
%description
Mongo (from "huMONGOus") is a schema-free document-oriented database.
It features dynamic profileable queries, full indexing, replication
and fail-over support, efficient storage of large binary data objects,
and auto-sharding.
This package provides the mongo shell, import/export tools, and other
client utilities.
%package server
Summary: mongo server, sharding server, and support scripts
Group: Applications/Databases
%description server
Mongo (from "huMONGOus") is a schema-free document-oriented database.
This package provides the mongo server software, mongo sharding server
softwware, default configuration files, and init.d scripts.
%package devel
Summary: Headers and libraries for mongo development.
Group: Applications/Databases
%description devel
Mongo (from "huMONGOus") is a schema-free document-oriented database.
This package provides the mongo static library and header files needed
to develop mongo client software.
%prep
%setup
%build
scons --prefix=$RPM_BUILD_ROOT/usr all
# XXX really should have shared library here
%install
scons --prefix=$RPM_BUILD_ROOT/usr install
mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1
cp debian/*.1 $RPM_BUILD_ROOT/usr/share/man/man1/
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
cp rpm/init.d-mongod $RPM_BUILD_ROOT/etc/rc.d/init.d/mongod
chmod a+x $RPM_BUILD_ROOT/etc/rc.d/init.d/mongod
mkdir -p $RPM_BUILD_ROOT/etc
cp rpm/mongod.conf $RPM_BUILD_ROOT/etc/mongod.conf
mkdir -p $RPM_BUILD_ROOT/var/lib/mongo
mkdir -p $RPM_BUILD_ROOT/var/log
touch $RPM_BUILD_ROOT/var/log/mongo
%clean
scons -c
rm -rf $RPM_BUILD_ROOT
%pre server
#/usr/sbin/useradd -M -o -r -d /var/mongo -s /bin/bash \
# -c "mongod" mongod > /dev/null 2>&1 || :
%post server
if test $1 = 1
then
/sbin/chkconfig --add mongod
fi
%preun server
if test $1 = 0
then
/sbin/chkconfig --del mongod
fi
%postun server
if test $1 -ge 1
then
/sbin/service mongod stop >/dev/null 2>&1 || :
fi
%files
%defattr(-,root,root,-)
%doc README GNU-AGPL-3.0.txt
%{_bindir}/mongo
%{_bindir}/mongodump
%{_bindir}/mongoexport
%{_bindir}/mongofiles
%{_bindir}/mongoimport
%{_bindir}/mongorestore
%{_mandir}/man1/mongo.1*
%{_mandir}/man1/mongodump.1*
%{_mandir}/man1/mongoexport.1*
%{_mandir}/man1/mongofiles.1*
%{_mandir}/man1/mongoimport.1*
%{_mandir}/man1/mongorestore.1*
%files server
%defattr(-,root,root,-)
%config(noreplace) /etc/mongod.conf
%{_bindir}/mongod
%{_bindir}/mongos
#%{_mandir}/man1/mongod.1*
%{_mandir}/man1/mongos.1*
/etc/rc.d/init.d/mongod
/etc/sysconfig/mongod
#/etc/rc.d/init.d/mongos
%attr(0755,root,root) %dir /var/mongo
%attr(0640,root,root) %config(noreplace) %verify(not md5 size mtime) /var/log/mongo
%files devel
/usr/include/mongo
%{_libdir}/libmongoclient.a
#%{_libdir}/libmongotestfiles.a
%changelog
* Sat Oct 24 2009 Joe Miklojcik <jmiklojcik@shopwiki.com> -
- Wrote mongo.spec.

86
rpm/mongod.conf Normal file
View File

@@ -0,0 +1,86 @@
# mongo.conf
#where to log
logpath=/var/log/mongod
#port = 27017
dbpath=/var/lib/mongo
# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
# Turn on/off security. Off is currently the default
#noauth = true
#auth = true
# Verbose logging output.
#verbose = true
# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true
# Enable db quota management
#quota = true
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#oplog = 0
# Diagnostic/debugging option
#nocursors = true
# Ignore query hints
#nohints = true
# Disable the HTTP interface (Defaults to localhost:27018).
#nohttpinterface = true
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true
# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
# Disable data file preallocation.
#noprealloc = true
# Specify .ns file size for new databases.
# nssize = <size>
# Accout token for Mongo monitoring server.
#mms-token = <token>
# Server name for Mongo monitoring server.
#mms-name = <server-name>
# Ping interval for Mongo monitoring server.
#mms-interval = <seconds>
# Replication Options
# in replicated mongo databases, specify here whether this is a slave or master
#slave = true
#source = master.example.com
# Slave only: specify a single database to replicate
#only = master.example.com
# or
#master = true
#source = slave.example.com
# Address of a server to pair with.
#pairwith = <server:port>
# Address of arbiter server.
#arbiter = <server:port>
# Automatically resync if slave data is stale
#autoresync
# Custom size for replication operation log.
#oplogSize = <MB>
# Size limit for in-memory storage of op ids.
#opIdMem = <bytes>

View File

@@ -171,7 +171,7 @@ int main(int argc, char* argv[], char *envp[] ) {
return 1;
}
log() << argv[0] << " v0.3- (alpha 3r) starting (--help for usage)" << endl;
log() << argv[0] << " v0.2.6 (alpha 2f) starting (--help for usage)" << endl;
printGitVersion();
printSysInfo();

View File

@@ -818,7 +818,15 @@ namespace mongo {
a = args.obj();
}
BSONObj out = func( a );
BSONObj out;
try {
out = func( a );
}
catch ( std::exception& e ){
JS_ReportError( cx , e.what() );
return JS_FALSE;
}
if ( out.isEmpty() ){
*rval = JSVAL_VOID;

View File

@@ -32,6 +32,6 @@
namespace mongo {
const char versionString[] = "1.1.4-";
const char versionString[] = "1.2.2";
} // namespace mongo

View File

@@ -198,13 +198,14 @@ public:
log(1) << "filesize: " << fileSize << endl;
ProgressMeter pm( fileSize );
const int BUF_SIZE = 1024 * 1024 * 4;
char line[ (1024 * 1024 * 4) + 128];
boost::scoped_array<char> line (new char[BUF_SIZE]);
while ( *in ){
in->getline( line , BUF_SIZE );
uassert( "unknown error reading file" , ( in->rdstate() & ios_base::badbit ) == 0 );
log(1) << "got line:" << line << endl;
char * buf = line.get();
in->getline( buf , BUF_SIZE );
uassert( "unknown error reading file" , ( in->rdstate() & ios_base::badbit ) == 0 );
log(1) << "got line:" << buf << endl;
char * buf = line;
while( isspace( buf[0] ) ) buf++;
int len = strlen( buf );

View File

@@ -180,6 +180,7 @@ namespace mongo {
#define localtime _localtime_not_threadsafe_
#define ctime _ctime_is_not_threadsafe_
#if defined(_WIN32) || defined(__sunos__)
inline void sleepsecs(int s) {
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
@@ -208,6 +209,28 @@ namespace mongo {
}
boost::thread::sleep(xt);
}
#else
inline void sleepsecs(int s) {
struct timespec t;
t.tv_sec = s;
t.tv_nsec = 0;
if ( nanosleep( &t , 0 ) ){
cout << "nanosleep failed" << endl;
}
}
inline void sleepmicros(int s) {
struct timespec t;
t.tv_sec = (int)(s / 1000000);
t.tv_nsec = s % 1000000;
if ( nanosleep( &t , 0 ) ){
cout << "nanosleep failed" << endl;
}
}
inline void sleepmillis(int s) {
sleepmicros( s * 1000 );
}
#endif
// note this wraps
inline int tdiff(unsigned told, unsigned tnew) {
return WrappingInt::diff(tnew, told);

View File

@@ -25,6 +25,7 @@
#include "../util/background.h"
#include <fcntl.h>
#include <errno.h>
#include "../db/cmdline.h"
namespace mongo {
@@ -84,7 +85,7 @@ namespace mongo {
continue;
}
disableNagle(s);
log() << "connection accepted from " << from.toString() << " #" << ++connNumber << endl;
if ( ! cmdLine.quiet ) log() << "connection accepted from " << from.toString() << " #" << ++connNumber << endl;
accepted( new MessagingPort(s, from) );
}
}
@@ -295,6 +296,14 @@ again:
}
goto again;
}
if ( len == 542393671 ){
// an http GET
log() << "looks like you're trying to access db over http on native driver port. please add 1000 for webserver" << endl;
static const char * wrongPort = "HTTP 1.0 404 Not Found\nConnection: Close\n\nYou are trying to access MongoDB on the native driver port. For http access, add 1000 to the port\n\n";
::send( sock , wrongPort , strlen( wrongPort ) , 0 );
return false;
}
log() << "bad recv() len: " << len << '\n';
return false;
}

View File

@@ -25,6 +25,7 @@ namespace mongo {
fd = 0;
maphandle = 0;
view = 0;
len = 0;
created();
}

View File

@@ -21,12 +21,6 @@
#include <iostream>
using namespace std;
#ifdef _WIN32
int getpid(){
return 0;
}
#endif
namespace mongo {
ProcessInfo::ProcessInfo( pid_t pid ){

View File

@@ -0,0 +1,63 @@
// processinfo_win32.cpp
/* Copyright 2009 10gen Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "stdafx.h"
#include "processinfo.h"
#include <iostream>
#include <windows.h>
#include <psapi.h>
using namespace std;
int getpid(){
return GetCurrentProcessId();
}
namespace mongo {
int _wconvertmtos( SIZE_T s ){
return (int)( s / ( 1024 * 1024 ) );
}
ProcessInfo::ProcessInfo( pid_t pid ){
}
ProcessInfo::~ProcessInfo(){
}
bool ProcessInfo::supported(){
return true;
}
int ProcessInfo::getVirtualMemorySize(){
MEMORYSTATUSEX mse;
mse.dwLength = sizeof(mse);
assert( GlobalMemoryStatusEx( &mse ) );
DWORDLONG x = (mse.ullTotalVirtual - mse.ullAvailVirtual) / (1024 * 1024) ;
assert( x <= 0x7fffffff );
return (int) x;
}
int ProcessInfo::getResidentSize(){
PROCESS_MEMORY_COUNTERS pmc;
assert( GetProcessMemoryInfo( GetCurrentProcess() , &pmc, sizeof(pmc) ) );
return _wconvertmtos( pmc.WorkingSetSize );
}
}

View File

@@ -122,9 +122,9 @@ namespace mongo {
#if defined(_WIN32)
(std::cout << now << " " << s).flush();
#else
assert( write( STDOUT_FILENO, now, 20 ) > 0 );
assert( write( STDOUT_FILENO, " ", 1 ) > 0 );
assert( write( STDOUT_FILENO, s.c_str(), s.length() ) > 0 );
write( STDOUT_FILENO, now, 20 );
write( STDOUT_FILENO, " ", 1 );
write( STDOUT_FILENO, s.c_str(), s.length() );
fsync( STDOUT_FILENO );
#endif
}