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

80 Коммитов

Автор SHA1 Сообщение Дата
Brian Pepin 1b65701858
Fix random FAIL_FAST and async context corruption in XAsyncGetResults (#514)
This PR fixes a random FAIL_FAST crash when completing an async call and fixes an issue where if you call XAsyncGetResults before a call is complete the async block's internal context gets corrupted.
2020-05-03 01:25:47 -07:00
Brian Pepin 0df9a4434b
Fix race condition in termination code (#512)
* Fix race in termination

* Task Queue should alert monitors during termination
2020-04-13 10:46:53 -07:00
Brian Pepin db4fb0c6c9
Fix corner case error handling (#505)
This change fixes a corner case where we could orphan a call if an async call was started after a queue was terminated.
2020-03-27 16:25:07 -07:00
Brian Pepin b43e7596a4
Move task queue over to new LocklessQueue (#496)
This change replaces LocklessList.h with LocklessQueue.h. LocklessQueue performs much better than LocklessList and allows new items to be added to a task queue with zero allocations. Overall performance of task queue inserts and removals is about 6x faster.
2020-02-28 11:54:56 -08:00
John L d0598f54dd
Fix lifetime issues with http_singleton (#490)
* Fixing singleton lifetime issues

* Fixing some broken unit tests

* Addressing feedback

* Address race condition in http_singleton::create

* Fix comment
2020-02-10 20:59:25 -08:00
Luca Beltrami edbbd4fdc9
Fixup the 2019 solution (#483) 2019-11-07 11:36:19 -08:00
Jason Sandlin bdb142114e
Removing assert on null singleton as cases are handled with proper error handling (#477)
* Removing assert on null singleton as cases are handled with proper error handling

* Fixing test
2019-10-22 13:47:09 -07:00
Brian Pepin d20427fa10
Fix a subtle race shutting down a task queue with deferred calls (#464)
If a task queue is executing a deferred callback and is asked to terminate, it's possible the the deferred call runs while the queue task port is destructing. This can cause a crash.  

This also changes cleanup so if you don't have a payload to return your cleanup op is called at the end of work processing.  this can help with shutdown.
2019-09-16 15:00:57 -07:00
Jason Sandlin a10c67e067
Switching to W4 and warnings as errors (#449)
* Switching to W4 and warnings as errors

* Fixing mock
2019-07-23 17:58:56 -07:00
Brian Pepin 278fb75581
Small semantic change to XAsyncCancel (#430)
XAsyncCancel now routes through the provider, which must cal XAsyncComplete(E_ABORT) to cancel a calll. This allows for non-cancelable async calls like XAL shutdown.
2019-06-10 19:59:37 -07:00
Jason Sandlin fedf374800
Fixing cleanup when singleton is dtor'd (#400)
* Fixing cleanup when singleton is dtor'd

* PR feedback

* PR feedback

* Fixing PR
2019-04-25 12:36:51 -07:00
Luca Beltrami c7a8808b88
Refactor websocket hooks to follow the same pattern as http hooks, add context pointer (#399)
* Refactor websocket hooks to follow the same pattern as http hooks, add context pointer

* Fix build error in generic platform

* CR feedback
2019-04-24 11:13:25 -07:00
Brian Pepin 484ac84014 Composite task queues based on process queue can terminate (#384) 2019-03-04 10:25:50 -08:00
Jason Sandlin bf4e654e16
Adding binary websocket support and context pointers on callbacks (#377) 2019-02-19 12:20:39 -08:00
Jason Sandlin f1615bf31b
Adding WinHTTP Websocket support (#361)
* Adding WinHTTP Websocket support

* Splitting out WinHTTP websocket logic

* PR

* Fixing ifdef

* Fixing TODOs
2019-01-18 12:44:33 -08:00
Brian Pepin 0351f6ea76
Fix for nested queue close w/delayed callbacks (#360)
This fixes a bug Luca found where if you have a delayed callback in a task queue and you close a composite queue the delayed callback can fire immediately. This happened because when canceling the callback timer for queue rundown we didn't clear the due time field, so when we started the timer back up we thought the call at the head of the list was due.
Other changes:
* Rundown logic at final release hardened. It was possible to race here and rundown a queue that wasn't destined to die.
* Additional tests.
* Fix tests for added Begin opcode.
2019-01-16 10:02:13 -08:00
Luca Beltrami 7e56b9e77f
More updates to the latest naming conventions (#359)
* Update naming conventions

* build fixes
2019-01-11 10:47:27 -08:00
Jason Sandlin 17d935541e
Switching to C++11 enum class types based on latest API style convention (#357)
* Switching to C++11 enum class types

* Fixing build break

* Fixing build break
2019-01-10 17:52:30 -08:00
Jason Sandlin 51e49a7bae
Updating to latest API naming convention (#356) 2019-01-10 15:07:57 -08:00
Brian Pepin b866887ff4 ERROR_CANCELLED->E_ABORT (#354) 2019-01-09 10:37:03 -08:00
Brian Pepin 8ec68c9d0e
Changes made from windows code review (#348)
The windows integration of this code found several improvements and a couple of bugs. This PR synchronizes with what's now in the Windows tree.
2019-01-07 11:03:51 -08:00
Brian Pepin 56982f21bb
Fix termination and composite queues for XAL (#347)
Queue termination was intended only to be performed by the creator of the main queue, with composite queues simply closing their handles.  That's not how XAL is using it though, so this change allows for termination of composite queues. Behavior changes are as follows:

* Terminating a composite queue terminates that queue, running through operations for that composite queue and clearing them out of the port.  The port will remain active for other queues to use.

* Closing a queue handle inside a termination callback would deadlock for thread pool based queues, since the final close handle will destroy the thread pool and wait for all calls to complete.  Now this works for both Win32 and STL based thread pools.

* Queue monitor callbacks were only active for the primary queue -- they were a NOP for composite queues.  This is now fixed.
2018-12-31 09:31:46 -08:00
Brian Pepin 3f5e78c76c
Update Async and AsyncQueue to new design guidelines (#344)
This change incorporates api breaking changes from Windows done as a result of design feedback. 
Specifically:

Design Changes

* AsyncQueue.h -> XTaskQueue.h
* New task queue termination APIs
* New task queue wait apis
* Lots of small changes based on design feedback
* Better perf - task queue is now lock free when submitting new items

File Renames

* Async.h -> XAsync.h, AsyncProvider.h -> XAsyncProvider.h.

Guideline Updates

* No more foo_handle_t. Replaced by XFooHandle.
* All APIs prefixed with X and a common category, like XAsync or XTaskQueue
2018-12-12 16:11:17 -08:00
Luca Beltrami 34d6dc71a0
Update the platform hook model andadd a "generic" platform (#340)
* first pass at supporting a generic platform and proper platform hooks

* fix xmlhttp platform

* iOS fixes

* revert unrelated change, move trace platform hooks setter in trace.cpp

* remove unnecessary `extern "c"` blocks, cleanup api types, move HCTraceImplScopeHelper to be header only

* fix build break

* CR feedback

* CR feedback

* CR feedback
2018-12-06 10:24:06 -08:00
Brian Pepin 5caa665540
Fix out of order locking bug in async lib (#312)
Fixes a A,B & B,A locking problem that can cause deadlocks.
2018-10-22 14:01:40 -07:00
Brian Pepin ded34400a2
Add stress test, work around live lock issue in async queue. (#304) 2018-10-08 12:03:26 -07:00
Brian Pepin 9db17bfdd3
Abstract async queue (#291)
This PR primarily moves async queue away from std::mutex and instead uses spin locks, at least on multi-processor systems. The reason for this is to prevent context switches while adding things to the queue, which can slow down perf critical threads.

The async queue implementation is also now built on an interface abstraction, which will make interoperability between Windows code and libHttpClient easier.

Finally, there are some API additions / changes:

DuplicateAsyncQueueHandle now returns a HRESULT and has the new handle as an out-param. The semantics haven't changed, but this signature mates better with other Win32 "duplicate" APIs and allows us a little more freedom in the implementation later on.

There are two new dispatch modes: SerializedThreadPool uses the thread pool, but ensures that queue calls are run in series through it instead of in parallel. This is useful if you want to use a thread pool as your completion dispatch mode, but still want things to always come in order. Immediate dispatch mode doesn't queue at all and just invokes the callback immediately on the submitting thread. This is a useful utility mechanism for chaining async calls together.

RemoveAsyncQueueCallbacks can now accept a nullptr as the callback function pointer to act as a wild card. This must be used with caution, since you can remove any callback (not just yours), but it's kind of necessary to support lambdas.
2018-09-27 13:59:03 -07:00
Brian Pepin ba0bf7c690
Merge changes from Windows tree into libHttpClient (#276)
* Merge with windows tree

* Use C++11 for deleting assignment/copy ctor

* merge changes from Windows

* Add unit tests, updates from Windows

* rebuild projects

* Move to standard snprintf

* Update non-windows error code

* Signal completion after completion callback

* Waits for non-win32

* Minor hardening

* fix merge conflict

* Missing filter

* PR feedback

* typo

* Update from GameCore spec review

* Merge from Windows tree

* PR feedback

* PR feedback

* Fix race condition in worker callback

* PR feedback
2018-09-12 11:35:40 -07:00
Jason Sandlin 1d874050f2
Removing unneeded testweb app (#270) 2018-09-06 13:50:17 -07:00
John L eb4b2c9011
Cleanup build (#241)
Significant build refactoring and improvement including
-Single sln file for vs2015 and 2017
-Building dependencies from source and getting rid of nugets
-Improve props files
-Added internal props file with common build properties shared among all projects
2018-08-09 11:22:13 -07:00
Jason Sandlin 56fa178fac
Moving AsyncBlock param to last param to match coding style (#224)
* Moving AsyncBlock param to last param to match coding style

* PR feedback
2018-08-02 15:54:08 -07:00
Brian Pepin d0737a7fcb
Spec review feedback (#193) 2018-06-25 12:58:53 -07:00
Jason Sandlin d45bef31e7
Updating name of duplicate async queue handle (#185)
* Updating name of duplicate async queue handle

* PR feedback
2018-06-06 15:50:00 -07:00
Jason Sandlin d062304d76
Fixing SAL on AsyncBlock (#180) 2018-05-31 14:05:11 -07:00
Jason Sandlin 0d04364602
Fixing unit test (#170) 2018-05-25 11:29:11 -07:00
Jason Sandlin 4824d68dcb
Removing global from APIs (#168) 2018-05-24 15:02:18 -07:00
Jason Sandlin 5dfecb286f
Adding Async at end of async API functions (#167) 2018-05-22 12:50:38 -07:00
Brian Pepin edef23ddc7 Signal wait after completion callback and enable non-win32 waits (#164)
* Merge with windows tree

* Use C++11 for deleting assignment/copy ctor

* merge changes from Windows

* Add unit tests, updates from Windows

* rebuild projects

* Move to standard snprintf

* Update non-windows error code

* Signal completion after completion callback

* Waits for non-win32

* Minor hardening

* fix merge conflict

* Missing filter

* PR feedback

* typo
2018-05-17 17:59:28 -07:00
Brian Pepin a0d8faf4f7 Port async unit tests and merge back with Windows tree (#156)
* Merge with windows tree

* Use C++11 for deleting assignment/copy ctor

* merge changes from Windows

* Add unit tests, updates from Windows

* rebuild projects

* Move to standard snprintf

* Update non-windows error code
2018-05-11 15:54:31 -07:00
Jason Sandlin bb181f3e5c
Moving AsyncBlock first in param order (#153)
* Moving AsyncBlock first in param order

* Fixing mobile projects
2018-05-09 11:13:04 -07:00
Jason Sandlin 965b531986
Adding binary response APIs (#141) 2018-05-02 10:22:10 -07:00
Jason Sandlin a265e1aaf3
Fixing unit tests (#129) 2018-04-12 18:46:02 -07:00
Jason Sandlin 495818dbb2
Fixing unit tests (#126) 2018-04-09 18:00:29 -07:00
Jason Sandlin d5158b2ca3
Fixing unit tests (#122) 2018-04-05 12:06:33 -07:00
Jason Sandlin 7c35657d56
Fixing STDAPIVCALLTYPE (#119) 2018-03-30 11:49:52 -07:00
Jason Sandlin 24671d9be0
Fixing unit test (#117) 2018-03-29 12:32:54 -07:00
Jason Sandlin 949b435c3e
Updating error codes to use hresult_t (#114) 2018-03-27 13:02:49 -07:00
Jason Sandlin bd89dab3aa
Removing old task system (#113) 2018-03-23 11:54:29 -07:00
Jason Sandlin 3299720fee
Fixing unit tests (#111) 2018-03-21 12:43:14 -07:00
Jason Sandlin 866e863e46
Fixing test build break (#108) 2018-02-20 10:17:18 -08:00