From 5d0a53a3b3d2a256624aeb8a3da67d07e8e56a3c Mon Sep 17 00:00:00 2001 From: Corey C Date: Mon, 8 Oct 2012 15:46:01 -0400 Subject: [PATCH] wfreerdp-server: improved peer tracking, added ability to disconnect individual peers --- server/Windows/wf_info.c | 7 ++++++- server/Windows/wf_info.h | 2 +- server/Windows/wf_peer.c | 3 +++ server/Windows/wf_update.c | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/server/Windows/wf_info.c b/server/Windows/wf_info.c index 7180797b2..da638c5cc 100644 --- a/server/Windows/wf_info.c +++ b/server/Windows/wf_info.c @@ -206,7 +206,12 @@ void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) int i; int peerId; //todo: reject peer if we have WF_INFO_MAXPEERS connected - + if (wfi->peerCount == WF_INFO_MAXPEERS) + { + context->socketClose = TRUE; + wf_info_unlock(wfi); + return; + } context->info = wfi; context->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL); diff --git a/server/Windows/wf_info.h b/server/Windows/wf_info.h index ff26275e9..3c7ee3c3b 100644 --- a/server/Windows/wf_info.h +++ b/server/Windows/wf_info.h @@ -23,7 +23,7 @@ #include "wf_interface.h" #define WF_INFO_DEFAULT_FPS 24 -#define WF_INFO_MAXPEERS 32 +#define WF_INFO_MAXPEERS 2 int wf_info_lock(wfInfo* wfi); int wf_info_try_lock(wfInfo* wfi, DWORD dwMilliseconds); diff --git a/server/Windows/wf_peer.c b/server/Windows/wf_peer.c index 4f9c8c06b..c519c0222 100644 --- a/server/Windows/wf_peer.c +++ b/server/Windows/wf_peer.c @@ -220,6 +220,9 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) client->Initialize(client); context = (wfPeerContext*) client->context; + if (context->socketClose) + return 0; + wfi = context->info; if (wfi->input_disabled == TRUE) diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index 9ddd47a1d..1fef2d13b 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -63,10 +63,10 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) wf_update_encode(wfi); //printf("Start of parallel sending\n"); - + index = 0; for (peerindex = 0; peerindex < wfi->peerCount; peerindex++) { - for (index = 0; index < WF_INFO_MAXPEERS; index++) + for (; index < WF_INFO_MAXPEERS; index++) { if (wfi->peers[index] && wfi->peers[index]->activated) {