summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/goodies.h43
-rw-r--r--util/message.cpp2
-rw-r--r--util/message.h4
-rw-r--r--util/ntservice.cpp5
-rw-r--r--util/sock.cpp2
-rw-r--r--util/sock.h6
-rw-r--r--util/version.cpp2
7 files changed, 45 insertions, 19 deletions
diff --git a/util/goodies.h b/util/goodies.h
index c43f356..7b73996 100644
--- a/util/goodies.h
+++ b/util/goodies.h
@@ -651,29 +651,50 @@ namespace mongo {
// for convenience, '{' is greater than anything and stops number parsing
inline int lexNumCmp( const char *s1, const char *s2 ) {
+ //cout << "START : " << s1 << "\t" << s2 << endl;
while( *s1 && *s2 ) {
- bool p1 = ( *s1 == '{' );
- bool p2 = ( *s2 == '{' );
+ bool p1 = ( *s1 == (char)255 );
+ bool p2 = ( *s2 == (char)255 );
+ //cout << "\t\t " << p1 << "\t" << p2 << endl;
if ( p1 && !p2 )
return 1;
if ( p2 && !p1 )
return -1;
-
+
bool n1 = isNumber( *s1 );
bool n2 = isNumber( *s2 );
if ( n1 && n2 ) {
- char * e1;
- char * e2;
- long l1 = strtol( s1 , &e1 , 10 );
- long l2 = strtol( s2 , &e2 , 10 );
-
- if ( l1 > l2 )
+ // get rid of leading 0s
+ while ( *s1 == '0' ) s1++;
+ while ( *s2 == '0' ) s2++;
+
+ char * e1 = (char*)s1;
+ char * e2 = (char*)s2;
+
+ // find length
+ // if end of string, will break immediately ('\0')
+ while ( isNumber (*e1) ) e1++;
+ while ( isNumber (*e2) ) e2++;
+
+ int len1 = e1-s1;
+ int len2 = e2-s2;
+
+ int result;
+ // if one is longer than the other, return
+ if ( len1 > len2 ) {
return 1;
- else if ( l1 < l2 )
+ }
+ else if ( len2 > len1 ) {
return -1;
-
+ }
+ // if the lengths are equal, just strcmp
+ else if ( (result = strncmp(s1, s2, len1)) != 0 ) {
+ return result;
+ }
+
+ // otherwise, the numbers are equal
s1 = e1;
s2 = e2;
continue;
diff --git a/util/message.cpp b/util/message.cpp
index a809c1f..cd19bd5 100644
--- a/util/message.cpp
+++ b/util/message.cpp
@@ -301,7 +301,7 @@ namespace mongo {
ports.insert(this);
}
- MessagingPort::MessagingPort( int timeout, int ll ) : tag(0) {
+ MessagingPort::MessagingPort( double timeout, int ll ) : tag(0) {
_logLevel = ll;
ports.insert(this);
sock = -1;
diff --git a/util/message.h b/util/message.h
index 203ad83..9651141 100644
--- a/util/message.h
+++ b/util/message.h
@@ -98,7 +98,7 @@ namespace mongo {
// in some cases the timeout will actually be 2x this value - eg we do a partial send,
// then the timeout fires, then we try to send again, then the timeout fires again with
// no data sent, then we detect that the other side is down
- MessagingPort(int timeout = 0, int logLevel = 0 );
+ MessagingPort(double timeout = 0, int logLevel = 0 );
virtual ~MessagingPort();
@@ -133,7 +133,7 @@ namespace mongo {
PiggyBackData * piggyBackData;
public:
SockAddr farEnd;
- int _timeout;
+ double _timeout;
int _logLevel; // passed to log() when logging errors
static void closeAllSockets(unsigned tagMask = 0xffffffff);
diff --git a/util/ntservice.cpp b/util/ntservice.cpp
index fe4ae44..22f83a5 100644
--- a/util/ntservice.cpp
+++ b/util/ntservice.cpp
@@ -56,8 +56,13 @@ namespace mongo {
commandLine << arg << " \"" << dbpath << "\" ";
i++;
continue;
+ } else if ( arg == "--logpath" && i + 1 < argc ) {
+ commandLine << arg << " \"" << argv[i+1] << "\" ";
+ i++;
+ continue;
} else if ( arg.length() > 9 && arg.substr(0, 9) == "--service" ) {
// Strip off --service(Name|User|Password) arguments
+ i++;
continue;
}
commandLine << arg << " ";
diff --git a/util/sock.cpp b/util/sock.cpp
index c4e1a71..3b97c4b 100644
--- a/util/sock.cpp
+++ b/util/sock.cpp
@@ -51,7 +51,7 @@ namespace mongo {
addrinfo hints;
memset(&hints, 0, sizeof(addrinfo));
hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_ADDRCONFIG;
+ //hints.ai_flags = AI_ADDRCONFIG; // This is often recommended but don't do it. SERVER-1579
hints.ai_family = (IPv6Enabled() ? AF_UNSPEC : AF_INET);
stringstream ss;
diff --git a/util/sock.h b/util/sock.h
index 4b4290d..897be8a 100644
--- a/util/sock.h
+++ b/util/sock.h
@@ -115,10 +115,10 @@ namespace mongo {
return "/tmp/mongodb-" + BSONObjBuilder::numStr(port) + ".sock";
}
- inline void setSockTimeouts(int sock, int secs) {
+ inline void setSockTimeouts(int sock, double secs) {
struct timeval tv;
- tv.tv_sec = secs;
- tv.tv_usec = 0;
+ tv.tv_sec = (int)secs;
+ tv.tv_usec = (int)((long long)(secs*1000*1000) % (1000*1000));
bool report = logLevel > 3; // solaris doesn't provide these
DEV report = true;
bool ok = setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *) &tv, sizeof(tv) ) == 0;
diff --git a/util/version.cpp b/util/version.cpp
index 4987e19..c5ca8d4 100644
--- a/util/version.cpp
+++ b/util/version.cpp
@@ -14,7 +14,7 @@ namespace mongo {
// mongo processes version support
//
- const char versionString[] = "1.6.3";
+ const char versionString[] = "1.6.6-pre-";
string mongodVersion() {
stringstream ss;