1. 28 May, 2020 5 commits
    • 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 20 May, 2020 9 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
    • Dan Melnic's avatar
      fsync the temp file · 5309963f
      Dan Melnic authored
      Summary: fsync the temp file
      
      Reviewed By: yfeldblum, kevin-vigor
      
      Differential Revision: D21668049
      
      fbshipit-source-id: 85825f81dfbe10a452f7f946133bb3d8993850f8
      5309963f
    • Yedidya Feldblum's avatar
      rethrow_current_exception · 51bad111
      Yedidya Feldblum authored
      Summary: [Folly] `rethrow_current_exception`, a `-fno-exceptions` compatibility wrapper for `throw;`.
      
      Reviewed By: ispeters
      
      Differential Revision: D21656269
      
      fbshipit-source-id: 8f37fe71c6255162b8f05268cae04ac5927013d7
      51bad111
    • Nick Terrell's avatar
      Fix a typo in CpuId breaking gcc-6.5 builds · 29e37140
      Nick Terrell authored
      Summary:
      gcc-6.5 on OS X <= 10.6 complains about the `\r` when this code path
      is enabled. I don't think we officially support `__i386__`, but I want to
      backport the patch from zstd. https://github.com/facebook/zstd/pull/1418
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum, Orvid
      
      Differential Revision: D13104652
      
      fbshipit-source-id: 737a68253c7d90c3a1cc026069b048551cb5ced9
      29e37140
    • Adam Simpkins's avatar
      use exceptionStr() when formating some errors in the logging code · 45f233c1
      Adam Simpkins authored
      Summary:
      If an error is thrown when formating arguments for a log message, use
      `folly::exceptionStr()` to format the exception instead of just `ex.what()`.
      
      I changed all of the tests that verify the results of these strings to use a
      regular expression, as `folly::exceptionStr()` produces different results in
      different platforms, and does not always demangle type names.
      
      I also included a minor change to increase a timeout in
      AsyncFileWriterTest.cpp, as I saw this timeout fail spuriously once in my
      testing.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21635680
      
      fbshipit-source-id: 749ef48deb59af1f2faef0158e0291838e09fc38
      45f233c1
  10. 19 May, 2020 7 commits
    • Matt Ma's avatar
      Fix and refactor inline functions stack trace. · 2d2c15fc
      Matt Ma authored
      Summary:
      Fix the issue that there may be other tags like DW_TAG_lexical_block between DW_TAG_subprogram and DW_TAG_inlined_subroutine.
      
      Also increase the maximum inline location info per frame since previous value 3 is too small.
      
      Refactors the code to set file and line for inline functions.
      
      Reviewed By: luciang
      
      Differential Revision: D21250080
      
      fbshipit-source-id: f52dc74ee5c144aa26723546b48486f8a5250f19
      2d2c15fc
    • Dan Melnic's avatar
      Fix uninitialized maxSubmit_, maxGet_ member variables · 8228e607
      Dan Melnic authored
      Summary: Fix uninitialized maxSubmit_, maxGet_ member variables
      
      Reviewed By: danobi
      
      Differential Revision: D21645171
      
      fbshipit-source-id: 094ba7b045010954fdebc249318191f956f5b7b2
      8228e607
    • Adam Simpkins's avatar
      make it possible to use folly logging with exceptions disabled · 04b3ad7f
      Adam Simpkins authored
      Summary:
      This updates the logging code so that it is possible to include `folly/xlog.h`
      and write log statements in code that is compiled with `-fno-exceptions`
      
      The code for parsing log configuration strings does still use exceptions in
      some of its config parsing logic.  It shouldn't be too difficult to disable
      that in a subsequent diff, but for now this change at least makes it possible
      for calling code to write log messages.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21630914
      
      fbshipit-source-id: ce9ed422f40066e57433a85182e1a8fc6d8628db
      04b3ad7f
    • Robin Cheng's avatar
      Fix a minor race condition for ThreadPoolExecutor. · cf7284d0
      Robin Cheng authored
      Summary:
      This fixes a race condition detected by ThreadSanitizer.
      
      The thread list is protected by a mutex, but individual structs in the list are not protected, leading to racy access to two of their fields. This diff makes the fields atomic.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21484748
      
      fbshipit-source-id: a981419f47a2aebaf1d40b23e9c4967cf2104aaa
      cf7284d0
    • Dan Melnic's avatar
      Remove PollIoBackend inline submit · b412547b
      Dan Melnic authored
      Summary: Remove PollIoBackend inline submit
      
      Reviewed By: danobi
      
      Differential Revision: D21625033
      
      fbshipit-source-id: 02ee55e64a2538c6a2392ea70912f4ae9b642963
      b412547b
    • Lee Howes's avatar
      Add another option to control output formatting of stack traces · 509ab86b
      Lee Howes authored
      Summary:
      The current stack trace formatting is based on repeated string appends with newlines. This change adds more control so that we can produce file and line information only, without unnecessary newlines.
      
      New format:
        ./folly/experimental/symbolizer/Symbolizer.h:77
        ./folly/experimental/symbolizer/test/StackTraceTest.cpp:209
        ./folly/experimental/symbolizer/test/StackTraceTest.cpp:213
        ./folly/experimental/symbolizer/test/StackTraceTest.cpp:258
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21562670
      
      fbshipit-source-id: 7d05605cbda686e2f1c87577647c7ab7581f8580
      509ab86b
    • Kirk Shoop's avatar
      Add ensureCleanupAfterTask · 59a079eb
      Kirk Shoop authored
      Summary:
      adds ensureCleanupAfterTask()
      
      takes a SemiFuture<T> task and a SemiFuture<Unit> cleanup.
      
      returns a SemiFuture<T>
      
      always starts cleanup after task completes. stores the result of the task and replays it after the cleanup completes.
      
      cleanup is not allowed to fail.
      
      Reviewed By: yfeldblum, andriigrynenko
      
      Differential Revision: D21481825
      
      fbshipit-source-id: 901a91c25f7b2b4fa794a590a5433e0fad27d168
      59a079eb