summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryellow <yellow@10gen.com>2008-01-24 16:09:24 +0000
committeryellow <yellow@10gen.com>2008-01-24 16:09:24 +0000
commit573b11ecd4c9592f4199f9c6f416a372e540765e (patch)
treef51bb3283ac044d761dbfaeff58f9171730ca446
parentda8ecf472130fa901330d34e38270d0e84779170 (diff)
downloadmongo-573b11ecd4c9592f4199f9c6f416a372e540765e.tar.gz
prebind
-rw-r--r--bin/run.tcsh8
-rw-r--r--grid/message.cpp1
-rw-r--r--util/sock.cpp2
-rw-r--r--util/sock.h10
4 files changed, 21 insertions, 0 deletions
diff --git a/bin/run.tcsh b/bin/run.tcsh
index 7dfe611513c..95b79bb81f2 100644
--- a/bin/run.tcsh
+++ b/bin/run.tcsh
@@ -1,6 +1,14 @@
while ( 1 == 1 )
if ( -f log/run.log ) mv log/run.log log/run.log.1
+ if ( -f log/run.log1 ) mv log/run.log log/run.log.2
+ if ( -f log/run.log2 ) mv log/run.log log/run.log.3
+ if ( -f log/run.log3 ) mv log/run.log log/run.log.4
+ if ( -f log/run.log4 ) mv log/run.log log/run.log.5
+ if ( -f log/run.log5 ) mv log/run.log log/run.log.6
+ if ( -f log/run.log6 ) mv log/run.log log/run.log.7
+
./db/db run >& log/run.log
+ sleep 2
end
\ No newline at end of file
diff --git a/grid/message.cpp b/grid/message.cpp
index bf8266e23ae..63f466d6f8b 100644
--- a/grid/message.cpp
+++ b/grid/message.cpp
@@ -20,6 +20,7 @@ void Listener::listen() {
cout << "ERROR: listen(): invalid socket? " << errno << endl;
return;
}
+ prebindOptions( sock );
if( bind(sock, (sockaddr *) &me.sa, me.addressSize) != 0 ) {
cout << "listen(): bind() failed errno:" << errno << endl;
if( errno == 98 )
diff --git a/util/sock.cpp b/util/sock.cpp
index d5fb7af1742..6d25536bfb3 100644
--- a/util/sock.cpp
+++ b/util/sock.cpp
@@ -64,6 +64,7 @@ void smain() {
//-----------------------------------------------
// Create a receiver socket to receive datagrams
RecvSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ prebindOptions( RecvSocket );
//-----------------------------------------------
// Bind the socket to any address and the specified port.
@@ -118,6 +119,7 @@ void xmain() {
// Create a receiver socket to receive datagrams
RecvSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ prebindOptions( RecvSocket );
//-----------------------------------------------
// Bind the socket to any address and the specified port.
diff --git a/util/sock.h b/util/sock.h
index 267102fca3a..9bd3088fc2d 100644
--- a/util/sock.h
+++ b/util/sock.h
@@ -16,6 +16,8 @@ inline void disableNagle(int sock) {
if( setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *) &x, sizeof(x)) )
cout << "ERROR: disableNagle failed" << endl;
}
+inline void prebindOptions( int sock ){
+}
#else
#include <sys/socket.h>
#include <sys/types.h>
@@ -34,6 +36,14 @@ inline void disableNagle(int sock) {
if( setsockopt(sock, SOL_TCP, TCP_NODELAY, (char *) &x, sizeof(x)) )
cout << "ERROR: disableNagle failed" << endl;
}
+inline void prebindOptions( int sock ){
+ cout << "doing prebind option" << endl;
+ int x = 1;
+ if ( setsockopt( sock , SOL_SOCKET, SO_REUSEADDR, &x, sizeof(x)) < 0 )
+ cout << "Failed to set socket opt, SO_REUSEADDR" << endl;
+}
+
+
#endif
struct SockAddr {