From 2b989fd9f6b4c94f99a7fd529ba897afa5769097 Mon Sep 17 00:00:00 2001 From: Christian Amor Kvalheim Date: Wed, 4 Jan 2012 16:58:08 +0100 Subject: [PATCH] Fixes for 0.4.X, updated history and package.json --- HISTORY | 4 ++++ external-libs/bson/bson.cc | 12 +++++++++-- lib/mongodb/connection/connection.js | 32 +++++++++++++++++----------- package.json | 2 +- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/HISTORY b/HISTORY index 0c5fc87bf6..19967013c6 100644 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,7 @@ +0.9.7.3-5 2012-01-04 +* Fix for RegExp serialization for 0.4.X where typeof /regexp/ == 'function' vs in 0.6.X typeof /regexp/ == 'object' +* Don't allow keepAlive and setNoDelay for 0.4.X as it throws errors + 0.9.7.3-4 2012-01-04 * Chased down potential memory leak on findAndModify, Issue #467 (node.js removeAllListeners leaves the key in the _events object, node.js bug on eventlistener?, leads to extremely slow memory leak on listener object) * Sanity checks for GridFS performance with benchmark added diff --git a/external-libs/bson/bson.cc b/external-libs/bson/bson.cc index ddc8c05a3a..f7eb87190b 100644 --- a/external-libs/bson/bson.cc +++ b/external-libs/bson/bson.cc @@ -368,7 +368,11 @@ uint32_t BSON::calculate_object_size2(Handle value) { // Current object we are processing Local currentObject = value->ToObject(); // Current list of object keys - Local keys = currentObject->GetOwnPropertyNames(); + #if NODE_MAJOR_VERSION == 0 && NODE_MINOR_VERSION < 6 + Local keys = currentObject->GetPropertyNames(); + #else + Local keys = currentObject->GetOwnPropertyNames(); + #endif // Contains pointer to keysIndex uint32_t keysIndex = 0; uint32_t keysLength = keys->Length(); @@ -380,7 +384,11 @@ uint32_t BSON::calculate_object_size2(Handle value) { // If the index is bigger than the number of keys for the object // we finished up the previous object and are ready for the next one if(keysIndex >= keys->Length()) { - keys = currentObject->GetOwnPropertyNames(); + #if NODE_MAJOR_VERSION == 0 && NODE_MINOR_VERSION < 6 + keys = currentObject->GetPropertyNames(); + #else + keys = currentObject->GetOwnPropertyNames(); + #endif keysLength = keys->Length(); } diff --git a/lib/mongodb/connection/connection.js b/lib/mongodb/connection/connection.js index d3e8084237..14f80593c6 100644 --- a/lib/mongodb/connection/connection.js +++ b/lib/mongodb/connection/connection.js @@ -49,16 +49,19 @@ Connection.prototype.start = function() { // If we have a normal connection if(this.socketOptions.ssl) { // Create a new stream - this.connection = new net.Stream(); + this.connection = new net.Stream(); // Set options on the socket this.connection.setTimeout(this.socketOptions.timeout); - this.connection.setNoDelay(this.socketOptions.noDelay); + // Work around for 0.4.X + if(process.version.indexOf("v0.4") == -1) this.connection.setNoDelay(this.socketOptions.noDelay); // Set keep alive if defined - if(this.socketOptions.keepAlive > 0) { - this.connection.setKeepAlive(true, this.socketOptions.keepAlive); - } else { - this.connection.setKeepAlive(false); - } + if(process.version.indexOf("v0.4") == -1) { + if(this.socketOptions.keepAlive > 0) { + this.connection.setKeepAlive(true, this.socketOptions.keepAlive); + } else { + this.connection.setKeepAlive(false); + } + } // Set up pair for tls with server, accept self-signed certificates as well this.pair = tls.createSecurePair(false); @@ -88,13 +91,16 @@ Connection.prototype.start = function() { this.connection = net.createConnection(this.socketOptions.port, this.socketOptions.host); // Set options on the socket this.connection.setTimeout(this.socketOptions.timeout); - this.connection.setNoDelay(this.socketOptions.noDelay); + // Work around for 0.4.X + if(process.version.indexOf("v0.4") == -1) this.connection.setNoDelay(this.socketOptions.noDelay); // Set keep alive if defined - if(this.socketOptions.keepAlive > 0) { - this.connection.setKeepAlive(true, this.socketOptions.keepAlive); - } else { - this.connection.setKeepAlive(false); - } + if(process.version.indexOf("v0.4") == -1) { + if(this.socketOptions.keepAlive > 0) { + this.connection.setKeepAlive(true, this.socketOptions.keepAlive); + } else { + this.connection.setKeepAlive(false); + } + } // Set up write stream this.writeSteam = this.connection; diff --git a/package.json b/package.json index c666b0ea64..bc9e78815a 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "mongodb" , "description" : "A node.js driver for MongoDB" , "keywords" : ["mongodb", "mongo", "driver", "db"] -, "version" : "0.9.7-3-4" +, "version" : "0.9.7-3-5" , "author" : "Christian Amor Kvalheim " , "contributors" : [ "Aaron Heckmann", "Christoph Pojer",