Skip to content

Commit

Permalink
- add more logging to figure out why deskskare hangs when getting ex…
Browse files Browse the repository at this point in the history
…ceptions
  • Loading branch information
ritzalam committed Mar 21, 2012
1 parent 8b72076 commit 0723e82
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 39 deletions.
Binary file modified bigbluebutton-client/resources/prod/bbb-deskshare-applet-0.71.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,51 @@ public class BlockStreamProtocolDecoder extends CumulativeProtocolDecoder {
private static final byte MOUSE_LOCATION_EVENT = 3;

protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {

// Let's work with a buffer that contains header and the message length,
// ten (10) should be enough since header (6-bytes) plus length (4-bytes)
if (in.remaining() < 10) return false;

byte[] header = new byte[HEADER.length];

int start = in.position();
in.get(header, 0, HEADER.length);

int messageLength = in.getInt();
try {
// Let's work with a buffer that contains header and the message length,
// ten (10) should be enough since header (6-bytes) plus length (4-bytes)
if (in.remaining() < 10) return false;

byte[] header = new byte[HEADER.length];

int start = in.position();
in.get(header, 0, HEADER.length);

int messageLength = in.getInt();

if (in.remaining() < messageLength) {
in.position(start);
return false;
}

decodeMessage(session, in, out);

return true;
} catch (Exception e) {
throwAwayCorruptedPacket(in);
Integer numErrors = (Integer)session.getAttribute("NUM_ERRORS", 0);
session.setAttribute("NUM_ERRORS", numErrors++);

if (numErrors > 50) {
log.info("Closing session. Too many corrupt packets.");
int seqNum = 0;
String room = (String)session.getAttribute(ROOM, null);
if (room != null) {
log.info("Closing session [" + room + "]. Too many corrupt packets.");
CaptureEndBlockEvent ceb = new CaptureEndBlockEvent(room, seqNum);
out.write(ceb);
} else {
log.info("Cannot determine session. Too many corrupt packets.");
}
CloseFuture future = session.close(true);
}

return true;
}

if (in.remaining() < messageLength) {
in.position(start);
return false;
}

decodeMessage(session, in, out);

return true;
}

private void decodeMessage(IoSession session, IoBuffer in, ProtocolDecoderOutput out) {
private void decodeMessage(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
byte event = in.get();
switch (event) {
case CAPTURE_START_EVENT:
Expand All @@ -92,25 +114,7 @@ private void decodeMessage(IoSession session, IoBuffer in, ProtocolDecoderOutput
break;
default:
log.error("Unknown event: " + event);
throwAwayCorruptedPacket(in);
Integer numErrors = (Integer)session.getAttribute("NUM_ERRORS", 0);
session.setAttribute("NUM_ERRORS", numErrors++);

if (numErrors > 50) {
log.info("Closing session. Too many corrupt packets.");
int seqNum = 0;
String room = (String)session.getAttribute(ROOM, null);
if (room != null) {
log.info("Closing session [" + room + "]. Too many corrupt packets.");
CaptureEndBlockEvent ceb = new CaptureEndBlockEvent(room, seqNum);
out.write(ceb);
} else {
log.info("Cannot determine session. Too many corrupt packets.");
}
CloseFuture future = session.close(true);
}
break;

throw new Exception("Unknown event: " + event);
}
}

Expand Down Expand Up @@ -150,6 +154,7 @@ private void throwAwayCorruptedPacket(IoBuffer in) {
previous = current;
}

log.warn("Could not find end of corrupted packet.");
// Could not find CRLF in the buffer. Reset the initial
// position to the one we recorded above.
in.position(start);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class DeskShareApplet extends JApplet implements ClientListener {
@Override
public void init() {
System.out.println("Desktop Sharing Applet Initializing");

hostValue = getParameter("IP");
String port = getParameter("PORT");
if (port != null) portValue = Integer.parseInt(port);
Expand All @@ -69,6 +70,7 @@ public void init() {
@Override
public void start() {
System.out.println("Desktop Sharing Applet Starting");
System.out.println("v0.8-beta4 mar 22, 2012");
super.start();
client = new DeskshareClient.NewBuilder().host(hostValue).port(portValue)
.room(roomValue).captureWidth(cWidthValue)
Expand Down

0 comments on commit 0723e82

Please sign in to comment.