From 4d11d3ec9e199ec2f37321f39e3df1e3fad0f61b Mon Sep 17 00:00:00 2001 From: Robert Ricci <ricci@cs.utah.edu> Date: Tue, 12 Sep 2006 20:05:46 +0000 Subject: [PATCH] Try to make sure we get core dumps, by upping the coredump size rlimit. Also, check for error in packet size calculation vs. how much data is actually saved. --- pelab/magent/main.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pelab/magent/main.cc b/pelab/magent/main.cc index e641dbf25a..9c8ac28dc6 100755 --- a/pelab/magent/main.cc +++ b/pelab/magent/main.cc @@ -300,6 +300,16 @@ void init(void) sigaction(SIGTERM,&action,NULL); sigaction(SIGINT,&action,NULL); + /* + * Make sure we leave a core dump if we crash + */ + struct rlimit limit; + limit.rlim_cur = RLIM_INFINITY; + limit.rlim_max = RLIM_INFINITY; + if (setrlimit(RLIMIT_CORE,&limit)) { + logWrite(ERROR,"Unable to set core dump size!"); + } + srandom(getpid()); switch (global::connectionModelArg) { @@ -440,7 +450,15 @@ void replayWritePacket(PacketInfo * packet) { char *packetBuffer; packetBuffer = static_cast<char*>(malloc(head.size)); - savePacket(& packetBuffer[0], *packet); + //logWrite(REPLAY,"Making a packet buffer of size %d",head.size); + char* endptr = savePacket(& packetBuffer[0], *packet); + // savePacket returns the pointer to the last byte written, so we have to + // subtract 1 to find out how many bytes were written + int writtensize = (endptr - packetBuffer - 1); + if (writtensize != head.size) { + logWrite(ERROR,"replayWritePacket(): Made packet save buffer of size " + "%d, but wrote %d", head.size, writtensize); + } replayWrite(& packetBuffer[0], head.size); free(packetBuffer); } @@ -520,6 +538,7 @@ void replayLoop(void) break; case PACKET_INFO_SEND_COMMAND: case PACKET_INFO_ACK_COMMAND: + logWrite(EXCEPTION,"Got a packet: %d",head.type); done = ! replayRead(& packetBuffer[0], head.size); if (!done) { -- GitLab