Added FunctTests to check KillSwitch feature:
- killSwitchWorks checks that a token is banned and events are dropped
- killIsTemporary checks that a token is banned for an amount of time and no events are dropped after that
Related work items: #1608758
Both PAL_Win32 and PAL_CPP11 have the exact same `WorkerThread` implementation (copy/pasted). This change extracts out the `WorkerThread` class from the Win32/CPP11 files _verbatim_ and puts them in a separate WorkerThread.hpp|cpp. The only change to the WorkerThread class is the introduction of an `IWorkerThread` interface and `WorkerThreadFactory`. This interface will be useful for when MIP creates its own custom WorkerThread that dispatches tasks to an external DLL.
I considered creating a separate PAL_CoreLib or PAL_MIP implementation, but it would everything except `WorkerThread` with the existing Win32/CPP11 PALs, so that seemed like the wrong abstraction.
I would like to merge this change to the main onesdk branch so that when I create the custom CoreLib/MIP implementation in a separate branch (for now), those changes will be very localized.
/build/agent-cpp/_work/1/s/lib/offline/OfflineStorage_SQLite.cpp:67:25: error: conversion from 'Microsoft::Applications::Events::Variant' to 'size_t' (aka 'unsigned long') is ambiguous
Kill-switch feature:
* collector may decide to kill all events associated with a token
* basic functional test(s) for the feature
Offline storage clean-up:
* if device experiences connectivity issues, then its offline storage may grow too big.
* DB may also contain old records from v1 that we are not processing. Delete those.
Related work items: #1403105, #1403106, #1445871, #1608757
HttpClientFactory chooses HttpClient implementation based on build flags. This factory can later be extended additional HttpClient implementations if necessary
- main() must be conditionally declared CDECL on Windows platforms.
- Removed unused variables.
- Fixed a loss of precision and possible underflow issue.
HTTP uploader fixes:
* fix lockup on shutdown: pause , then join on all TPM callbacks in system - waiting for HCM request callbacks to come
* limit the # of HTTP uploads in the pipeline as it may previously caused OOMs, esp. in case of several UploadNow calls
* add more tests for scenarios above, including shutdown with high number of requests, as well as Unit tests around this area
Related work items: #1628137
Resolve WATSON AV at shutdown found during Office fuzzy testing: don't touch the object that might have been already destroyed. Code logic relies on existing idle-wait check in _CancelAllRequests_. Since we can't safely rely on a signal handle member field, waiting inside a _cancel_() method of an object that might be potentially destroyed by another parallel thread (e.g. by WinInet thread pool callback handling thread), signal handling has to be removed. It was largely unnecessary: we already have an "idle waiter" inside the CancelAllRequests(...), that yields to (WinInet or Win10) callback threads until all pending requests have run to completion or cancellation. Worst case shutdown wait time after forcedly resetting/aborting HTTP socket connection is about 100ms or up to the amount of time it takes for the callback thread to get scheduled and run to object deletion. In fact in case if there are two or more pending HTTP requests, the shutdown is now faster after the change since we no longer wait individually on each of these, but rather than wait for all of them to complete. Added Win32 "fuzzy' test that attempts to rapidly send requests in a loop and abort them, printing how many got OKd (O) and how many got a "failure" notification due to cancellation (X). No crashed observed.
Related work items: #1561793
Stats improvement:
* reduce priority from Critical/Realtime to normal
* reduce frequency to 1 event in 30 minutes
* reduce stats event size. Stop collecting histograms we never ever look at (and in fact block in our Kusto storage)
* rework the code to make it simple, avoid "copypasta" that previously plagued MetaStats.cpp
* use wall clock for stats event timestamp
* adjust tests to account for lesser number of stats event per session
* make per-tenant stats a configurable "debug only" feature, as it does not scale well for deployment in Office
* adjust PAL to properly return monotonic clock
Related work items: #1618463
Provide more secure implementation of evt_log -- evt_log_s that 'remembers' the array size.
Plus add a test app for vs2010 to verify the flow.
There is a compile-time compiler define **_CRT_SECURE_LOG_S** that now allows to enforce the usage of **evt_log_s** similar to Secure Template practice done for old C-style APIs, that is automagically figuring out the passed array size.. Conceptually similar to that: https://docs.microsoft.com/en-us/cpp/c-runtime-library/secure-template-overloads
* **evt_log** is still there: as long as users use the TELEMETRY_EVENT macro, it automatically appends the null-entry at the end of array, that one serves as null-terminator similar to C-style strings, so that the knowledge of array size is redundant per-se: we scan until we find null terminator. If users use _CRT_SECURE_LOG_S, then the requirement of null-terminating goes away.. ideally it'd be fine if users just always use TELEMETRY_EVENT macro that automatically adds padding.
* If users prefer **evt_log_s** by defining _CRT_SECURE_LOG_S, then all **evt_log** API calls automatically get routed to **evt_log_s** alongside with auto-calculated array size.. There's no need to know of evt_log_s.
* If users use **evt_log_s** directly, then they'd have to manually pass down the array size ... probably not the most efficient way.. while they can also employ a macro to calc it at compile time.
Related work items: #1592232
Defensive fix for WATSON bug 2685462: if adding to package using splicer fails, then avoid crashing with OOM - report back that no more records can be added to package. Some telemetry loss is expected under this condition.
Related work items: #1588215
Sprinkle "#ifdef _MSC_VER" wherever "#pragma warning" is used to get rid of the "-Wno-unknown-pragmas" flag.
Remove "Wno-reorder" flag as it is not causing issues anymore. Fixed by someone else?
Build Break Fix: pValue is undefined. This error has existed forever, but was ignored because MSVC simply doesn't emit compile errors for templated methods that aren't called.
Three changes:
1. Fix C2362: initialization of a value skipped by a goto.
2. Fix C4596: referencing a class from within the class declaration is illegal.
3. Standard C++ does not permit examining dependent base classes when looking for declarations of member functions. Use 'this->' when calling non-overridden base class methods.