summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-06-17 16:57:24 -0400
committerDwight <dmerriman@gmail.com>2008-06-17 16:57:24 -0400
commitf5947576e2079076698bfeedc97ef65c581dca26 (patch)
treef72798cfa35d53353e1d9d53ff13d563950941b3
parent652faabd1854bac70edc5b7976065ea0a2af4f22 (diff)
parent683671d4bbd039d88144d01061e9f37a58262cf4 (diff)
downloadmongo-f5947576e2079076698bfeedc97ef65c581dca26.tar.gz
Merge branch 'master' of ssh://git.10gen.com/data/gitroot/p
-rw-r--r--db/db.cpp31
-rw-r--r--db/pdfile.cpp10
-rw-r--r--db/pdfile.h4
-rw-r--r--grid/message.h5
4 files changed, 32 insertions, 18 deletions
diff --git a/db/db.cpp b/db/db.cpp
index 43168d0007f..6530090c4f5 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -345,7 +345,13 @@ void jniCallback(Message& m, Message& out)
bool log = false;
curOp = m.data->operation;
if( m.data->operation == dbQuery ) {
- receivedQuery(jmp, m, ss);
+ // on a query, the Message must have m.freeIt true so that the buffer data can be
+ // retained by cursors. As freeIt is false, we make a copy here.
+ assert( m.data->len > 0 && m.data->len < 32000000 );
+ Message copy(malloc(m.data->len), true);
+ memcpy(copy.data, m.data, m.data->len);
+
+ receivedQuery(jmp, copy, ss);
}
else if( m.data->operation == dbInsert ) {
ss << "insert ";
@@ -455,11 +461,16 @@ void connThread()
resp.setData(opReply, "i am fine");
dbMsgPort.reply(m, resp);
if( end ) {
- cout << curTimeMillis() % 10000 << " end msg" << endl;
- dbMsgPort.shutdown();
- sleepmillis(500);
- problem() << "exiting end msg" << endl;
- exit(EXIT_SUCCESS);
+ cout << curTimeMillis() % 10000 << " end msg " << dbMsgPort.farEnd.toString() << endl;
+ if( dbMsgPort.farEnd.isLocalHost() ) {
+ dbMsgPort.shutdown();
+ sleepmillis(500);
+ problem() << "exiting end msg" << endl;
+ exit(EXIT_SUCCESS);
+ }
+ else {
+ cout << " (not from localhost, ignoring end msg)" << endl;
+ }
}
}
else if( m.data->operation == dbQuery ) {
@@ -558,7 +569,8 @@ void msg(const char *m, const char *address, int port, int extras = 0) {
if( !p.connect(db) )
return;
- for( int q = 0; q < 3; q++ ) {
+ const int Loops = 1;
+ for( int q = 0; q < Loops; q++ ) {
Message send;
Message response;
@@ -573,11 +585,12 @@ void msg(const char *m, const char *address, int port, int extras = 0) {
double tm = t.micros() + 1;
cout << " ****ok. response.data:" << ok << " time:" << tm / 1000.0 << "ms " <<
((double) len) * 8 / 1000000 / (tm/1000000) << "Mbps" << endl;
- if( q+1 < 3 ) {
- cout << "\t\tSLEEP 8 then sending again" << endl;
+ if( q+1 < Loops ) {
+ cout << "\t\tSLEEP 8 then sending again as a test" << endl;
sleepsecs(8);
}
}
+ sleepsecs(1);
p.shutdown();
}
diff --git a/db/pdfile.cpp b/db/pdfile.cpp
index ddf74adf615..017972e72f1 100644
--- a/db/pdfile.cpp
+++ b/db/pdfile.cpp
@@ -404,11 +404,13 @@ Extent* PhysicalDataFile::newExtent(const char *ns, int approxSize, int loops) {
int ExtentSize = approxSize <= header->unusedLength ? approxSize : header->unusedLength;
DiskLoc loc;
if( ExtentSize <= 0 ) {
- if( loops > 8 ) {
- assert(false);
- return 0;
+ /* not there could be a lot of looping here is db just started and
+ no files are open yet. we might want to do something about that. */
+ if( loops > 8 ) {
+ assert( loops < 10000 );
+ cout << "warning: loops=" << loops << " fileno:" << fileNo << ' ' << ns << '\n';
}
- cout << "INFO: newExtent(): file full, adding a new file " << ns << endl;
+ cout << "info: newExtent(): file " << fileNo << " full, adding a new file " << ns << endl;
return client->addAFile()->newExtent(ns, approxSize, loops+1);
}
int offset = header->unused.getOfs();
diff --git a/db/pdfile.h b/db/pdfile.h
index ec8b07074c4..da7efbfc374 100644
--- a/db/pdfile.h
+++ b/db/pdfile.h
@@ -364,9 +364,9 @@ public:
PhysicalDataFile* getFile(int n) {
assert(this);
- if( n < 0 || n >= 10000 ) {
+ if( n < 0 || n >= 8000 ) {
cout << "getFile(): n=" << n << endl;
- assert( n >= 0 && n < 10000 );
+ assert( n >= 0 && n < 8000 );
}
#if defined(_DEBUG)
if( n > 100 )
diff --git a/grid/message.h b/grid/message.h
index 3a26909dec9..1f4df0d83bd 100644
--- a/grid/message.h
+++ b/grid/message.h
@@ -75,7 +75,7 @@ struct MsgData {
int operation;
char _data[4];
- int dataLen();
+ int dataLen(); // len without header
};
const int MsgDataHeaderSize = sizeof(MsgData) - 4;
inline int MsgData::dataLen() { return len - MsgDataHeaderSize; }
@@ -85,7 +85,7 @@ inline int MsgData::dataLen() { return len - MsgDataHeaderSize; }
class Message {
public:
Message() { data = 0; freeIt = false; }
- Message( void * _data , bool _freeIt ){ data = (MsgData*)_data; freeIt = _freeIt; };
+ Message( void * _data , bool _freeIt ){ data = (MsgData*)_data; freeIt = _freeIt; };
~Message() { reset(); }
SockAddr from;
@@ -129,4 +129,3 @@ public:
private:
bool freeIt;
};
-