1. 03 Jun, 2020 1 commit
    • Victor Zverovich's avatar
      Update fmt version to 6.2.1 · 7e211332
      Victor Zverovich authored
      Summary:
      Update fmt version to 6.2.1 for better compatibility with the version used in fbcode. Among other things this fixes fbthrift build failure on Travis:
      
      ```
      /home/fbthrift/thrift/lib/cpp2/async/RocketClientChannel.cpp:70:67:   required from here
      /home/install/include/fmt/core.h:492:3: error: static assertion failed: don't know how to format the type, include fmt/ostream.h if it provides an operator<< that should be used
      ```
      which is caused by trying to format an enum class without a formatter - only supported as of 6.0.
      
      Reviewed By: stevegury, avalonalex
      
      Differential Revision: D21860076
      
      fbshipit-source-id: 1857ab65822956b005980b8dfff7a967508f507c
      7e211332
  2. 01 Jun, 2020 3 commits
    • Yedidya Feldblum's avatar
      Cut FOR_EACH_ENUMERATE · 06274a0d
      Yedidya Feldblum authored
      Summary: [Folly] Cut the `FOR_EACH_ENUMERATE` macro, which may be replaced by a combination of range-for, `ranges::view::enumerate`, and structured bindings.
      
      Reviewed By: markisaa
      
      Differential Revision: D21813019
      
      fbshipit-source-id: fc9ac09a4e2f72f1433d0a518f03d5cd69a59c55
      06274a0d
    • Dan Melnic's avatar
      Expose async read/write functionality · f6784e42
      Dan Melnic authored
      Summary: Expose async read/write functionality
      
      Reviewed By: yfeldblum, kevin-vigor
      
      Differential Revision: D21731597
      
      fbshipit-source-id: 95a0af53c7b85e1bf1a2619586091b6633bc7b8a
      f6784e42
    • soyoo's avatar
      Fix typo in stop_watch.h (#1110) · 8f91f848
      soyoo authored
      Summary: Pull Request resolved: https://github.com/facebook/folly/pull/1110
      
      Reviewed By: Orvid
      
      Differential Revision: D21110331
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 57522232efb7268bc290e4f22057f531a380fb81
      8f91f848
  3. 29 May, 2020 5 commits
    • Lee Howes's avatar
      Have SemiFuture::within mark internal futures as consumed to avoid treating them as discarded. · 15449325
      Lee Howes authored
      Summary:
      SemiFuture::within creates two valid SemiFutures and promptly overwrites them, both discarding valid SemiFutures and wasting the core allocation. It later drops the updated versions without directly consuming them, instead stealing the deferred executors.
      
      This update initializes the two SemiFutures as empty, and safely terminates the chain with trivial callbacks so the SemiFutures can be treated as consumed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21769500
      
      fbshipit-source-id: eab13a78b17ecfc937b42c8d5e01e1292158d9ed
      15449325
    • Chad Austin's avatar
      fix some warnings on macOS · 8f13bf87
      Chad Austin authored
      Differential Revision: D21757385
      
      fbshipit-source-id: 28af042285d343944452e1c2cf94794a121c0e06
      8f13bf87
    • Sergey Anpilov's avatar
      Fix "unused parameter" in getValueOrUnit in non-debug builds · 6840cc81
      Sergey Anpilov authored
      Summary:
      `value` could trigger "unused parameter" warning in NDEBUG builds. The fix is straightforward, to use the new-ish `[[maybe_unused]]` attribute.
      
      The alternatives are to use `FOLLY_MAYBE_UNUSED` or even manual `(void)value;`. But since this is coroutines library, it should be reasonably safe to assume the compiler supports the cleaner and more expressive native C++17 option.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D21784931
      
      fbshipit-source-id: 895bf95d65df6533d768b65c44a898a73e0a636f
      6840cc81
    • Chad Austin's avatar
      don't use clock_gettime fallback on modern macOS · c85f8af6
      Chad Austin authored
      Summary:
      There were two problems with the clock_gettime fallback logic on
      macOS. One is that it used undefined macros if AvailabilityMacros.h
      wasn't included. Another is that it compiled the fallback when the
      minimum iPhone OS version (as when building on macOS) was not set, and
      vice versa.
      
      Fix that.
      
      Differential Revision: D21757362
      
      fbshipit-source-id: 99fd17260cb25ed07c39ba79466e835f08a1fc7c
      c85f8af6
    • Matt Dordal's avatar
      add a method to access a threadlocal without creating an object · fd295717
      Matt Dordal authored
      Summary:
      It may be useful to see if a threadlocal has been created on a thread before accessing it.
      
      One way this could be useful: the data is only relevant to a few threads but will be accessed by many. This would allow you to save the memory on the non-relevant threads.
      
      Differential Revision: D21731260
      
      fbshipit-source-id: 0b1835b454f9b0c457f722ab38f84f89aca383fb
      fd295717
  4. 28 May, 2020 7 commits
    • Andrew Huang's avatar
      (Trivial) Add detailed comment for session cache settings in SSLContext · 0674ab06
      Andrew Huang authored
      Summary: Add detailed comment to SSL_CTX_set_session_cache_mode call in SSLContext, since any changes can result in breaking functionality or increased memory usage.
      
      Reviewed By: mingtaoy
      
      Differential Revision: D21769914
      
      fbshipit-source-id: 61a172f24cda870d6c13a24d279509e2e2804538
      0674ab06
    • Lewis Baker's avatar
      Make collectAll, collectAllRange, collectAllWindowed consistently rethrow... · e19b938b
      Lewis Baker authored
      Make collectAll, collectAllRange, collectAllWindowed consistently rethrow exception from first failure
      
      Summary:
      The void-returning variants of collectAllRange() and collectAllWindowed() were
      previously failing with the error from the first task to fail whereas the other
      variants of collectAll() were failing with an arbitrary error (typically first
      by argument order) in the case of multiple errors.
      
      This was problematic because after the first task failed it requests cancellation
      of the other tasks, which then often will complete with an 'OperationCancelled'
      error. This mean that, unless the original error occurred on the first failed
      task in argument order, the error that caused the cancellation would be discarded
      and instead, the collectAll() operation would result in an 'OperationCancelled'
      error.
      
      This change updates those algorithms to now consistently fail with the error
      from the first task to fail (in time) as this error will typically be the most
      useful in determining the root cause of the failure.
      
      Also it now discards any errors that occur in child tasks if they fail after
      cancellation was requested on the parent task. In this case the collectAll()
      will complete with an 'OperationCancelled' error.
      
      Also made a few drive-by changes to avoid rethrowing exceptions where possible
      by using `co_yield co_error(e)`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21681812
      
      fbshipit-source-id: dfe15d0672dcbdeb4e156962cdffe767ddf91a0b
      e19b938b
    • Lewis Baker's avatar
      Add cancellation support for folly::coro::UnboundedQueue::dequeue() · 70f914ba
      Lewis Baker authored
      Summary:
      Adds the ability to request cancellation of the folly::coro::UnboundedQueue's
      dequeue() operation by injecting a CancellationToken using co_withCancellation().
      
      Most of the work for supporting this was implemented in the change to
      Semaphore::co_wait() to support cancellation.
      
      This diff just adds some tests for cancellation of UnboundedQueue::dequeue()
      and provides a more efficient code-path for the cancellation-case that does
      not involve throwing an exception.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21555325
      
      fbshipit-source-id: 7fbae8aa426b40bbea4d0d6dec85df4bad813733
      70f914ba
    • Lewis Baker's avatar
      Make folly::fibers::Semaphore::co_wait() cancellable · 955b416f
      Lewis Baker authored
      Summary:
      The `Semaphore::co_await()` method now response to requests for cancellation
      communicated through the awaiting context's CancellationToken.
      
      This allows interrupting a wait-operation if the result is no longer required,
      in which case the co_wait() task completes with the OperationCancelled exception.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21655946
      
      fbshipit-source-id: 8c7f862580ddebd2b4d3eb3cc3ab5e01ad5ee289
      955b416f
    • Lewis Baker's avatar
      Change folly::fibers::Semaphore to use an intrusive list of waiters · f8a3d164
      Lewis Baker authored
      Summary:
      Now use an intrusive list structure to store the list of waiters waiting
      for the semaphore to be signalled.
      
      This is primarily motivated by the need to support efficient cancellation,
      which requires the ability to efficiently remove a specific element from
      the waiter list without having to scan the list like we would for the
      existing `std::deque`-based list storage.
      
      Another beneift of this change is that it now eliminates memory allocations
      that were previously required by the std::deque container.
      
      The `Semaphore::future_wait()` implementation should now also have one fewer
      allocations as the allocation of the Baton and the Baton::Waiter are now fused.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21692257
      
      fbshipit-source-id: 9beff176b250ae3f37df9e2138f93b15d2607353
      f8a3d164
    • Kyle Nekritz's avatar
      Fix expiration on test certificate authorities. · ac31a538
      Kyle Nekritz authored
      Summary: These only had a 1 month expiration after D21271202.
      
      Reviewed By: xybu, mingtaoy
      
      Differential Revision: D21765601
      
      fbshipit-source-id: 18b9f400e96b2ba39df650db9e6627f1cf917250
      ac31a538
    • Matt Ma's avatar
      Change symbolize function to return the actual used frame count. · a55266f1
      Matt Ma authored
      Summary:
      If inline functions are enabled, actual frames used can be larger than the
      address count.
      
      Reviewed By: luciang
      
      Differential Revision: D21371112
      
      fbshipit-source-id: c1e602b62b6af427f11701bf25894a99f554ec47
      a55266f1
  5. 27 May, 2020 2 commits
    • Pranav Thulasiram Bhat's avatar
      Create Async interface for Baton · e844b95a
      Pranav Thulasiram Bhat authored
      Summary:
      Baton is the primitive that allows fibers to block. The goal of this diff is to provide an `Async` interface to blocking calls that operate on Batons.
      
      Overloading `await` directly was one option, however, there are 3 blocking baton APIs (wait, try_wait_for and try_wait_until). Morover these APIs can accept arguments (something async::await doesn't do so far)
      
      So, this diff adds a bunch of wrappers that return Async<> results that must be 'awaited' on. This keeps static-analysis happy, and performs the onFiber check.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21667887
      
      fbshipit-source-id: 774c19d223ebb0932c043e4c09635c5e85cc8241
      e844b95a
    • Maged Michael's avatar
      RequestContext: Fix race condition in releasing clear and delete counts of RequestData · e1c7e6ce
      Maged Michael authored
      Summary:
      Fix race condition between releaseRefClearDelete and releaseRefDeleteOnly by fixing handling in releaseRefClearDelete of the case where the clear count is 1 and the delete count is > 1.
      
      The correct behavior of releaseRefClearDelete when delete count > 1 is to release the clear count first and then release the delete count, instead of releasing the two counts in one step.
      
      The following sequence of events demonstrates the problem in the absence of the fix:
      - clear count == 1 and delete count == 2
      - Thread 1 calls releaseRefClearDeleteCount
      - Thread 2 calls releaseRefDeleteOnly
      - Thread 1 atomically decrements the counts to 0 and 1
      - Thread 2 atomically decrements the delete count to 0
      - Thread 2 deletes the RequestData object
      - Thread 1 call to onClear accesses deleted object
      
      Reviewed By: yfeldblum, davidtgoldblatt
      
      Differential Revision: D21705266
      
      fbshipit-source-id: 8ec2151c4e98968beaef7e9ccec0a786ca5ae267
      e1c7e6ce
  6. 26 May, 2020 4 commits
    • Jon Maltiel Swenson's avatar
      Enable request timeout callback to be any HHWheelTimer callback · ad1c3b8e
      Jon Maltiel Swenson authored
      Summary: This diff factors out some of the logic needed in the stacked diff D21628842. We want `RocketClientChannel::sendRequestResponse` to work without a fiber if the caller is not already on a fiber, which means we cannot only use `Baton::TimeoutHandler` for the request's timeout callback.
      
      Reviewed By: iahs
      
      Differential Revision: D21628871
      
      fbshipit-source-id: 2e739f205fcb0a255108fa88f94107378a1bab49
      ad1c3b8e
    • Chad Austin's avatar
      allow building python3 streaming on platforms without coroutines · 774673fb
      Chad Austin authored
      Summary:
      In order to use the Python 3 streaming thrift client on platforms that
      don't support coroutines, conditionally define anything that depends
      on coroutines.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21692900
      
      fbshipit-source-id: 9f26d598097181ae43d1ff377a22b1c2f789321e
      774673fb
    • Yedidya Feldblum's avatar
      Add missing includes of folly/synchronization/Baton.h · d65ffba7
      Yedidya Feldblum authored
      Summary: Add missing includes of `folly/synchronization/Baton.h`.
      
      Differential Revision: D21716396
      
      fbshipit-source-id: 8c8fb818f3083b4fe04fd1c62923d7ba698dcedd
      d65ffba7
    • Dan Melnic's avatar
      Add AsyncUDPSocket::maxReadsPerEvent_ support · 40d9b66e
      Dan Melnic authored
      Summary: Add AsyncUDPSocket::maxReadsPerEvent_ support
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21509991
      
      fbshipit-source-id: 5c4f939c1cfdda8711864df3b5f5c58439f8d7bf
      40d9b66e
  7. 25 May, 2020 1 commit
    • Yedidya Feldblum's avatar
      Compare exception_wrapper::class_name() to demangle(typeid(...)) in tests · 9f44c679
      Yedidya Feldblum authored
      Summary: [Folly] Compare `exception_wrapper::class_name()` to `demangle(typeid(...))` in tests v.s. comparing it to string literals since the actual result of `...::class_name()` depends on the platform and whether `libiberty-dev` is available.
      
      Differential Revision: D21711569
      
      fbshipit-source-id: b2289d89923d6775c7e806eff9c3732ad37a0218
      9f44c679
  8. 24 May, 2020 1 commit
    • Yedidya Feldblum's avatar
      Prefer EndsWith matcher in exception_wrapper test · 82ca4c04
      Yedidya Feldblum authored
      Summary: [Folly] Prefer `EndsWith` matcher in `exception_wrapper` test so that, in case of failure, the non-matching input will be shown.
      
      Differential Revision: D21708674
      
      fbshipit-source-id: 022f7d64a030417b80b8796ae3d78534295509fc
      82ca4c04
  9. 23 May, 2020 2 commits
    • Yedidya Feldblum's avatar
      Comments in folly/synchronization/Lock.h · d5ce6e82
      Yedidya Feldblum authored
      Summary: [Folly] Comments in `folly/synchronization/Lock.h`.
      
      Differential Revision: D21689050
      
      fbshipit-source-id: 65ffa2cf9bf3afe8740ae0c4a0d529c706397dae
      d5ce6e82
    • Yedidya Feldblum's avatar
      Extract utf-16 surrogate-pair helpers · 49fd581d
      Yedidya Feldblum authored
      Summary: [Folly] Extract utf-16 surrogate-pair helpers from `folly/json.cpp` into `folly/Unicode.h`.
      
      Reviewed By: luciang
      
      Differential Revision: D21634400
      
      fbshipit-source-id: 64d15e79fe19cce5f5c9c38837d4663209b5f888
      49fd581d
  10. 22 May, 2020 2 commits
    • Lee Howes's avatar
      Add logging for SemiFutures that are discarded with potential · 44ff9b50
      Lee Howes authored
      Summary: Add tracing to SemiFuture destruction that is potentially work-dropping.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21671142
      
      fbshipit-source-id: 8e3e733d9a0845b00fe7ccf465e9c817a10fee59
      44ff9b50
    • Wez Furlong's avatar
      getdeps: use `eden prefetch` on windows · 93d952a9
      Wez Furlong authored
      Summary:
      Now that we've deployed the new eden build with globfiles
      support, we can enable the use of eden prefetch in the getdeps
      build when running inside an EdenFS mount on Windows.
      
      Reviewed By: fanzeyi
      
      Differential Revision: D21692689
      
      fbshipit-source-id: b42e778901976cf0385ec31056c227b2049162dc
      93d952a9
  11. 21 May, 2020 7 commits
    • Ian Petersen's avatar
      Enable building folly/Expected.h with coroutines on and exceptions off · 791aa797
      Ian Petersen authored
      Summary:
      `folly::expected_detail::Promise<Value, Error>` won't build with exceptions
      turned off (e.g. by passing `-fno-exceptions` on Clang's command line) because
      its `unhandled_exception()` says `throw;`.  This diff replaces the `throw;`
      with a call to `folly::rethrow_current_exception();`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21682605
      
      fbshipit-source-id: 294752590d54b0671395982ccdeb0386a742c01e
      791aa797
    • Yedidya Feldblum's avatar
      Use RequestToken in RequestEventBase · 8174190b
      Yedidya Feldblum authored
      Summary: [Folly] Use `RequestToken` in `RequestEventBase` to speed up lookup.
      
      Reviewed By: zhxchen17
      
      Differential Revision: D21529465
      
      fbshipit-source-id: eaaef7b48be2c5a8d76fb5f4a5293f7db7e68bed
      8174190b
    • Yedidya Feldblum's avatar
      Fix typo in checking hw checksum support · ed5983fe
      Yedidya Feldblum authored
      Summary: [Folly] Fix technical typo in checking hw checksum support, but which makes no practical difference.
      
      Differential Revision: D21689112
      
      fbshipit-source-id: 8ad71d20a561f4bbf5c413ce94e7bec227d9d940
      ed5983fe
    • Amir Livneh's avatar
      Fix instances of "the the" in comments · 6ff43051
      Amir Livneh authored
      Reviewed By: yfeldblum
      
      Differential Revision: D21666740
      
      fbshipit-source-id: 96975e777df0745f343c5b722f1d8c05bb8ac32e
      6ff43051
    • Yedidya Feldblum's avatar
      Tweak BlockingContext · f8dfa34d
      Yedidya Feldblum authored
      Summary: [Folly] Tweak `BlockingContext` in various ways.
      
      Differential Revision: D21657789
      
      fbshipit-source-id: 4b03b3b43dddc0e9011a7594001994f2594a1a5b
      f8dfa34d
    • Yedidya Feldblum's avatar
      Lock utilities · 2fc0cee3
      Yedidya Feldblum authored
      Summary:
      [Folly] Lock utilities: `upgrade_lock`, `transition_to_shared_lock`, `transition_to_upgrade_lock`, `transition_to_unique_lock`, `try_transition_to_unique_lock`.
      
      Note: `std::shared_mutex` does not have an upgrade state or any atomic transitions; there is no `std::upgrade_lock`; and `std::shared_lock` does not have a constructor from `std::unique_lock`.
      
      Reviewed By: simpkins, nbronson
      
      Differential Revision: D15532568
      
      fbshipit-source-id: d32f387b26b57539857922c3090dc75ffcaaa538
      2fc0cee3
    • Lee Howes's avatar
      Remove collectXSemiFuture · 8c529eea
      Lee Howes authored
      Summary:
      Migration from Future-returning executor-erasing collectX forms to
      SemiFuture-returning forms, that are less risky in particular with coroutines.
      
      Earlier changes added collectXSemiFuture and collectXUnsafe as a migration
      path. We then migrated collectX callsites to collectXSemiFuture or
      collectXUnsafe and switched the implementation of collectX to the SemiFuture
      form.
      
      This diff removes collectXSemiFuture completely.
      
      Reviewed By: yfeldblum, mpark
      
      Differential Revision: D21631886
      
      fbshipit-source-id: c7b296d51f30c8b51ab0c7d06b1ce62c8cdd28d5
      8c529eea
  12. 20 May, 2020 5 commits
    • Ian Petersen's avatar
      Enable building folly/Optional.h with coroutines on and exceptions off · 8abb78f4
      Ian Petersen authored
      Summary:
      `folly::detail::OptionalPromise<Value>` won't build with exceptions turned off
      (e.g. by passing `-fno-exceptions` on Clang's command line) because its
      `unhandled_exception()` says `throw;`.  This diff replaces the `throw;` with a
      call to `folly::rethrow_current_exception();`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21655976
      
      fbshipit-source-id: 5f431372f2494a09f98e3b8c36a94e8475efff29
      8abb78f4
    • Bryan Alger's avatar
      Fix win32 build of PThread · c6897700
      Bryan Alger authored
      Summary:
      This fails to build on win32 platform with:
      ```
      xplat\folly\portability\pthread.cpp(142): error C2664: 'HANDLE CreateThread(LPSECURITY_ATTRIBUTES,SIZE_T,LPTHREAD_START_ROUTINE,LPVOID,DWORD,LPDWORD)': cannot convert argument 3 from 'DWORD (__cdecl *)(void *)' to 'LPTHREAD_START_ROUTINE'
      ```
      
      This seems to fix it.
      
      Reviewed By: Orvid
      
      Differential Revision: D21623386
      
      fbshipit-source-id: 1b18a74bd71ffc75f34a92074e07f3d69742c07d
      c6897700
    • Yedidya Feldblum's avatar
      Small simplification of AsyncSocket read loop · 5009c3cb
      Yedidya Feldblum authored
      Summary: [Folly] Small simplification of `AsyncSocket` read loop.
      
      Differential Revision: D21514325
      
      fbshipit-source-id: 0af27205b4aa2807a800430e8a2b3dea36356970
      5009c3cb
    • Dan Melnic's avatar
      Add io_uring_submit_and_wait call · fca66cf3
      Dan Melnic authored
      Summary: Add io_uring_submit_and_wait call
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21653382
      
      fbshipit-source-id: 945aa877a30b3c6431089a113ece5999d1217eb4
      fca66cf3
    • Matt Ma's avatar
      Remove unused name field in LocationInfo. · e8f3237c
      Matt Ma authored
      Reviewed By: yfeldblum, luciang
      
      Differential Revision: D21656746
      
      fbshipit-source-id: 5e19d72ccd524926c698b8814cc6c8f2c6133565
      e8f3237c