Commit 18c8a948 authored by Jonathon Duerig's avatar Jonathon Duerig

Added logging to try to find two bugs.

parent f1be0720
......@@ -117,7 +117,7 @@ void Connection::connect(unsigned int ip)
isConnected = peer->isConnected();
if (isConnected)
{
logWrite(CONNECTION, "Inserting a connection with key %s",
logWrite(PCAP,"Inserting key: %s",
planet.toString().c_str());
global::planetMap[planet] = this;
}
......@@ -185,6 +185,8 @@ Time Connection::writeToConnection(Time const & previousTime)
if (!isConnected && result.isConnected)
{
planet = result.planet;
logWrite(PCAP,"Inserting key: %s",
planet.toString().c_str());
global::planetMap[planet] = this;
}
else if (isConnected && result.isConnected
......@@ -193,8 +195,9 @@ Time Connection::writeToConnection(Time const & previousTime)
logWrite(CONNECTION, "OldKey: %s", planet.toString().c_str());
global::planetMap[planet] = NULL;
planet = result.planet;
logWrite(PCAP,"Inserting key: %s",
planet.toString().c_str());
global::planetMap[planet] = this;
logWrite(CONNECTION, "NewKey: %s", planet.toString().c_str());
}
isConnected = result.isConnected;
bufferFull = result.bufferFull;
......
......@@ -65,7 +65,11 @@ void DirectInput::nextCommand(fd_set * readable)
if (error == Header::PREFIX_SIZE - index)
{
unsigned char version = headerBuffer[Header::PREFIX_SIZE - 1];
global::CONTROL_VERSION = version;
if (global::CONTROL_VERSION != version)
{
logWrite(COMMAND_INPUT, "Setting version to %d", version);
global::CONTROL_VERSION = version;
}
versionSize = Header::headerSize();
index += error;
state = HEADER;
......
......@@ -809,8 +809,10 @@ namespace
bool outgoing;
logWrite(PCAP,"Looking up key (outgoing): t=%d,i=%s,lp=%i,rp=%i",
transport, inet_ntoa(ipPacket->ip_dst),key.localPort,key.remotePort);
// logWrite(PCAP,"Looking up key (outgoing): t=%d,i=%s,lp=%i,rp=%i",
// transport, inet_ntoa(ipPacket->ip_dst),key.localPort,key.remotePort);
logWrite(PCAP, "Looking up key (outgoing): %s",
key.toString().c_str());
map<PlanetOrder, Connection *>::iterator pos;
pos = global::planetMap.find(key);
......@@ -821,8 +823,10 @@ namespace
swap(key.localPort, key.remotePort);
// key.localPort = ntohs(tcpPacket->dest);
// key.remotePort = ntohs(tcpPacket->source);
logWrite(PCAP,"Looking up key (incoming): t=%d,i=%s,lp=%i,rp=%i",
transport,inet_ntoa(ipPacket->ip_src),key.localPort,key.remotePort);
logWrite(PCAP, "Looking up key (incoming): %s",
key.toString().c_str());
// logWrite(PCAP,"Looking up key (incoming): t=%d,i=%s,lp=%i,rp=%i",
// transport,inet_ntoa(ipPacket->ip_src),key.localPort,key.remotePort);
pos = global::planetMap.find(key);
if (pos != global::planetMap.end()) {
outgoing = false;
......
......@@ -492,14 +492,15 @@ def send_write(conn, key, timestamp, app_connection, size):
def receive_characteristic(conn):
global socket_map
buf = conn.recv(36)
if len(buf) != 36:
raise Exception('ERROR: Event header is the wrong size. Length: '
+ str(len(buf)))
eventType = load_char(buf[0:1]);
size = load_short(buf[1:3]);
version = load_char(buf[3:4]);
if version != magent_version:
raise Exception('ERROR: Wrong version from magent.');
raise Exception('ERROR: Wrong version from magent: version('
+ str(version) + ') buf_size(' + len(buf) + ')');
if len(buf) != 36:
raise Exception('ERROR: Event header is the wrong size. Length: '
+ str(len(buf)))
socketKey = buf[4:34];
connectionKey = load_short(buf[34:36]);
......@@ -550,7 +551,8 @@ def receive_characteristic(conn):
else:
sys.stdout.write('Recieve: Ignored TENTATIVE_THROUGHPUT for '
+ app_connection.dest.remote_ip + ' - '
+ buf + ' vs ' + app_connection.last_bandwidth + '\n')
+ buf + ' vs ' + str(app_connection.last_bandwidth)
+ '\n')
elif eventType == AUTHORITATIVE_BANDWIDTH and int(buf) > 0:
# We know that the bandwidth has definitely changed. Reset everything.
app_connection.last_bandwidth = int(buf)
......@@ -607,8 +609,8 @@ def set_link(source, dest, ending, event_type='MODIFY'):
def send_command(conn, key, command_id, command):
if is_fake:
sys.stdout.write('Command: ' + key + ' ' + command_to_string[command_id]
+ '\n')
sys.stdout.write('Command: ' + key + ' version(' + str(magent_version)
+ ') ' + command_to_string[command_id] + '\n')
return
output = (save_char(command_id)
+ save_short(len(command))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment