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/db/pdfile.cpp b/db/pdfile.cpp index 09a29ef8e06..8955ea2419d 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -317,6 +317,12 @@ auto_ptr DataFileMgr::findAll(const char *ns) { return auto_ptr(new BasicCursor(DiskLoc())); } Extent *e = getExtent(loc); + while( e->firstRecord.isNull() && !e->xnext.isNull() ) { + cout << " DFM::findAll(): extent empty, skipping ahead" << endl; + // find a nonempty extent + // it might be nice to free the whole extent here! but have to clean up free recs then. + e = e->getNextExtent(); + } return auto_ptr(new BasicCursor( e->firstRecord )); } @@ -691,7 +697,7 @@ DiskLoc DataFileMgr::insert(const char *ns, const void *buf, int len, bool god) if( d->nIndexes ) indexRecord(d, buf, len, loc); -// cout << " inserted at loc:" << hex << loc.getOfs() << " lenwhdr:" << hex << lenWHdr << dec << endl; +// cout << " inserted at loc:" << hex << loc.getOfs() << " lenwhdr:" << hex << lenWHdr << dec << ' ' << ns << endl; return loc; } diff --git a/db/pdfile.h b/db/pdfile.h index dfe475383aa..c20b130d1d8 100644 --- a/db/pdfile.h +++ b/db/pdfile.h @@ -41,7 +41,8 @@ private: MemoryMappedFile mmf; PDFHeader *header; - int length; +int __unUsEd; +// int length; int fileNo; }; @@ -263,9 +264,15 @@ inline DiskLoc Record::getNext(const DiskLoc& myLoc) { if( nextOfs != DiskLoc::NullOfs ) return DiskLoc(myLoc.a(), nextOfs); Extent *e = myExtent(myLoc); - if( e->xnext.isNull() ) - return DiskLoc(); // end of table. - return e->xnext.ext()->firstRecord; + while( 1 ) { + if( e->xnext.isNull() ) + return DiskLoc(); // end of table. + e = e->xnext.ext(); + if( !e->firstRecord.isNull() ) + break; + // entire extent could be empty, keep looking + } + return e->firstRecord; } inline DiskLoc Record::getPrev(const DiskLoc& myLoc) { if( prevOfs != DiskLoc::NullOfs ) diff --git a/grid/message.cpp b/grid/message.cpp index f6da3a24059..ca328453fdb 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 #include @@ -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 {