From f47b03415ddc8b39bcbb39e596365dbe565a8070 Mon Sep 17 00:00:00 2001 From: dmex Date: Sun, 10 Nov 2013 10:54:41 +0000 Subject: [PATCH] NetworkTools: fixed graph; fixed workqueue issue; --- plugins/NetworkTools/ping.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/plugins/NetworkTools/ping.c b/plugins/NetworkTools/ping.c index ca463a82a..b4fa1614d 100644 --- a/plugins/NetworkTools/ping.c +++ b/plugins/NetworkTools/ping.c @@ -557,18 +557,22 @@ static INT_PTR CALLBACK NetworkPingWndProc( context = (PNETWORK_OUTPUT_CONTEXT)GetProp(hwndDlg, L"Context"); if (uMsg == WM_NCDESTROY) { + PhSaveWindowPlacementToSetting( + SETTING_NAME_PING_WINDOW_POSITION, + SETTING_NAME_PING_WINDOW_SIZE, + hwndDlg + ); + + PhDeleteWorkQueue(&context->PingWorkQueue); + PhDeleteGraphState(&context->PingGraphState); + PhDeleteLayoutManager(&context->LayoutManager); + if (context->PingGraphHandle) { DestroyWindow(context->PingGraphHandle); context->PingGraphHandle = NULL; } - PhSaveWindowPlacementToSetting( - SETTING_NAME_PING_WINDOW_POSITION, - SETTING_NAME_PING_WINDOW_SIZE, - hwndDlg - ); - if (context->IconHandle) { DestroyIcon(context->IconHandle); @@ -581,9 +585,6 @@ static INT_PTR CALLBACK NetworkPingWndProc( context->FontHandle = NULL; } - PhDeleteWorkQueue(&context->PingWorkQueue); - PhDeleteGraphState(&context->PingGraphState); - PhDeleteLayoutManager(&context->LayoutManager); RemoveProp(hwndDlg, L"Context"); context = NULL; } @@ -642,8 +643,9 @@ static INT_PTR CALLBACK NetworkPingWndProc( // Set window icon. if (context->IconHandle) SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)context->IconHandle); - - PhInitializeWorkQueue(&context->PingWorkQueue, 0, 3, 1000); + + // Initialize the WorkQueue with a maximum of 20 threads (fix pinging slow-links with a high interval update). + PhInitializeWorkQueue(&context->PingWorkQueue, 0, 20, 5000); PhInitializeGraphState(&context->PingGraphState); PhInitializeLayoutManager(&context->LayoutManager, hwndDlg); PhInitializeCircularBuffer_ULONG(&context->PingHistory, PhGetIntegerSetting(L"SampleCount")); @@ -667,7 +669,10 @@ static INT_PTR CALLBACK NetworkPingWndProc( { PhLoadWindowPlacementFromSetting(SETTING_NAME_PING_WINDOW_POSITION, SETTING_NAME_PING_WINDOW_SIZE, hwndDlg); } - + + // Initialize window layout. + PhLayoutManagerLayout(&context->LayoutManager); + // Convert IP Address to string format. if (context->IpAddress.Type == PH_IPV4_NETWORK_TYPE) {