CLOUDSTACK-6898: [Hyper-V] fixed rdp console freezing during reboot.

Console was freezing because we read data from socket in blocking mode.
During reboot it was blocking infintely.
To fix issue, now we are reading data in non-blocking mode.
In non-blocking mode I set the timeout to 5 seconds.
This commit is contained in:
Anshul Gangwar 2014-09-03 14:28:28 +05:30 committed by Devdeep Singh
parent 63ea596ba2
commit 4c9507d21e
2 changed files with 7 additions and 4 deletions

View File

@ -371,7 +371,7 @@ public class SyncLink implements Link {
// Pull source in loop
while (!shutdown) {
// Pull data from source element and send it to sink element
ByteBuffer data = pull(true);
ByteBuffer data = pull(false);
if (data != null)
sink.handleData(data, this);

View File

@ -101,20 +101,23 @@ public class AprSocketSource extends BaseElement {
if (verbose)
System.out.println("[" + this + "] INFO: Reading data from stream.");
// to unblock during reboot
long startTime = System.currentTimeMillis();
// FIXME: If pull is destroyed or socket is closed, segfault will happen here
int actualLength = (block) ? // Blocking read
Socket.recv(socket, buf.data, buf.offset, buf.data.length - buf.offset)
: // Non-blocking read
Socket.recvt(socket, buf.data, buf.offset, buf.data.length - buf.offset, 1);
Socket.recvt(socket, buf.data, buf.offset, buf.data.length - buf.offset, 5000000);
if (socketWrapper.shutdown) {
socketWrapper.destroyPull();
return;
}
if (actualLength < 0) {
long elapsedTime = System.currentTimeMillis() - startTime;
if (actualLength < 0 || elapsedTime > 5000) {
if (verbose)
System.out.println("[" + this + "] INFO: End of stream.");
System.out.println("[" + this + "] INFO: End of stream or timeout");
buf.unref();
closeStream();