mirror of
https://github.com/FreeRDP/FreeRDP.git
synced 2025-06-03 00:00:20 +00:00
[server,shadow] abort connection if a resize fails
The shadow server tries to resize the client to use a compatible resolution. If that fails, e.g. if there is another resize request after the disconnect/reconnect sequence, abort the connection.
This commit is contained in:
parent
34f44ce4a1
commit
d6ab9d5f63
@ -116,6 +116,10 @@ struct rdp_shadow_client
|
|||||||
RdpsndServerContext* rdpsnd;
|
RdpsndServerContext* rdpsnd;
|
||||||
audin_server_context* audin;
|
audin_server_context* audin;
|
||||||
RdpgfxServerContext* rdpgfx;
|
RdpgfxServerContext* rdpgfx;
|
||||||
|
|
||||||
|
BOOL resizeRequested;
|
||||||
|
UINT32 resizeWidth;
|
||||||
|
UINT32 resizeHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rdp_shadow_server
|
struct rdp_shadow_server
|
||||||
|
@ -382,6 +382,65 @@ static BOOL shadow_client_capabilities(freerdp_peer* peer)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void shadow_reset_desktop_resize(rdpShadowClient* client)
|
||||||
|
{
|
||||||
|
WINPR_ASSERT(client);
|
||||||
|
client->resizeRequested = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL shadow_send_desktop_resize(rdpShadowClient* client)
|
||||||
|
{
|
||||||
|
BOOL rc;
|
||||||
|
rdpUpdate* update;
|
||||||
|
rdpSettings* settings;
|
||||||
|
const freerdp_peer* peer;
|
||||||
|
|
||||||
|
WINPR_ASSERT(client);
|
||||||
|
|
||||||
|
settings = client->context.settings;
|
||||||
|
peer = client->context.peer;
|
||||||
|
WINPR_ASSERT(peer);
|
||||||
|
WINPR_ASSERT(client->server);
|
||||||
|
WINPR_ASSERT(client->server->surface);
|
||||||
|
|
||||||
|
const UINT32 resizeWidth = client->server->surface->width;
|
||||||
|
const UINT32 resizeHeight = client->server->surface->height;
|
||||||
|
|
||||||
|
if (client->resizeRequested)
|
||||||
|
{
|
||||||
|
if ((resizeWidth == client->resizeWidth) && (resizeHeight == client->resizeHeight))
|
||||||
|
{
|
||||||
|
const UINT32 w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
|
||||||
|
const UINT32 h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
|
||||||
|
WLog_WARN(TAG,
|
||||||
|
"detected previous resize request for resolution %" PRIu32 "x%" PRIu32
|
||||||
|
", still have %" PRIu32 "x%" PRIu32 ", disconnecting peer",
|
||||||
|
resizeWidth, resizeHeight, w, h);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update = client->context.update;
|
||||||
|
WINPR_ASSERT(update);
|
||||||
|
WINPR_ASSERT(update->DesktopResize);
|
||||||
|
|
||||||
|
// Update peer resolution, required so that during disconnect/reconnect the correct resolution
|
||||||
|
// is sent to the client.
|
||||||
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, resizeWidth))
|
||||||
|
return FALSE;
|
||||||
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, resizeHeight))
|
||||||
|
return FALSE;
|
||||||
|
rc = update->DesktopResize(update->context);
|
||||||
|
WLog_INFO(TAG, "Client %s resize requested (%" PRIu32 "x%" PRIu32 "@%" PRIu32 ")",
|
||||||
|
peer->hostname, resizeWidth, resizeHeight,
|
||||||
|
freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth));
|
||||||
|
client->resizeRequested = TRUE;
|
||||||
|
client->resizeWidth = resizeWidth;
|
||||||
|
client->resizeHeight = resizeHeight;
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL shadow_client_post_connect(freerdp_peer* peer)
|
static BOOL shadow_client_post_connect(freerdp_peer* peer)
|
||||||
{
|
{
|
||||||
int authStatus;
|
int authStatus;
|
||||||
@ -425,18 +484,12 @@ static BOOL shadow_client_post_connect(freerdp_peer* peer)
|
|||||||
/* Resize client if necessary */
|
/* Resize client if necessary */
|
||||||
if (shadow_client_recalc_desktop_size(client))
|
if (shadow_client_recalc_desktop_size(client))
|
||||||
{
|
{
|
||||||
BOOL rc;
|
shadow_send_desktop_resize(client);
|
||||||
rdpUpdate* update = peer->context->update;
|
|
||||||
WINPR_ASSERT(update);
|
|
||||||
WINPR_ASSERT(update->DesktopResize);
|
|
||||||
|
|
||||||
rc = update->DesktopResize(update->context);
|
|
||||||
WLog_INFO(TAG, "Client from %s is resized (%" PRIu32 "x%" PRIu32 "@%" PRIu32 ")",
|
|
||||||
peer->hostname, settings->DesktopWidth, settings->DesktopHeight,
|
|
||||||
freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth));
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shadow_reset_desktop_resize(client);
|
||||||
|
|
||||||
if (shadow_client_channels_post_connect(client) != CHANNEL_RC_OK)
|
if (shadow_client_channels_post_connect(client) != CHANNEL_RC_OK)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -1858,22 +1911,14 @@ static BOOL shadow_client_send_resize(rdpShadowClient* client, SHADOW_GFX_STATUS
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send Resize */
|
/* Send Resize */
|
||||||
WINPR_ASSERT(peer->context);
|
if (!shadow_send_desktop_resize(client))
|
||||||
WINPR_ASSERT(peer->context->update);
|
|
||||||
WINPR_ASSERT(peer->context->update->DesktopResize);
|
|
||||||
if (!peer->context->update->DesktopResize(peer->context->update->context))
|
|
||||||
{
|
|
||||||
WLog_ERR(TAG, "DesktopResize failed");
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
shadow_reset_desktop_resize(client);
|
||||||
|
|
||||||
/* Clear my invalidRegion. shadow_client_activate refreshes fullscreen */
|
/* Clear my invalidRegion. shadow_client_activate refreshes fullscreen */
|
||||||
EnterCriticalSection(&(client->lock));
|
EnterCriticalSection(&(client->lock));
|
||||||
region16_clear(&(client->invalidRegion));
|
region16_clear(&(client->invalidRegion));
|
||||||
LeaveCriticalSection(&(client->lock));
|
LeaveCriticalSection(&(client->lock));
|
||||||
WLog_INFO(TAG, "Client from %s is resized (%" PRIu32 "x%" PRIu32 "@%" PRIu32 ")",
|
|
||||||
peer->hostname, settings->DesktopWidth, settings->DesktopHeight,
|
|
||||||
freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth));
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user