diff options
author | Dwight <dmerriman@gmail.com> | 2007-11-26 19:38:14 -0500 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2007-11-26 19:38:14 -0500 |
commit | cbf7e7db0435641b05851059aeef752ad4a6bbb5 (patch) | |
tree | 0efcde0b0a469ad5bbfd882870ff78a2bac2ac08 /grid | |
parent | eb4ffe30f868fae9bb87353148cbc1d5a9c780ee (diff) | |
download | mongo-cbf7e7db0435641b05851059aeef752ad4a6bbb5.tar.gz |
jumbo frames on localhost
Diffstat (limited to 'grid')
-rw-r--r-- | grid/message.cpp | 2 | ||||
-rw-r--r-- | grid/protocol.h | 1 | ||||
-rw-r--r-- | grid/protoimpl.h | 13 | ||||
-rw-r--r-- | grid/protorecv.cpp | 11 | ||||
-rw-r--r-- | grid/protosend.cpp | 9 |
5 files changed, 22 insertions, 14 deletions
diff --git a/grid/message.cpp b/grid/message.cpp index 40888029449..fb465ab5f30 100644 --- a/grid/message.cpp +++ b/grid/message.cpp @@ -113,7 +113,7 @@ void MessagingPort::say(int channel, SockAddr& to, Message& toSend, int response ep.sa = to;
MS *ms = new MS(pc, ep, msgid);
- int mss = conn.mtu() - FragHeader;
+ int mss = conn.mtu(to) - FragHeader;
int left = toSend.data->len;
cout << "say() len:" << left << endl;
int i = 0;
diff --git a/grid/protocol.h b/grid/protocol.h index 8bf945ec88b..020c9ec75cb 100644 --- a/grid/protocol.h +++ b/grid/protocol.h @@ -70,6 +70,7 @@ public: F(Fragment *f);
~F();
int __num(); //frag #
+ int __len();
MSGID __msgid();
int __channel();
bool __isREQUESTACK(); // if true, this is just a request for acknowledgement not real data
diff --git a/grid/protoimpl.h b/grid/protoimpl.h index 5f019c6e732..3c5a1d8218f 100644 --- a/grid/protoimpl.h +++ b/grid/protoimpl.h @@ -182,10 +182,12 @@ inline void __sendMISSING(ProtocolConnection *pc, EndPoint& to, // -> receiver
inline F* __recv(UDPConnection& c, SockAddr& from) {
- Fragment *f = (Fragment *) malloc(c.mtu());
+ Fragment *f = (Fragment *) malloc(MaxMTU);
int n;
while( 1 ) {
- n = c.recvfrom((char*) f, c.mtu(), from);
+// n = c.recvfrom((char*) f, c.mtu(), from);
+ n = c.recvfrom((char*) f, MaxMTU, from);
+ cout << "recvfrom returned " << n << endl;
if( n >= 0 )
break;
if( !goingAway ) {
@@ -195,6 +197,12 @@ inline F* __recv(UDPConnection& c, SockAddr& from) { }
}
assert( f->fragmentLen == n );
+ if( f->fragmentNo > 0 ) {
+ // don't waste tons of space if the maxmtu is 16k but we get 1480
+ unsigned newsz = (f->fragmentLen + 255) & 0xffffff00;
+ if( newsz < MaxMTU )
+ f = (Fragment *) realloc(f, newsz);
+ }
{
lock lk(coutmutex);
DUMP(*f, from, "\t\t\t\t\t\t\t\t\t\t<");
@@ -222,6 +230,7 @@ inline F::F(Fragment *f) : internals(f), op(NORMAL) { }
inline F::~F() { free(internals); internals=0; }
inline int F::__num() { return internals->fragmentNo; }
+inline int F::__len() { return internals->fragmentLen; }
inline MSGID F::__msgid() { return internals->msgId; }
inline int F::__channel() { return internals->channel; }
inline bool F::__isREQUESTACK() { return op == REQUESTACK; }
diff --git a/grid/protorecv.cpp b/grid/protorecv.cpp index 74d488ba660..67ee3866912 100644 --- a/grid/protorecv.cpp +++ b/grid/protorecv.cpp @@ -123,9 +123,14 @@ bool MR::got(F *frag, EndPoint& fromAddr) { }
if( nExpected < 0 && i == 0 ) {
messageLenExpected = frag->__firstFragMsgLen();
- int mss = pc.udpConnection.mtu() - FragHeader;
- nExpected = (messageLenExpected + mss - 1) / mss;
- ptrace( cout << ".got first frag expected:" << nExpected << " expectedLen:" << messageLenExpected << endl; )
+ if( messageLenExpected == frag->__len()-FragHeader )
+ nExpected = 1;
+ else {
+ int mss = frag->__len()-FragHeader;
+ assert( messageLenExpected > mss );
+ nExpected = (messageLenExpected + mss - 1) / mss;
+ ptrace( cout << ".got first frag, expect:" << nExpected << "packets, expectedLen:" << messageLenExpected << endl; )
+ }
}
if( i >= (int) f.size() )
f.resize(i+1, 0);
diff --git a/grid/protosend.cpp b/grid/protosend.cpp index 9abef1f7916..4c18c44b697 100644 --- a/grid/protosend.cpp +++ b/grid/protosend.cpp @@ -134,15 +134,8 @@ void MS::send() { if( pc.myEnd.channel >= 0 )
__sendRESET(&pc, to);
pc.to = to;
-#if defined(_WIN32)
- pc.cs.delayMax = 1.0;
-#else
-// cout << "SADDR:" << pc.to.sa.sa.sin_addr.s_addr << endl;
- if( pc.to.sa.sa.sin_addr.s_addr == 0x100007f ) {
-// cout << "TEMP: LOCALHOST ************************************* " << endl;
+ if( pc.to.sa.isLocalHost() )
pc.cs.delayMax = 1.0;
- }
-#endif
}
while( pc.cs.pendingSend.size() >= 1 ) {
|