Fix white screen of death in remotedesktop
Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
parent
b23cb01e7c
commit
8de8a927ee
@ -75,6 +75,7 @@ RemoteView::RemoteView(BRect frame, uint16 listenPort)
|
|||||||
fReceiveBuffer = new(std::nothrow) StreamingRingBuffer(16 * 1024);
|
fReceiveBuffer = new(std::nothrow) StreamingRingBuffer(16 * 1024);
|
||||||
if (fReceiveBuffer == NULL) {
|
if (fReceiveBuffer == NULL) {
|
||||||
fInitStatus = B_NO_MEMORY;
|
fInitStatus = B_NO_MEMORY;
|
||||||
|
TRACE_ERROR("no memory available\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +86,7 @@ RemoteView::RemoteView(BRect frame, uint16 listenPort)
|
|||||||
fSendBuffer = new(std::nothrow) StreamingRingBuffer(16 * 1024);
|
fSendBuffer = new(std::nothrow) StreamingRingBuffer(16 * 1024);
|
||||||
if (fSendBuffer == NULL) {
|
if (fSendBuffer == NULL) {
|
||||||
fInitStatus = B_NO_MEMORY;
|
fInitStatus = B_NO_MEMORY;
|
||||||
|
TRACE_ERROR("no memory available\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +97,7 @@ RemoteView::RemoteView(BRect frame, uint16 listenPort)
|
|||||||
fReceiveEndpoint = new(std::nothrow) BNetEndpoint();
|
fReceiveEndpoint = new(std::nothrow) BNetEndpoint();
|
||||||
if (fReceiveEndpoint == NULL) {
|
if (fReceiveEndpoint == NULL) {
|
||||||
fInitStatus = B_NO_MEMORY;
|
fInitStatus = B_NO_MEMORY;
|
||||||
|
TRACE_ERROR("no memory available\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,18 +108,21 @@ RemoteView::RemoteView(BRect frame, uint16 listenPort)
|
|||||||
fReceiver = new(std::nothrow) NetReceiver(fReceiveEndpoint, fReceiveBuffer);
|
fReceiver = new(std::nothrow) NetReceiver(fReceiveEndpoint, fReceiveBuffer);
|
||||||
if (fReceiver == NULL) {
|
if (fReceiver == NULL) {
|
||||||
fInitStatus = B_NO_MEMORY;
|
fInitStatus = B_NO_MEMORY;
|
||||||
|
TRACE_ERROR("no memory available\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fSendEndpoint = new(std::nothrow) BNetEndpoint();
|
fSendEndpoint = new(std::nothrow) BNetEndpoint();
|
||||||
if (fSendEndpoint == NULL) {
|
if (fSendEndpoint == NULL) {
|
||||||
fInitStatus = B_NO_MEMORY;
|
fInitStatus = B_NO_MEMORY;
|
||||||
|
TRACE_ERROR("no memory available\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fSender = new(std::nothrow) NetSender(fSendEndpoint, fSendBuffer);
|
fSender = new(std::nothrow) NetSender(fSendEndpoint, fSendBuffer);
|
||||||
if (fSender == NULL) {
|
if (fSender == NULL) {
|
||||||
fInitStatus = B_NO_MEMORY;
|
fInitStatus = B_NO_MEMORY;
|
||||||
|
TRACE_ERROR("no memory available\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,6 +131,7 @@ RemoteView::RemoteView(BRect frame, uint16 listenPort)
|
|||||||
B_RGB32);
|
B_RGB32);
|
||||||
if (fOffscreenBitmap == NULL) {
|
if (fOffscreenBitmap == NULL) {
|
||||||
fInitStatus = B_NO_MEMORY;
|
fInitStatus = B_NO_MEMORY;
|
||||||
|
TRACE_ERROR("no memory available\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +139,7 @@ RemoteView::RemoteView(BRect frame, uint16 listenPort)
|
|||||||
B_FOLLOW_NONE, B_WILL_DRAW);
|
B_FOLLOW_NONE, B_WILL_DRAW);
|
||||||
if (fOffscreen == NULL) {
|
if (fOffscreen == NULL) {
|
||||||
fInitStatus = B_NO_MEMORY;
|
fInitStatus = B_NO_MEMORY;
|
||||||
|
TRACE_ERROR("no memory available\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,6 +150,10 @@ RemoteView::RemoteView(BRect frame, uint16 listenPort)
|
|||||||
this);
|
this);
|
||||||
if (fDrawThread < 0) {
|
if (fDrawThread < 0) {
|
||||||
fInitStatus = fDrawThread;
|
fInitStatus = fDrawThread;
|
||||||
|
|
||||||
|
TRACE_ERROR("failed to start _DrawThread()\n");
|
||||||
|
TRACE_ERROR("status = %" B_PRIx32 "\n", fInitStatus);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,9 +450,14 @@ RemoteView::_DrawThread()
|
|||||||
while (!fStopThread) {
|
while (!fStopThread) {
|
||||||
uint16 code;
|
uint16 code;
|
||||||
status_t status = message.NextMessage(code);
|
status_t status = message.NextMessage(code);
|
||||||
|
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
TRACE_ERROR("failed to read message from receiver\n");
|
if (status == B_TIMED_OUT || status == -1) {
|
||||||
break;
|
TRACE_ERROR("could not connect to device\n");
|
||||||
|
} else {
|
||||||
|
TRACE_ERROR("failed to read message from receiver\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("code %u with %ld bytes data\n", code, message.DataLeft());
|
TRACE("code %u with %ld bytes data\n", code, message.DataLeft());
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NetReceiver.h"
|
#include "NetReceiver.h"
|
||||||
|
#include "RemoteMessage.h"
|
||||||
|
|
||||||
#include "StreamingRingBuffer.h"
|
#include "StreamingRingBuffer.h"
|
||||||
|
|
||||||
@ -59,16 +60,21 @@ NetReceiver::_NetworkReceiverEntry(void *data)
|
|||||||
status_t
|
status_t
|
||||||
NetReceiver::_NetworkReceiver()
|
NetReceiver::_NetworkReceiver()
|
||||||
{
|
{
|
||||||
|
static const uint16_t shutdown_message[] = { RP_CLOSE_CONNECTION, 0, 0 };
|
||||||
|
|
||||||
status_t result = fListener->Listen();
|
status_t result = fListener->Listen();
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ERROR("failed to listen on port: %s\n", strerror(result));
|
TRACE_ERROR("failed to listen on port: %s\n", strerror(result));
|
||||||
|
fTarget->Write(shutdown_message, sizeof(shutdown_message));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!fStopThread) {
|
while (!fStopThread) {
|
||||||
fEndpoint = fListener->Accept(1000);
|
fEndpoint = fListener->Accept(5000);
|
||||||
if (fEndpoint == NULL)
|
if (fEndpoint == NULL) {
|
||||||
continue;
|
fTarget->Write(shutdown_message, sizeof(shutdown_message));
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
int32 errorCount = 0;
|
int32 errorCount = 0;
|
||||||
TRACE("new endpoint connection: %p\n", fEndpoint);
|
TRACE("new endpoint connection: %p\n", fEndpoint);
|
||||||
@ -81,6 +87,7 @@ NetReceiver::_NetworkReceiver()
|
|||||||
BNetEndpoint *endpoint = fEndpoint;
|
BNetEndpoint *endpoint = fEndpoint;
|
||||||
fEndpoint = NULL;
|
fEndpoint = NULL;
|
||||||
delete endpoint;
|
delete endpoint;
|
||||||
|
fTarget->Write(shutdown_message, sizeof(shutdown_message));
|
||||||
return readSize;
|
return readSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +108,7 @@ NetReceiver::_NetworkReceiver()
|
|||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ERROR("writing to ring buffer failed: %s\n",
|
TRACE_ERROR("writing to ring buffer failed: %s\n",
|
||||||
strerror(result));
|
strerror(result));
|
||||||
|
fTarget->Write(shutdown_message, sizeof(shutdown_message));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user