mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
recv()
This commit is contained in:
parent
dce3cb2a9e
commit
880049d39e
@ -291,6 +291,7 @@ void t()
|
||||
|
||||
Message m;
|
||||
while( 1 ) {
|
||||
curOp = 0;
|
||||
m.reset();
|
||||
stringstream ss;
|
||||
|
||||
@ -363,7 +364,8 @@ void t()
|
||||
receivedKillCursors(m);
|
||||
}
|
||||
else {
|
||||
cout << " operation isn't supported ?" << endl;
|
||||
cout << " operation isn't supported: " << m.data->operation << endl;
|
||||
assert(false);
|
||||
}
|
||||
|
||||
int ms = t.millis();
|
||||
|
@ -24,14 +24,16 @@ DataFileMgr theDataFileMgr;
|
||||
map<string,Client*> clients;
|
||||
Client *client;
|
||||
const char *curNs = "";
|
||||
int curOp;
|
||||
int MAGIC = 0x1000;
|
||||
int curOp = -2;
|
||||
|
||||
extern int otherTraceLevel;
|
||||
|
||||
void sayDbContext() {
|
||||
cout << " client: " << (client ? client->name.c_str() : "null");
|
||||
cout << " op:" << curOp << endl;
|
||||
cout << " ns: " << curNs << endl;
|
||||
if( client )
|
||||
cout << " ns: " << curNs << endl;
|
||||
}
|
||||
|
||||
JSObj::JSObj(Record *r) {
|
||||
|
@ -95,21 +95,33 @@ bool MessagingPort::connect(SockAddr& _far)
|
||||
|
||||
bool MessagingPort::recv(Message& m) {
|
||||
mmm( cout << "* recv() sock:" << this->sock << endl; )
|
||||
int len;
|
||||
int len = -1;
|
||||
|
||||
int x = ::recv(sock, (char *) &len, 4, 0);
|
||||
if( x == 0 ) {
|
||||
cout << "MessagingPort::recv(): conn closed? " << farEnd.toString() << endl;
|
||||
m.reset();
|
||||
return false;
|
||||
}
|
||||
if( x < 0 ) {
|
||||
cout << "MessagingPort::recv(): recv() error " << errno << ' ' << farEnd.toString()<<endl;
|
||||
m.reset();
|
||||
return false;
|
||||
char *lenbuf = (char *) &len;
|
||||
int lft = 4;
|
||||
while( 1 ) {
|
||||
int x = ::recv(sock, lenbuf, lft, 0);
|
||||
if( x == 0 ) {
|
||||
cout << "MessagingPort::recv(): conn closed? " << farEnd.toString() << endl;
|
||||
m.reset();
|
||||
return false;
|
||||
}
|
||||
if( x < 0 ) {
|
||||
cout << "MessagingPort::recv(): recv() error " << errno << ' ' << farEnd.toString()<<endl;
|
||||
m.reset();
|
||||
return false;
|
||||
}
|
||||
lft -= x;
|
||||
if( lft == 0 )
|
||||
break;
|
||||
lenbuf += x;
|
||||
cout << "MessagingPort::recv(): got " << x << " bytes wanted 4, lft=" << lft << endl;
|
||||
assert( lft > 0 );
|
||||
}
|
||||
|
||||
assert( x == 4 );
|
||||
// assert( x == 4 );
|
||||
|
||||
assert( len >= 0 && len <= 16000000 );
|
||||
|
||||
int z = (len+1023)&0xfffffc00; assert(z>=len);
|
||||
MsgData *md = (MsgData *) malloc(z);
|
||||
@ -123,7 +135,7 @@ bool MessagingPort::recv(Message& m) {
|
||||
char *p = (char *) &md->id;
|
||||
int left = len -4;
|
||||
while( 1 ) {
|
||||
x = ::recv(sock, p, left, 0);
|
||||
int x = ::recv(sock, p, left, 0);
|
||||
if( x == 0 ) {
|
||||
cout << "MessagingPort::recv(): conn closed? " << farEnd.toString() << endl;
|
||||
m.reset();
|
||||
|
Loading…
Reference in New Issue
Block a user