Граф коммитов

674 Коммитов

Автор SHA1 Сообщение Дата
Jason Sandlin c80549b9a7
Update to PR trigger (#704) 2022-06-28 20:36:14 -07:00
Maxim Ivanov 3a875da097
Look for HC_NOWEBSOCKETS property in all sources (#703)
Properties may be set not only in the command line, but also in other sources, like gradle.properties file in user dir or environment variables.

Co-authored-by: Jason Sandlin <jasonsa@microsoft.com>
2022-06-28 13:43:33 -07:00
mr-efficient 73a31ba762
Fixed hang in XblCleanupAsync (#700)
* Fixed hang in XblCleanupAsync

CurlProvider::PerformAsync can be called simultaneously from multiple threads, which leaves CurlProvider::m_curlMultis in a bad state.  That results in m_curlMultis.size() being incorrect, which results in m_cleanupTasksRemaining being incorrect, which results in XAsyncComplete never being called in CurlProvider cleanup.

I protect against this by protecting access to m_curlMultis with m_mutex.

* Revert "Fixed hang in XblCleanupAsync"

This reverts commit 1adc155e4d.

* Fixed hang in XblCleanupAsync

Fixed hang in XblCleanupAsync
1adc155
CurlProvider::PerformAsync can be called simultaneously from multiple threads, which leaves CurlProvider::m_curlMultis in a bad state. That results in m_curlMultis.size() being incorrect, which results in m_cleanupTasksRemaining being incorrect, which results in XAsyncComplete never being called in CurlProvider cleanup.

I protect against this by protecting access to m_curlMultis with m_mutex.

* Update CurlProvider.cpp

Updated previous change based on review comments.  Changed Tabs -> Spaces and made a local copy of  CurlProvider::m_curlMultis in CurlProvider::CleanupAsyncProvider

Co-authored-by: Jason Sandlin <jasonsa@microsoft.com>
2022-06-28 12:32:09 -07:00
Sahil Ashar 8656e9ae17
Updating namespacing (#702) 2022-06-24 15:27:14 -05:00
Maxim Ivanov 427f4d2e89
Use more CMake way to reference project dir (#701)
Makes it easier to build on non-Windows platforms
2022-06-20 13:20:12 -07:00
John L 68228ea5b4
Addressing several WebSocket bugs (#699)
* WinHttp request error not correctly handled when a disconnect isn't acknowledged by the server
* Fixes race condition between WebSocket disconnect event handler invocation and unregistration when closing a WebSocket handle
* HCWebSocketConnectAsync will now pass back the client's WebSocket handle in the XAsync result rather than an internal handle
2022-06-09 14:41:54 -07:00
Maxim Ivanov da1dc4b237
Fix GCC missing-field-initializers warning (#694)
Zero initialize Address variables

Co-authored-by: Jason Sandlin <jasonsa@microsoft.com>
2022-06-06 15:34:02 -07:00
Maxim Ivanov e809f45a54
Check allocated buffer size before copying response (#693)
Small safety check to ensure destination buffer has enough space.
2022-06-06 14:20:47 -07:00
John L 2eabe3bb34
Doc update for HCWebSocketConnectAsync (#695) 2022-05-31 16:16:20 -07:00
Luca Beltrami f59e06c477
Minor fixes for building without websockets (#691)
* Minor fixes for building without websockets

* Fix importing of headers
2022-05-24 15:22:27 -07:00
Maxim Ivanov 77d749af8b
Fix deadlock in threadpool_stl (#690)
Short lived libHC instances were deadlocking because of insufficient checks upon entering condvar wait.

If large number of threads created, then threads could start execution with `m_terminate` being set to true already.
Waiting for on `m_wake` condvar without prior check of `m_terminate` causes deadlock
2022-05-24 14:00:18 -07:00
microsoft-github-policy-service[bot] cd7bbb6f42
Microsoft mandatory file (#688)
Co-authored-by: microsoft-github-policy-service[bot] <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com>
2022-05-16 15:11:23 -07:00
Sasha Weiss 91cda2eff5
Unregister callback during LHC cleanup (#686) 2022-04-22 14:43:49 -07:00
Jason Sandlin 1a4a418df0
Fix various missing #include and required namespace qualifiers (#685) 2022-04-21 18:45:35 -07:00
Jason Sandlin c6072a08ee
Mock handles need to add ref internally to avoid cleanup race conditions (#684) 2022-04-21 15:20:51 -07:00
Sasha Weiss bea2069547
Add network-detail logging around network failures (#682)
* Log a bunch of network diagnostic info on Android for network failure cases

* Add not suspended check if available

* Add a null check

* Move network details getting to a NetworkObserver class

* Some tweaks

* Some cosmetic tweaks

* Use StringBuilder.length instead of specific boolean
2022-04-08 14:35:43 -07:00
John L 10d727a577
Update WebSocket Sample to demonstrate proper WebSocket cleanup without using globals (#681) 2022-04-08 11:54:02 -07:00
tculotta e3984a63bc
Reintroducing websocket close behavior for Request_Error scenario (#680)
* Reintroducing websocket close behavior for Request_Error scenario

* Reintroducing websocket close behavior for Request_Error scenario

* Reintroducing websocket close behavior for Request_Error scenario
2022-03-31 14:11:10 -07:00
Brian Pepin 9e788ef6b1
Sync bug fixes from Microsoft OS repo (#673)
This syncs several fixes from the Windows OS repo.

Some edge case race conditions in queue signaling.
Fixing a use after free bug.
Hardening the task queue handles so closing a handle twice will fail instead of corrupting the queue.
A suspend / resume API that is only enabled and used on Xbox.
2022-03-09 14:57:34 -08:00
tculotta 677e4ec1ad
Fix parameter use for HC_NOWEBSOCKETS case (#671) 2022-03-04 15:28:54 -08:00
John L 4890e52198
Fix some faulty logic in WinHttp WebSocket fragment handling (#670)
When WebSocket message fragments are received, they are collected in a buffer within LHC.  They are only forwarded to the client when that buffer is full or when the final fragment has been received.  When WinHttp has given us fragments, LHC incorrectly invokes the HCWebSocketBinaryMessageFragmentFunction even if we were able to accumulate the fragments in our buffer before passing them along to the client.

This also fixes a bug where the WebSocket's default m_maxReceiveBufferSize isn't correctly initialized to 20kb as documented in the header.
2022-03-03 17:58:09 -08:00
John L 8b42f4bf4e
Fix race condition in CurlProvider::CleanupAsync (#669)
During cleaning, CurlProvider loops over its CurlMultis and kicks off CurlMulti::CleanupAsync for each of them.  When the last of those sub-tasks completes, the Provider will be freed and then the CurlProvider::CleanupAsync task will be completed.  There is a race condition such that the final CurlMulti cleanup may complete _before_ CurlProvider::CleanupAsyncProvider's XAsyncOp::Begin.  This race exposes a couple of nasty bugs: 
* Due to a tricky detail of how c++ move semantics work, ownership of the CurlMulti isn't properly transferred to CurlMulti::CleanupAsync, leading to the CurlMulti object (and its curl_multi handle) being cleaned up twice: once as part of CurlMulti::CleanupAsync (expected), and then a second time when the final MultiCleanupComplete fires while the CurlMulti object is still in the CurlProvider's m_curlMultis map (unexpected).  The fix is to properly transfer ownership of the CurlMulti by passing it by value rather than r-value reference.
* Because CurlProvider is looping over its member m_curlMultis, we need to ensure that the provider isn't destroyed before that loop completes.  The fix for this is to gate cleanup of the CurlProvider on not only the CurlMulti cleanup operations completing, but also on CurlProvider::CleanupAsyncProvider having exited that cleanup loop.

I also fixed a couple of other spots where ownership of unique_ptrs wasn't properly transferred, even though they didn't directly lead to bugs.
2022-03-03 12:08:42 -08:00
tculotta 34933b4dd2
Adding HC_NOWEBSOCKETS around more socket operations (#667) 2022-02-18 09:56:25 -08:00
Sahil Ashar 5ad328eaa7
adding NOTICE.txt to be in compliance (#666) 2022-02-10 15:19:22 -06:00
John L 53396fd6a9
Ensure WebSocket handle passed to clients is the same handle they created and not an internal handle (#665) 2022-02-08 15:47:03 -08:00
John L 312552b182
Cleanup redesign part 2 (#662)
* WebSocket class reworked allowing multiple "observers" to independently register for events.  This allows both clients and HC_PERFORM_ENV to keep track of the connection state
* HCWebSocketConnectAsync Shim added to HC_PERFORM_ENV, tracking WebSocket connect attempts
  * During cleanup, WebSockets in the process of connecting will be allowed to finish connecting (currently no support for cancellation)
  * Connected WebSockets will be properly closed
* Validated E2E using local WebSocket echo server + API runner scripts (added in separate PR)
* Regression tested via API runner
2022-02-04 19:26:54 -08:00
Jason Sandlin d702af7dcb
Minor readme updates (#664) 2022-02-04 12:33:19 -08:00
John L e28ba610ce
Fix winHttp WebSocket regression cause by message fragment changes (#663) 2022-02-03 21:37:06 -08:00
John L 18f7aad846
Cleanup redesign part 1 (#658)
* Adds HCHttpPerformAsync shim to HC_PERFORM_ENV to track ongoing HTTP requests
* Adds partial support for HTTP cancelation
* Adds logic to HCCleanupAsync to cancel and await ongoing Http requests during cleanup
* Added relevant UnitTests

Remaining work:
* Tracking active WebSocket connections & terminating during HCCleanup
2022-02-01 13:20:53 -08:00
Jason Sandlin b2dfa4d17e
Issue 655: Be able to query if library has been initialized #655 (#660)
* Issue 655: Be able to query if library has been initialized #655

* Adding export
2022-02-01 02:15:33 -08:00
Chuy Galván 25864d6503
Fix bug on UWP request stream (#659) 2022-01-28 10:35:40 -08:00
Sasha Weiss be2fde89b0
Use a safe binary staging dir for iOS OpenSSL build (#657)
* Use a staging directory rather than CONFIGURATION_TEMP_DIR

* Make sure to create staging directory
2022-01-24 13:47:38 -08:00
John L b1a2a5bfac
WinHttp Cleanup race condition (#656)
Fixes a race condition be HCCleanupAsync and a WinHttpClose call by adding a final "Closed" state to connection.
2022-01-24 11:27:50 -08:00
John L 1d7b29a29a
Proper handling of large incoming messages for WinHttp WebSockets (#653)
* Fixes bug where messages that exceeded the hardcoded receive buffer size were never delivered to clients
* Added public API to set a message fragment handler. When messages are broken down at the platform level and exceed the configured receive buffer size, they will be passed to clients in fragments.
* Adds public API to configure maximum WebSocket receive buffer size.  When receive buffer is full, partial messages are passed to client. 
* Adds public API to configure the maximum receive buffer size (WinHttp only).  If large messages are expected, this can be changed so that full messages are delivered all at once rather than in chunks.  Setting this buffer size to large values does mean that the entire message will be stored in LHC memory until it is passed along to clients so memory performance may be affected.
2022-01-18 12:04:21 -08:00
Sasha Weiss 2a5f223cb8
Update the Android compileSdkVersion (#650) 2021-12-28 11:50:08 -08:00
Sahil Ashar fe4e4eaa3b
Fix for Android JNI link bug (#648) 2021-12-21 15:22:04 -06:00
John L 4ede2c3dcb
Fix bug in WinHttp WebSocket (#647) 2021-12-21 10:05:57 -08:00
John L c39d82badd
Add missing deps to props file for GDK (#646) 2021-12-09 12:22:45 -08:00
John L 5d9a114023
Fixing some cleanup & memory issues in WinHttp (#645) 2021-12-06 18:57:05 -08:00
John L 0b321c270a
Adding support for VS toolset v143 (#644)
* v143 Support for Win32 & GDK
* Change to generating project files for each supported toolset from a single project template.
2021-12-03 15:04:19 -08:00
John L 8e28f5baf3
Make XCurl HTTP Provider cleanup fully asynchronous (#643)
* Fixes deadlock that occurs if callers use one single threaded manually dispatched queue for both HTTP calls and HCCleanupAsync
* Layered such that other HTTP providers can support async cleanup in the future
2021-11-30 13:35:33 -08:00
John L cd6651fdf5
Fix GDK build break when HC_NOWEBSOCKETS is specified (#642) 2021-11-18 16:04:42 -08:00
John L 6d65866efd
Fix link error on Win32 when building with HC_NOWEBSOCKETS set (#641) 2021-11-17 14:06:21 -08:00
tculotta 263f247beb
vs2022 projects should locate the v142 LHC projects (#640)
* vs2022 projects should locate the v142 LHC projects

* constraining 143/142 association to GDK for flexibility on other platforms
2021-11-17 11:09:56 -08:00
John L 3a7a491505
Set CURLOPT_NOBODY for XCurl HEAD requests (#639) 2021-11-12 14:38:03 -08:00
John L 19a2aaf96b
WinHttp should check network initialization status on GDK before begining WebSocket/Http calls (#638) 2021-11-11 15:45:06 -08:00
MSFT-Heba a52aec7beb
Fixing a typo in openssl.bash (#637)
Co-authored-by: heba <xlivexdevx@V-TKLIMEK-CON.redmond.corp.microsoft.com>
2021-11-11 13:31:52 -08:00
John L 710df0af8c
Another allocator bug (#636) 2021-11-10 13:32:49 -08:00
John L 691374b339
Fixing a couple of allocator bugs (#635) 2021-11-10 11:07:03 -08:00
John L 04f2adda51
Populate HCWebSocketHandle in WebSocket Send completion callback (#634) 2021-11-09 16:26:43 -08:00