Ticket #12555: 0002-Fix-white-screen-of-death-in-remotedesktop.patch

File 0002-Fix-white-screen-of-death-in-remotedesktop.patch, 4.8 KB (added by DarkmatterVale, 9 years ago)
  • src/apps/remotedesktop/RemoteView.cpp

    From c22888fa8ecb6e98ed798b8e043af9493e43c9c5 Mon Sep 17 00:00:00 2001
    From: DarkmatterVale <valetolpegin@gmail.com>
    Date: Fri, 1 Jan 2016 13:08:10 +0000
    Subject: [PATCH 2/2] Fix white screen of death in remotedesktop
    
    ---
     src/apps/remotedesktop/RemoteView.cpp               | 21 +++++++++++++++++++--
     .../app/drawing/interface/remote/NetReceiver.cpp    | 14 +++++++++++---
     2 files changed, 30 insertions(+), 5 deletions(-)
    
    diff --git a/src/apps/remotedesktop/RemoteView.cpp b/src/apps/remotedesktop/RemoteView.cpp
    index 0693886..399300a 100644
    a b RemoteView::RemoteView(BRect frame, uint16 listenPort)  
    7575    fReceiveBuffer = new(std::nothrow) StreamingRingBuffer(16 * 1024);
    7676    if (fReceiveBuffer == NULL) {
    7777        fInitStatus = B_NO_MEMORY;
     78        TRACE_ERROR("no memory available\n");
    7879        return;
    7980    }
    8081
    RemoteView::RemoteView(BRect frame, uint16 listenPort)  
    8586    fSendBuffer = new(std::nothrow) StreamingRingBuffer(16 * 1024);
    8687    if (fSendBuffer == NULL) {
    8788        fInitStatus = B_NO_MEMORY;
     89        TRACE_ERROR("no memory available\n");
    8890        return;
    8991    }
    9092
    RemoteView::RemoteView(BRect frame, uint16 listenPort)  
    9597    fReceiveEndpoint = new(std::nothrow) BNetEndpoint();
    9698    if (fReceiveEndpoint == NULL) {
    9799        fInitStatus = B_NO_MEMORY;
     100        TRACE_ERROR("no memory available\n");
    98101        return;
    99102    }
    100103
    RemoteView::RemoteView(BRect frame, uint16 listenPort)  
    105108    fReceiver = new(std::nothrow) NetReceiver(fReceiveEndpoint, fReceiveBuffer);
    106109    if (fReceiver == NULL) {
    107110        fInitStatus = B_NO_MEMORY;
     111        TRACE_ERROR("no memory available\n");
    108112        return;
    109113    }
    110114
    111115    fSendEndpoint = new(std::nothrow) BNetEndpoint();
    112116    if (fSendEndpoint == NULL) {
    113117        fInitStatus = B_NO_MEMORY;
     118        TRACE_ERROR("no memory available\n");
    114119        return;
    115120    }
    116121
    117122    fSender = new(std::nothrow) NetSender(fSendEndpoint, fSendBuffer);
    118123    if (fSender == NULL) {
    119124        fInitStatus = B_NO_MEMORY;
     125        TRACE_ERROR("no memory available\n");
    120126        return;
    121127    }
    122128
    RemoteView::RemoteView(BRect frame, uint16 listenPort)  
    125131        B_RGB32);
    126132    if (fOffscreenBitmap == NULL) {
    127133        fInitStatus = B_NO_MEMORY;
     134        TRACE_ERROR("no memory available\n");
    128135        return;
    129136    }
    130137
    RemoteView::RemoteView(BRect frame, uint16 listenPort)  
    132139        B_FOLLOW_NONE, B_WILL_DRAW);
    133140    if (fOffscreen == NULL) {
    134141        fInitStatus = B_NO_MEMORY;
     142        TRACE_ERROR("no memory available\n");
    135143        return;
    136144    }
    137145
    RemoteView::RemoteView(BRect frame, uint16 listenPort)  
    142150        this);
    143151    if (fDrawThread < 0) {
    144152        fInitStatus = fDrawThread;
     153
     154        TRACE_ERROR("failed to start _DrawThread()\n");
     155        TRACE_ERROR("status = %" B_PRIx32 "\n", fInitStatus);
     156
    145157        return;
    146158    }
    147159
    RemoteView::_DrawThread()  
    438450    while (!fStopThread) {
    439451        uint16 code;
    440452        status_t status = message.NextMessage(code);
     453
    441454        if (status != B_OK) {
    442             TRACE_ERROR("failed to read message from receiver\n");
    443             break;
     455            if (status == B_TIMED_OUT || status == -1) {
     456                TRACE_ERROR("could not connect to device\n");
     457            } else {
     458                TRACE_ERROR("failed to read message from receiver\n");
     459                break;
     460            }
    444461        }
    445462
    446463        TRACE("code %u with %ld bytes data\n", code, message.DataLeft());
  • src/servers/app/drawing/interface/remote/NetReceiver.cpp

    diff --git a/src/servers/app/drawing/interface/remote/NetReceiver.cpp b/src/servers/app/drawing/interface/remote/NetReceiver.cpp
    index d88fcfa..2b5064d 100644
    a b  
    77 */
    88
    99#include "NetReceiver.h"
     10#include "RemoteMessage.h"
    1011
    1112#include "StreamingRingBuffer.h"
    1213
    NetReceiver::_NetworkReceiverEntry(void *data)  
    5960status_t
    6061NetReceiver::_NetworkReceiver()
    6162{
     63    static const uint16_t shutdown_message[] = { RP_CLOSE_CONNECTION, 0, 0 };
     64
    6265    status_t result = fListener->Listen();
    6366    if (result != B_OK) {
    6467        TRACE_ERROR("failed to listen on port: %s\n", strerror(result));
     68        fTarget->Write(shutdown_message, sizeof(shutdown_message));
    6569        return result;
    6670    }
    6771
    6872    while (!fStopThread) {
    69         fEndpoint = fListener->Accept(1000);
    70         if (fEndpoint == NULL)
    71             continue;
     73        fEndpoint = fListener->Accept(5000);
     74        if (fEndpoint == NULL) {
     75            fTarget->Write(shutdown_message, sizeof(shutdown_message));
     76            return B_ERROR;
     77        }
    7278
    7379        int32 errorCount = 0;
    7480        TRACE("new endpoint connection: %p\n", fEndpoint);
    NetReceiver::_NetworkReceiver()  
    8187                BNetEndpoint *endpoint = fEndpoint;
    8288                fEndpoint = NULL;
    8389                delete endpoint;
     90                fTarget->Write(shutdown_message, sizeof(shutdown_message));
    8491                return readSize;
    8592            }
    8693
    NetReceiver::_NetworkReceiver()  
    101108            if (result != B_OK) {
    102109                TRACE_ERROR("writing to ring buffer failed: %s\n",
    103110                    strerror(result));
     111                fTarget->Write(shutdown_message, sizeof(shutdown_message));
    104112                return result;
    105113            }
    106114        }