diff options
author | eea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-05-12 20:03:19 +0000 |
---|---|---|
committer | eea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-05-12 20:03:19 +0000 |
commit | 26292c689203c30db37cfd00ea0e87dbf2cc34ee (patch) | |
tree | b65ba6ab104810f13933527be4121012a0823cd6 /java | |
parent | 77a6dfc94a0c95a08f7accff8c137357d52bf2c3 (diff) | |
download | ATCD-26292c689203c30db37cfd00ea0e87dbf2cc34ee.tar.gz |
Updated the LogRecord so it's compatible with C++ ACE again.
Diffstat (limited to 'java')
-rw-r--r-- | java/netsvcs/Logger/LogRecord.java | 9 | ||||
-rw-r--r-- | java/netsvcs/Logger/ServerLoggingHandler.java | 26 |
2 files changed, 11 insertions, 24 deletions
diff --git a/java/netsvcs/Logger/LogRecord.java b/java/netsvcs/Logger/LogRecord.java index 721341cb252..c2f1e4bdeee 100644 --- a/java/netsvcs/Logger/LogRecord.java +++ b/java/netsvcs/Logger/LogRecord.java @@ -44,7 +44,10 @@ public class LogRecord */ public LogRecord() { - this(0, (int)new Date().getTime(), 0); + type(0); + timeStamp((int)new Date().getTime()); + length(0); + pid(0); } /** @@ -108,8 +111,9 @@ public class LogRecord // Order here must match layout order in the C++ class. // This, of course, is VERY fragile, and ought not be used as // a model for anything except how NOT to do anything. - type(dis.readInt()); + length(dis.readInt()); + type(dis.readInt()); this.timeStamp((long)dis.readInt() * 1000); // Skip smaller time resolution info since we're lucky if Java's @@ -121,6 +125,7 @@ public class LogRecord // Does readFully() allocate space for the buffer? Either // way, we won't have memory leaks :-) int dataLength = (int) (length_ - numIntMembers * sizeofIntInBytes); + msgData_ = new byte[dataLength]; dis.readFully(msgData_, 0, dataLength); } diff --git a/java/netsvcs/Logger/ServerLoggingHandler.java b/java/netsvcs/Logger/ServerLoggingHandler.java index 9088e17d9d1..40f1aee8440 100644 --- a/java/netsvcs/Logger/ServerLoggingHandler.java +++ b/java/netsvcs/Logger/ServerLoggingHandler.java @@ -71,37 +71,19 @@ public class ServerLoggingHandler extends SvcHandler for (;;) { - // Messages arrive in the following format: - // o 4 byte length (network format) - // o message, in ACE.LogRecord format + // Messages arrive in the ACE.LogRecord format // // Hey! We need exception catching in here too! try { // Reconstitute a log message from the wire LogRecord rec = new LogRecord(); - - // We don't really need this, because - // the object already knows how to - // extract itself properly. However, - // in order to interoperate with the - // C++ version, this must be extracted. - // Plus, it makes a convenient way to - // check everything. - int length = dis.readInt(); rec.streamInFrom(dis); - if (rec.length() == length) - { - // Give the record to the log processor - this.receiver_.logRecord(this.hostName(), - rec); - } - else - { - ACE.ERROR(Thread.currentThread().getName() + ": Length error"); - } + // Give the record to the log processor + this.receiver_.logRecord(this.hostName(), + rec); } catch (EOFException eof) { |