Skip to content

Commit 0917d94

Browse files
committed
Merge branch 'development' of https://git01.codeplex.com/casablanca into removedev11
2 parents af151c1 + 22ae7d5 commit 0917d94

File tree

7 files changed

+386
-24
lines changed

7 files changed

+386
-24
lines changed

Release/src/websockets/client/ws_client_winrt.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,22 @@ class winrt_callback_client : public websocket_client_callback_impl, public std:
134134
{
135135
m_external_close_handler(status, reason, error_code);
136136
}
137-
m_close_tce.set();
138-
m_server_close_complete.set();
137+
138+
// Locally copy the task completion event since there is a PPL bug
139+
// that the set method accesses internal state in the event and the websocket
140+
// client could be destroyed.
141+
auto local_close_tce = m_close_tce;
142+
local_close_tce.set();
139143
});
140144
}
141145

142146
~winrt_callback_client()
143147
{
144-
// task_completion_event::set() returns false if it has already been set.
145-
// In that case, wait on the m_server_close_complete event for the tce::set() to complete.
146-
// The websocket client on close handler (upon receiving close frame from server) will
147-
// set this event.
148-
// If we have not received a close frame from the server, this set will be a no-op as the
149-
// websocket_client is anyways destructing.
150-
if (!m_close_tce.set())
151-
{
152-
m_server_close_complete.wait();
153-
}
148+
// Locally copy the task completion event since there is a PPL bug
149+
// that the set method accesses internal state in the event and the websocket
150+
// client could be destroyed.
151+
auto local_close_tce = m_close_tce;
152+
local_close_tce.set();
154153
}
155154

156155
pplx::task<void> connect()
@@ -161,6 +160,8 @@ class winrt_callback_client : public websocket_client_callback_impl, public std:
161160
return pplx::task_from_exception<void>(websocket_exception("Only a default proxy server is supported."));
162161
}
163162

163+
164+
164165
const auto &proxy_cred = proxy.credentials();
165166
if(proxy_cred.is_set())
166167
{
@@ -409,12 +410,6 @@ class winrt_callback_client : public websocket_client_callback_impl, public std:
409410
ReceiveContext ^ m_context;
410411

411412
pplx::task_completion_event<void> m_close_tce;
412-
// There is a bug in ppl task_completion_event. The task_completion_event::set() accesses some
413-
// internal data after signaling the event. The waiting thread might go ahead and start destroying the
414-
// websocket_client. Due to this race, set() can cause a crash.
415-
// To workaround this bug, maintain another event: m_server_close_complete. We will signal this when the m_close_tce.set() has
416-
// completed. The websocket_client destructor can wait on this event before proceeding.
417-
Concurrency::event m_server_close_complete;
418413

419414
// External callback for handling received and close event
420415
std::function<void(websocket_incoming_message)> m_external_message_handler;

Release/tests/functional/websockets/client/dirs.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
<ProjectFile Include="vs12.xp\websocketsclient120_test.xp.vcxproj" Condition="'$(Platform)'!='ARM' and '$(RunCodeAnalysis)'!='true'"/>
88
</ItemGroup>
99

10-
<!--
1110
<ItemGroup Condition="'$(OsVersion)|$(DevToolsVersion)'=='6.3|120'">
1211
<ProjectFile Include="VS12.winrt\websocketsclient120_test.winrt.vcxproj" />
1312
</ItemGroup>
1413

14+
<!--
1515
<ItemGroup Condition="'$(DevToolsVersion)'=='140'">
1616
<ProjectFile Include="vs14\websocketsclient140_test.vcxproj" />
1717
<ProjectFile Include="vs14.android\websocketsclient140_test.android.vcxproj" Condition="'$(Platform)'!='x64'" />
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Debug|x64">
9+
<Configuration>Debug</Configuration>
10+
<Platform>x64</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Release|Win32">
13+
<Configuration>Release</Configuration>
14+
<Platform>Win32</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<ProjectGuid>{8E3772EF-7807-40DA-8932-F37DB0C1CB44}</ProjectGuid>
23+
<SccProjectName>SAK</SccProjectName>
24+
<SccAuxPath>SAK</SccAuxPath>
25+
<SccLocalPath>SAK</SccLocalPath>
26+
<SccProvider>SAK</SccProvider>
27+
<DefaultLanguage>en-US</DefaultLanguage>
28+
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
29+
<WindowsAppContainer>true</WindowsAppContainer>
30+
<VCTargetsPath Condition="'$(VCTargetsPath12)' != '' and '$(VSVersion)' == '' and $(VisualStudioVersion) == ''">$(VCTargetsPath12)</VCTargetsPath>
31+
</PropertyGroup>
32+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
33+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
34+
<ConfigurationType>DynamicLibrary</ConfigurationType>
35+
<UseDebugLibraries>true</UseDebugLibraries>
36+
<CharacterSet>Unicode</CharacterSet>
37+
<PlatformToolset>v120</PlatformToolset>
38+
</PropertyGroup>
39+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
40+
<ConfigurationType>DynamicLibrary</ConfigurationType>
41+
<UseDebugLibraries>true</UseDebugLibraries>
42+
<CharacterSet>Unicode</CharacterSet>
43+
<PlatformToolset>v120</PlatformToolset>
44+
</PropertyGroup>
45+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
46+
<ConfigurationType>DynamicLibrary</ConfigurationType>
47+
<UseDebugLibraries>false</UseDebugLibraries>
48+
<WholeProgramOptimization>true</WholeProgramOptimization>
49+
<CharacterSet>Unicode</CharacterSet>
50+
<PlatformToolset>v120</PlatformToolset>
51+
</PropertyGroup>
52+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
53+
<ConfigurationType>DynamicLibrary</ConfigurationType>
54+
<UseDebugLibraries>false</UseDebugLibraries>
55+
<WholeProgramOptimization>true</WholeProgramOptimization>
56+
<CharacterSet>Unicode</CharacterSet>
57+
<PlatformToolset>v120</PlatformToolset>
58+
</PropertyGroup>
59+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
60+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.root))\Build\Release.Tests.Settings" />
61+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
62+
<ClCompile>
63+
<PrecompiledHeader>Use</PrecompiledHeader>
64+
<Optimization>Disabled</Optimization>
65+
<PreprocessorDefinitions>WINAPI_FAMILY=WINAPI_PARTITION_APP;WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
66+
<AdditionalIncludeDirectories>$(CasablancaIncludeDir);$(CommonTestIncludeDir);..\..\utilities;</AdditionalIncludeDirectories>
67+
<AdditionalUsingDirectories>$(WindowsSDKDir)\References\CommonConfiguration\Neutral;$(VSInstallDir)\vc\vcpackages;$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
68+
<CompileAsWinRT>true</CompileAsWinRT>
69+
<MinimalRebuild>false</MinimalRebuild>
70+
<AdditionalOptions>-Zm200 %(AdditionalOptions)</AdditionalOptions>
71+
</ClCompile>
72+
<Link>
73+
<SubSystem>Windows</SubSystem>
74+
<GenerateDebugInformation>true</GenerateDebugInformation>
75+
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
76+
</Link>
77+
</ItemDefinitionGroup>
78+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
79+
<ClCompile>
80+
<PrecompiledHeader>Use</PrecompiledHeader>
81+
<Optimization>Disabled</Optimization>
82+
<PreprocessorDefinitions>WINAPI_FAMILY=WINAPI_PARTITION_APP;WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
83+
<AdditionalIncludeDirectories>$(CasablancaIncludeDir);$(CommonTestIncludeDir);..\..\utilities</AdditionalIncludeDirectories>
84+
<AdditionalUsingDirectories>$(WindowsSDKDir)\References\CommonConfiguration\Neutral;$(VSInstallDir)\vc\vcpackages;$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
85+
<CompileAsWinRT>true</CompileAsWinRT>
86+
<MinimalRebuild>false</MinimalRebuild>
87+
<AdditionalOptions>-Zm200 %(AdditionalOptions)</AdditionalOptions>
88+
</ClCompile>
89+
<Link>
90+
<SubSystem>Windows</SubSystem>
91+
<GenerateDebugInformation>true</GenerateDebugInformation>
92+
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
93+
</Link>
94+
</ItemDefinitionGroup>
95+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
96+
<ClCompile>
97+
<PrecompiledHeader>Use</PrecompiledHeader>
98+
<Optimization>MaxSpeed</Optimization>
99+
<FunctionLevelLinking>true</FunctionLevelLinking>
100+
<IntrinsicFunctions>true</IntrinsicFunctions>
101+
<PreprocessorDefinitions>WINAPI_FAMILY=WINAPI_PARTITION_APP;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
102+
<AdditionalIncludeDirectories>$(CasablancaIncludeDir);$(CommonTestIncludeDir);..\..\utilities</AdditionalIncludeDirectories>
103+
<AdditionalUsingDirectories>$(WindowsSDKDir)\References\CommonConfiguration\Neutral;$(VSInstallDir)\vc\vcpackages;$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
104+
<CompileAsWinRT>true</CompileAsWinRT>
105+
<MinimalRebuild>false</MinimalRebuild>
106+
<AdditionalOptions>-Zm200 %(AdditionalOptions)</AdditionalOptions>
107+
</ClCompile>
108+
<Link>
109+
<SubSystem>Windows</SubSystem>
110+
<GenerateDebugInformation>true</GenerateDebugInformation>
111+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
112+
<OptimizeReferences>true</OptimizeReferences>
113+
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
114+
</Link>
115+
</ItemDefinitionGroup>
116+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
117+
<ClCompile>
118+
<PrecompiledHeader>Use</PrecompiledHeader>
119+
<Optimization>MaxSpeed</Optimization>
120+
<FunctionLevelLinking>true</FunctionLevelLinking>
121+
<IntrinsicFunctions>true</IntrinsicFunctions>
122+
<PreprocessorDefinitions>WINAPI_FAMILY=WINAPI_PARTITION_APP;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
123+
<AdditionalIncludeDirectories>$(CasablancaIncludeDir);$(CommonTestIncludeDir);..\..\utilities</AdditionalIncludeDirectories>
124+
<AdditionalUsingDirectories>$(WindowsSDKDir)\References\CommonConfiguration\Neutral;$(VSInstallDir)\vc\vcpackages;$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
125+
<CompileAsWinRT>true</CompileAsWinRT>
126+
<MinimalRebuild>false</MinimalRebuild>
127+
<AdditionalOptions>-Zm200 %(AdditionalOptions)</AdditionalOptions>
128+
</ClCompile>
129+
<Link>
130+
<SubSystem>Windows</SubSystem>
131+
<GenerateDebugInformation>true</GenerateDebugInformation>
132+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
133+
<OptimizeReferences>true</OptimizeReferences>
134+
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
135+
</Link>
136+
</ItemDefinitionGroup>
137+
<ItemGroup>
138+
<ProjectReference Include="$(TestRoot)\Common\utilities\vs12.winrt\CommonUtilities120.winrt.vcxproj">
139+
<Project>{ea2d69a1-55c8-4c15-805e-de7e85872484}</Project>
140+
</ProjectReference>
141+
<ProjectReference Include="$(TestRoot)\Common\UnitTestpp\vs12.winrt\UnitTestpp120.winrt.vcxproj">
142+
<Project>{B341AA9C-F38B-4D59-B6B7-8F22491090B7}</Project>
143+
</ProjectReference>
144+
<ProjectReference Include="$(CasablancaSrcDir)\build\vs12.winrt\casablanca120.winrt.vcxproj">
145+
<Project>{198ED804-2655-4D92-8104-C220E3EA9452}</Project>
146+
</ProjectReference>
147+
<ProjectReference Include="..\..\utilities\vs12.winrt\websockets_test_utilities120.winrt.vcxproj">
148+
<Project>{D422311C-1C3A-4083-A564-6474EA60FFC7}</Project>
149+
</ProjectReference>
150+
</ItemGroup>
151+
<ItemGroup>
152+
<ClInclude Include="..\stdafx.h" />
153+
<ClInclude Include="..\websocket_client_tests.h" />
154+
</ItemGroup>
155+
<ItemGroup>
156+
<ClCompile Include="..\authentication_tests.cpp" />
157+
<ClCompile Include="..\client_construction.cpp" />
158+
<ClCompile Include="..\close_tests.cpp" />
159+
<ClCompile Include="..\error_tests.cpp" />
160+
<ClCompile Include="..\receive_msg_tests.cpp" />
161+
<ClCompile Include="..\send_msg_tests.cpp" />
162+
<ClCompile Include="..\proxy_tests.cpp" />
163+
<ClCompile Include="..\stdafx.cpp">
164+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
165+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
166+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
167+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
168+
</ClCompile>
169+
</ItemGroup>
170+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
171+
<ImportGroup Label="ExtensionTargets">
172+
</ImportGroup>
173+
174+
<Target Name="StripAppContainer" AfterTargets="Build">
175+
<CallTarget Targets="StripAppContainerOnProjectDll" />
176+
<Copy SourceFiles="$(OutDir)\$(TargetName).dll" DestinationFolder="$(OutDir)\.." />
177+
<Copy SourceFiles="$(OutDir)\$(TargetName).pdb" DestinationFolder="$(OutDir)\.." />
178+
</Target>
179+
</Project>

Release/tests/functional/websockets/utilities/dirs.proj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
<ProjectFile Include="VS12\websockets_test_utilities120.vcxproj" />
77
<ProjectFile Include="VS12.xp\websockets_test_utilities120.xp.vcxproj" Condition="'$(Platform)'!='ARM' and '$(RunCodeAnalysis)'!='true'"/>
88
</ItemGroup>
9-
<!--
9+
1010
<ItemGroup Condition="'$(OsVersion)|$(DevToolsVersion)'=='6.3|120'">
1111
<ProjectFile Include="VS12.winrt\websockets_test_utilities120.winrt.vcxproj" />
1212
</ItemGroup>
1313

14+
<!--
1415
<ItemGroup Condition="'$(DevToolsVersion)'=='140'">
1516
<ProjectFile Include="VS14\websockets_test_utilities140.vcxproj" />
1617
<ProjectFile Include="vs14.android\websockets_test_utilities140.android.vcxproj" Condition="'$(Platform)'!='x64'" />

Release/tests/functional/websockets/utilities/stdafx.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,22 @@
2424

2525
#pragma once
2626

27-
#if defined(_WIN32) && _MSC_VER < 1800
28-
// pplxtasks.h includes Windows.h on VS2012 only WinRT, which is terrible.
29-
// Need to include before to avoid winsock issues with websocketpp.
27+
#if defined(_WIN32)
28+
// Include first to avoid any issues with Windows.h.
3029
#define NOMINMAX
3130
#include <winsock2.h>
3231
#endif
3332

33+
#if defined(_WIN32)
34+
// Trick Boost.Asio into thinking CE, otherwise _beginthreadex will be used which is banned
35+
// for the Windows Runtime pre VS2015. Then CreateThread will be used instead.
36+
#if _MSC_VER < 1900
37+
#if defined(__cplusplus_winrt)
38+
#define UNDER_CE 1
39+
#endif
40+
#endif
41+
#endif
42+
3443
#include "cpprest/uri.h"
3544
#include "cpprest/asyncrt_utils.h"
3645
#include "cpprest/streams.h"

Release/tests/functional/websockets/utilities/test_websocket_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#ifdef _WIN32
3333
#pragma warning( disable : 4503 )
3434
#pragma warning( push )
35-
#pragma warning( disable : 4100 4127 4996 4512 4701 4267 )
35+
#pragma warning( disable : 4100 4127 4996 4512 4701 4267 4067 )
3636
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
3737
#define _WEBSOCKETPP_CPP11_STL_
3838
#define _WEBSOCKETPP_INITIALIZER_LISTS_

0 commit comments

Comments
 (0)