1. 22 Oct, 2021 3 commits
    • Ben Blackburne's avatar
      Revert D31823117: remove folly:file dependency from folly:random · ad3ec3b8
      Ben Blackburne authored
      Differential Revision:
      D31823117
      
      Original commit changeset: 115a59d69d4c
      
      fbshipit-source-id: 5245896f91b26977f6d8bab204a4e719c23c0900
      ad3ec3b8
    • TJ Yin's avatar
      remove folly:file dependency from folly:random · 95223cc0
      TJ Yin authored
      Reviewed By: vitaut
      
      Differential Revision: D31823117
      
      fbshipit-source-id: 115a59d69d4c91ac35d60764ab24de175e27207c
      95223cc0
    • James Donald's avatar
      Suppress MSVC spurious warning about not-enough-args BOOST macro · 0cb87475
      James Donald authored
      Summary:
      These boost macros have a longstanding warning problem, not fixed in VS 2019
      ```
      folly\overload.h(72): warning C4003: not enough arguments for function-like macro invocation 'BOOST_PP_TUPLE_TO_LIST_1'
      folly\overload.h(73): warning C4003: not enough arguments for function-like macro invocation 'BOOST_PP_TUPLE_TO_LIST_1'
      ```
      
      Reviewed By: kosievdmerwe
      
      Differential Revision: D25497039
      
      fbshipit-source-id: 47e6555681f043d6d7a80cc0c963d6e326e70242
      0cb87475
  2. 21 Oct, 2021 3 commits
    • Cristian Lumezanu's avatar
      Fix ConstructorCallback destructor consistency issue · cf3af766
      Cristian Lumezanu authored
      Summary:
      ConstructorCallback enables the addition of callback functions to be called when a class constructor is called (D27056139 (https://github.com/facebook/folly/commit/d31902b958fc21c7bf812b0ec45c796b4bf9073c)). The ConstructorCallback object holds a static array with all installed callbacks. When a class constructor is called, the ConstructorCallback constructor traverses the array and executes each installed callback. The array is destroyed when all instances of the class are destroyed.
      
      This diff fixes a potential concurrency issue when ConstructorCallbacks are destroyed: the callback array is destroyed while another thread is calling the class constructor and potentially looping through the callback array. We fix the issue by putting the callback array, the callback count, and the mutex into a struct and initializing a `createGlobal` object from the struct.
      
      **Facebook:**
      
      We describe the issue in more detail in T100230454.
      
      Reviewed By: bschlinker
      
      Differential Revision: D30910255
      
      fbshipit-source-id: d345900dbadbf2e009719b6f930ab1d8aa284647
      cf3af766
    • Callum Ryan's avatar
      Task cancellation from Python · 359722f3
      Callum Ryan authored
      Summary:
      Extending the current support for python futures <-> folly tasks interop to also support cancellation.
      
      By adding a new version of `bridgeCoroTask` that also accepts a `folly::CancellationToken` we can give python code the ability to cancel the folly task.
      
      Reviewed By: nanshu
      
      Differential Revision: D31765430
      
      fbshipit-source-id: 4277e94e296f56b998c9c583823a93ce5b9e7586
      359722f3
    • Dan Melnic's avatar
      Fix C++20 build · ea4721b1
      Dan Melnic authored
      Summary: Fix C++20 build
      
      Reviewed By: luciang
      
      Differential Revision: D31786941
      
      fbshipit-source-id: 153ffcee7b64f4c6dfafb786df90e909cee723b3
      ea4721b1
  3. 20 Oct, 2021 5 commits
    • Nikita Lutsenko's avatar
      folly | Add stub for ThreadId when building with emscripten. · 63f559ca
      Nikita Lutsenko authored
      Summary: No thread id available built-in in emscripten, even though it has partial pthread support. Stub it out.
      
      Reviewed By: boguscoder
      
      Differential Revision: D31754569
      
      fbshipit-source-id: 29113ba31cf6b65e7d5c52455fd99ee1e659c041
      63f559ca
    • Yedidya Feldblum's avatar
      move make_unique_lock to folly/synchronization/Lock.h · 5bef498a
      Yedidya Feldblum authored
      Summary: Since all the other lock utilities are there.
      
      Differential Revision: D31523986
      
      fbshipit-source-id: 22a071c50e51518b061980d7429d1a28755dbe40
      5bef498a
    • TJ Yin's avatar
      fix file_util in windows · 1e7f9f89
      TJ Yin authored
      Summary:
      For MSVC, `ssize_t` and `std::make_signed_t<std::size_t>` are different types (even though both are 32 bit signed integer, `std::is_same` is false: https://godbolt.org/z/n4Wfbh3nM). This creates type mismatch between header and cpp file.
      
      This diff changed to include `folly/portability/SysTypes.h` which defines `ssize_t` in a portable way.
      
      Reviewed By: ot
      
      Differential Revision: D31722673
      
      fbshipit-source-id: c8968d5e0b5ac12d8d6ab4c141f791cb73d80686
      1e7f9f89
    • Dan Melnic's avatar
      Fix -Werror,-Wunused-result · 5cfeab7b
      Dan Melnic authored
      Summary: Fix -Werror,-Wunused-result
      
      Reviewed By: ispeters
      
      Differential Revision: D31786026
      
      fbshipit-source-id: 51af8e21a02f9d6f476d0cb79eb7c6d38f545f20
      5cfeab7b
    • Dan Melnic's avatar
      Fix C++20 build · 0f877ebd
      Dan Melnic authored
      Summary: Fix C++20 build
      
      Reviewed By: ispeters
      
      Differential Revision: D31785835
      
      fbshipit-source-id: ecfa717787546048c422084785b51e0f7d8eaa26
      0f877ebd
  4. 19 Oct, 2021 5 commits
  5. 18 Oct, 2021 3 commits
    • Cristian Lumezanu's avatar
      Add connectAttempt and connectSuccess AsyncSocket::LifecycleObserver callbacks · ba3aedb3
      Cristian Lumezanu authored
      Summary:
      Made the following changes AsyncTransport::LifecycleObserver callback
      - added `connectAttempt()`, called for each observer when connect is invoked;
      - changed `connect()` to `connectSuccess()`, called for each observer when connect is successful;
      
      Reviewed By: bschlinker
      
      Differential Revision: D29962337
      
      fbshipit-source-id: f1d2c0e48b6d7e263466f74c97d701bb9df9b313
      ba3aedb3
    • Yedidya Feldblum's avatar
      fix dynamic::operator--(int) · 81c70338
      Yedidya Feldblum authored
      Summary: A typo in its name meant it was missing and that `dynamic::operator-(int)` was defined instead.
      
      Reviewed By: ot, luciang
      
      Differential Revision: D31726709
      
      fbshipit-source-id: 42696c958f674de806dd56c3d89ec07dd60db961
      81c70338
    • Giuseppe Ottaviano's avatar
      Fix retryingJitteredExponentialBackoffDur when jitter_param=0 · 51669993
      Giuseppe Ottaviano authored
      Summary:
      `retryingJitteredExponentialBackoffDur()` supports `jitter_param=0` (sanctioned in tests, and widely used to disable jitter based on a runtime parameter), but `std::normal_distribution` does not, so just special-case it.
      
      In practice, libstdc++ already returns 0.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D31722687
      
      fbshipit-source-id: d81b1736379c596c4fc352b0067a4ad5788b0f8c
      51669993
  6. 17 Oct, 2021 3 commits
    • Yedidya Feldblum's avatar
      revise sanitizer extern wrappers · e83309fe
      Yedidya Feldblum authored
      Summary: Make them a bit shorter with a bit less repetition. Performance-wise, trades away two direct calls for one indirect but perfectly-predictable call. And continues to optimize away in non-sanitizer builds.
      
      Reviewed By: luciang
      
      Differential Revision: D31673074
      
      fbshipit-source-id: f6d8b66cf45a81788d1ec0c5b58241f4fc693001
      e83309fe
    • Yedidya Feldblum's avatar
      use relaxed_atomic in BufferedRandomDevice · 0ae0ccc8
      Yedidya Feldblum authored
      Differential Revision: D31661218
      
      fbshipit-source-id: 48535870ab2b2f86b0d4e9286365fe906110dc3e
      0ae0ccc8
    • Yedidya Feldblum's avatar
      when Baton::wait marks timeout, just use relaxed · e5d88948
      Yedidya Feldblum authored
      Summary: While the baton is used to guard associated memory, if the wait times out, the associated memory is not available. There is no corresponding load-acquire, so marking the timeout may use a store-relaxed rather than a store-release.
      
      Reviewed By: luciang
      
      Differential Revision: D31676286
      
      fbshipit-source-id: dd2474db1ba053337de7e84aa88e7556e630b1ce
      e5d88948
  7. 16 Oct, 2021 1 commit
    • Yedidya Feldblum's avatar
      use relaxed_atomic in CacheLocality · 6eb46044
      Yedidya Feldblum authored
      Summary: The stripe table, which is a table of atomics, is its own data and does not guard any associated data. It must technically be atomic to avoid technical data race, but all accesses are relaxed.
      
      Differential Revision: D31524230
      
      fbshipit-source-id: 782b515f3845b4567ca258fd8d096f22248d60ff
      6eb46044
  8. 15 Oct, 2021 6 commits
    • Yedidya Feldblum's avatar
      bump c/x success order until c++17 · 9031f3d9
      Yedidya Feldblum authored
      Summary:
      We currently bump it for clang+tsan because the clang implementation of tsan historically implements the historical pre-c++17 rule even post-c++17. But to enable libstdc++ assertions, we must also bump it for for some versions of libstdc++ when assertions are enabled.
      
      The assertions are removed in libstdc++ trunk: https://github.com/gcc-mirror/gcc/commit/dba1ab212292839572fda60df00965e094a11252. They remain in libstdc++11.2.
      
      Reviewed By: ot
      
      Differential Revision: D31593055
      
      fbshipit-source-id: a339306e86452c4bb6d9d821cd28038ab6f49767
      9031f3d9
    • Cristian Lumezanu's avatar
      Change move constructor to populate member fields early · ae1e90a3
      Cristian Lumezanu authored
      Summary: The AsyncSocket move constructor creates a new socket and then populates member fields, such as `byteEventHelper_` and `preReceivedData_`, with the respective values from the old socket. This happens **after** any callbacks in the AsyncSocket constructor (e.g., installed with ConstructorCallback). These callbacks may need the updated values. This diffs offers the possibility to populate new socket member variables early, by adding them to the initializer list of the AsyncSocket constructor used in the move constructor.
      
      Reviewed By: bschlinker
      
      Differential Revision: D31318333
      
      fbshipit-source-id: 731d24ab4c7525e6f28c3aea4d04c9c5e98409ea
      ae1e90a3
    • Nitin Garg's avatar
      Replace spinlock with SharedMutex in DigestBuilder · 580d5f19
      Nitin Garg authored
      Summary:
      Spinlocks in user space are generally a bad idea due to tendency to
      burn CPU in outlier events. Replace it with SharedMutex instead. The common
      case cost could go up a bit should be better overall.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D31654923
      
      fbshipit-source-id: 77d249293458cd740904f777e00be1bd6834b62f
      580d5f19
    • Gabe Levi's avatar
      Port OpenSSL to sockets · 5fadaded
      Gabe Levi authored
      Summary: Added another line to the rsys sample app's `main.cpp`, which forced me to enable sockets and fix errors in order to get it compile and link.
      
      Reviewed By: usikder
      
      Differential Revision: D30192527
      
      fbshipit-source-id: 10eb9714900ca7f7a48c11b5d8308558ca5e8208
      5fadaded
    • Veselin Petrov's avatar
      Enable basic folly::Future support for XROS builds. · df5cac55
      Veselin Petrov authored
      Summary:
      `folly/io/async:async_base` is not fully migrated to XROS, mitigate futures implementation for now:
      * Craft out `fibers::Baton` and `IO pool` dependencies from futures.
      * Add futures to CI targets.
      * Add build time test to ensure `folly::Future<Unit>` symbols are generated.
      
      This closely follows mitigation in `AROS` branch:
      https://www.internalfb.com/code/aros/[a0c19baba13b]/xros/third-party/folly/folly/futures/Future.h
      
      (any suggestions on how to properly proceed with such change are greatly appreciated!)
      
      Reviewed By: egorich239
      
      Differential Revision: D31497625
      
      fbshipit-source-id: c0b2406496ca3c4f69ddadd61dbd1d75f309e8a1
      df5cac55
    • Dan Melnic's avatar
      Workaround for protected default constructor issue · 27ff58f4
      Dan Melnic authored
      Summary: Workaround for protected default constructor issue
      
      Reviewed By: yfeldblum, mpark, luciang
      
      Differential Revision: D31618662
      
      fbshipit-source-id: f7e2d498f2da01971b4f67dd28897026f405c0fb
      27ff58f4
  9. 14 Oct, 2021 9 commits
    • Dan Melnic's avatar
      csl_iterator fix · 07acbad2
      Dan Melnic authored
      Summary: csl_iterator fix
      
      Reviewed By: yfeldblum
      
      Differential Revision: D31664052
      
      fbshipit-source-id: 338b60ddc9575a7d73ee431e9cef848cecfbcdad
      07acbad2
    • Dan Melnic's avatar
      Async socket test workaround for -Werror,-Wsign-compare · 6b63ce1a
      Dan Melnic authored
      Summary: Async socket test workaround for -Werror,-Wsign-compare
      
      Reviewed By: mpark, ispeters, luciang
      
      Differential Revision: D31625210
      
      fbshipit-source-id: 387bf6172d4e518dfd850f456b859605aa9a6d0f
      6b63ce1a
    • Dan Melnic's avatar
      Address ConstructorCallback -Werror,-Wsign-compare · 36eb4497
      Dan Melnic authored
      Summary: Address ConstructorCallback -Werror,-Wsign-compare
      
      Reviewed By: ispeters, luciang
      
      Differential Revision: D31625450
      
      fbshipit-source-id: d5be388fc0d62eb715b5a8fe8e5758a8345cbbb0
      36eb4497
    • Misha Shneerson's avatar
      fix a unit test · be319ae4
      Misha Shneerson authored
      Differential Revision: D31641668
      
      fbshipit-source-id: a733dbd2dc4e3f20e82d75514ded1a51788d378f
      be319ae4
    • Giuseppe Ottaviano's avatar
      Promote DigestBuilder out of detail · d06843a4
      Giuseppe Ottaviano authored
      Summary: `DigestBuilder` is a useful companion to `TDigest` (already public), has a simple and well-defined interface, better documentation than most classes in the parent directory, tests, and benchmarks. It doesn't need to be in `detail/`, and it can be useful for use cases not covered by `BufferedStat`, for example when sub-second resolution and a precise flush schedule are required.
      
      Reviewed By: philippv, luciang
      
      Differential Revision: D31643638
      
      fbshipit-source-id: 4f2f54a933942cbe02d08cd63ab5fc04f13630e3
      d06843a4
    • Yedidya Feldblum's avatar
      operator symmetry for folly::dynamic · 9eef9f86
      Yedidya Feldblum authored
      Summary: Symmetric operators are done using free or non-member operators. This ensures that whatever conversions could happen to the RHS can also happen to the LHS, symmetrically.
      
      Reviewed By: philippv
      
      Differential Revision: D31582089
      
      fbshipit-source-id: ecae61bc810ee9538b1c2b738c58d4e9e01f1483
      9eef9f86
    • Mohammed Das's avatar
      Add CO_TYPED_TEST to GtestHelpers.h (#1669) · e2504d85
      Mohammed Das authored
      Summary:
      Pull Request resolved: https://github.com/facebook/folly/pull/1669
      
      Similar to CO_TEST_[F|P], adding CO_TYPED_TEST which allows test cases to use co_await/co_return and blocks on the Task<> separately.
      
      Reviewed By: iahs
      
      Differential Revision: D31621981
      
      fbshipit-source-id: 83618de2d106954bde819d90afde0c0140674d54
      e2504d85
    • Cameron Pickett's avatar
      AtScopeExit for coroutine cleanups · e9943344
      Cameron Pickett authored
      Reviewed By: iahs
      
      Differential Revision: D31271338
      
      fbshipit-source-id: 10cbd083c4da7461a43d4d0a9d4ab5455dcee270
      e9943344
    • Yedidya Feldblum's avatar
      fix a typo in Baton comments · 951a2b92
      Yedidya Feldblum authored
      Summary: While `wake()` is an accurate-enough description of what the function in question does, the actual name of the function is `post()`.
      
      Reviewed By: luciang
      
      Differential Revision: D31617933
      
      fbshipit-source-id: b45f062dccada3cedab2e2b7e7734f6b0b501e63
      951a2b92
  10. 13 Oct, 2021 2 commits
    • Jun Wu's avatar
      edenapi: remove tools · b6bf13bb
      Jun Wu authored
      Summary:
      `hg debugapi` now provides easier ways to test edenapi endpoints.
      Remove the `edenapi/tools` to reduce code bloat. This also unblocks removing
      `To/FromJson` complexity so adding new endpoints become easier.
      
      Reviewed By: yancouto
      
      Differential Revision: D31465796
      
      fbshipit-source-id: fdc0a47b4302c876e78455101068f27949d1b645
      b6bf13bb
    • Yedidya Feldblum's avatar
      Use relaxed_atomic in IOThreadPoolExecutor · 64fd47a2
      Yedidya Feldblum authored
      Summary:
      [Folly] Use `relaxed_atomic` in `IOThreadPoolExecutor`.
      
      For the `nextThread_` field, which may be mutated within `pickThread` in any number of threads concurrently. While `pickThread` is only ever called with a shared lock held, the shared lock does not actually help with concurrent mutations.
      
      Since the mutations of `nextThread_` by `pickThread` is always a `std::atomic::fetch_add` with `std::memory_order_relaxed`, and since that case is a bit more nicely solved with `folly::relaxed_atomic`, switch to that.
      
      Reviewed By: ot
      
      Differential Revision: D6290451
      
      fbshipit-source-id: e473fa6321e462c9b3df9d2bd9650967cca3444a
      64fd47a2