1. 02 Feb, 2018 4 commits
    • Lee Howes's avatar
      Fix for deferredexecutor behaviour. · 49cf5372
      Lee Howes authored
      Summary: DeferredExecutor suffered from a case where boosting would not work if no work was present. This change modifies is so that on a call to via the next executor will be set in the DeferredExecutor. When add is called the callback will be stored. Whichever happens second actually enqueues the work on the chained executor. get uses via to correctly implement this.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D6663244
      
      fbshipit-source-id: 74600d511373e0f6f7ca4128f25f3947a4981200
      49cf5372
    • Michael Lee's avatar
      Disable thread_local for all mobile targets · 3c49c7d6
      Michael Lee authored
      Summary: Android also has limited support for thread_local so we should not enable it at all as a precaution
      
      Reviewed By: magedm
      
      Differential Revision: D6884145
      
      fbshipit-source-id: f39dd8fd5405ca0bc5be9b3538718a6f58058442
      3c49c7d6
    • Andrii Grynenko's avatar
      Simplify EventBaseLoopController · 5359a760
      Andrii Grynenko authored
      Summary: Make EventBaseLoopController not dependent on EventBase's runOnDestruction. This will allow us to make FiberManager work with any Executor.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6828478
      
      fbshipit-source-id: 4d74776044a02954d022ef6f6f1e6834839973b8
      5359a760
    • Adam Simpkins's avatar
      remove duplicate FunctionSchedulerTest · 425c8833
      Adam Simpkins authored
      Summary:
      FunctionSchedulerTest.cpp was unfortunately copied into folly twice in separate
      locations.  D1845525 moved it into `folly/test`, D2051557 moved it into
      `folly/experimental/test`
      
      The version in `folly/experimental/test` has had several updates and new tests
      added; the version in `folly/test` has had no significant changes since it was
      first added.
      
      This diff deletes the older copy in `folly/test`
      
      Differential Revision: D6880255
      
      fbshipit-source-id: 8a4d5f6421ec18b319ffd76f98915e925b407468
      425c8833
  2. 01 Feb, 2018 12 commits
    • Michael Lee's avatar
      Unconditionally disable thread_local in hazard pointer when on mobile · be9e8ce5
      Michael Lee authored
      Summary:
      Sometimes the compiler lies to us and says it supports thread_local when it is not always fully implemented.
      
      Unconditionally disable this when `FOLLY_MOBILE` is set
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6875230
      
      fbshipit-source-id: 051f79eac78da03973bad9090b6577393b88998b
      be9e8ce5
    • Adam Simpkins's avatar
      cmake: mark the async_test as BROKEN for now · caed689d
      Adam Simpkins authored
      Summary:
      Disable running the async_test in open source builds.  A few of the tests
      functions in this binary are flaky.
      
      Additionally, this test consistently hangs in Travis CI builds.  It hangs in
      `AsyncSocketTest.ServerAcceptOptions`; I suspect it never sees the socket
      accept event and therefore never breaks out of the loop.  I suspect that even
      if we fixed this test other subsequent tests would also hang.  We should
      ideally update all of the tests to always have their own internal event base
      loop timeout rather than potentially looping forever, so it could at least run
      other test functions after a hang like this.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6874011
      
      fbshipit-source-id: 46c07a1cf3216eda1900e214447e6e49b6c8e489
      caed689d
    • Yedidya Feldblum's avatar
      Move invoke helpers into a special detail namespace · 2cd9535c
      Yedidya Feldblum authored
      Summary:
      [Folly] Move `invoke` helpers into a special detail namespace.
      
      So that code in `namespace folly::detail` can use `invoke_result`, etc., unqualified.
      
      Reviewed By: aary
      
      Differential Revision: D6869406
      
      fbshipit-source-id: 1b0ebbfb16621cf7e32c0f89162a19410a70605a
      2cd9535c
    • Adam Simpkins's avatar
      update CI scripts to run ctest with `--output-on-failure` · 047b8261
      Adam Simpkins authored
      Summary:
      Update our continuous integration configuration files to invoke ctest with the
      `--output-on-failure` flag so it will print the output of all tests that fail.
      Without this flag it is rather difficult to debug test failures in CI.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6869299
      
      fbshipit-source-id: 02d2e1ac03f786034b20797d02e9c3aa64c1b30b
      047b8261
    • Uddipta Maity's avatar
      Adding a method to get varint encoding size · 293868b2
      Uddipta Maity authored
      Summary: #title
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6864158
      
      fbshipit-source-id: 13c98c3e44db6febae844f099baa9fbecc9db673
      293868b2
    • Adam Simpkins's avatar
      logging: clean up some test checks for gcc-4.9 platforms · e8ca7f09
      Adam Simpkins authored
      Summary:
      Change some `EXPECT_EQ()` statements to `EXPECT_TRUE()` and `EXPECT_FALSE()`.
      This was causing compilation failures on some gcc-4.9 platforms.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6869102
      
      fbshipit-source-id: c3294eeca90130fec601c60a76cfa4dc1bc81639
      e8ca7f09
    • Maged Michael's avatar
      hazptr: remove logging of reclaim · aca1d9ef
      Maged Michael authored
      Summary: Removed instances of logging reclaim_
      
      Reviewed By: mzlee
      
      Differential Revision: D6864752
      
      fbshipit-source-id: d36205052799d2307e1cd6a0307c094ac3fa8b26
      aca1d9ef
    • Adam Simpkins's avatar
      update tests to build with gcc-4.9 · fce4eabe
      Adam Simpkins authored
      Summary:
      Various folly tests failed to compile when using the older gcc-4.9 version.
      Since we apparently want to keep supporting gcc-4.9 for a bit longer, update
      the code so that it can be compiled with gcc-4.9.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6817546
      
      fbshipit-source-id: a5224560330b49e94e10d21f81a83538ec7f34e9
      fce4eabe
    • Adam Simpkins's avatar
      add fbcode_builder configs for folly · bbab1089
      Adam Simpkins authored
      Summary: Add fbcode_builder configs for folly to folly/build.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6700053
      
      fbshipit-source-id: 3b9e974f727e7b7815580d8a12a6adfc3b529866
      bbab1089
    • Adam Simpkins's avatar
      update ThreadPoolExecutorTest to never try lowering niceness · 5d276f09
      Adam Simpkins authored
      Summary:
      The code in PriorityThreadFactoryTest.ThreadPriority attempted to set the
      thread niceness to 1.  This would fail if the process was already running at a
      higher niceness value and was not being run as root.
      
      This updates the test to get the current niceness first, and to use that plus 1
      as the niceness value to change to.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6817548
      
      fbshipit-source-id: 80e740f1fbe751865a418a58081bde4086b21679
      5d276f09
    • Adam Simpkins's avatar
      update ExceptionWrapperTest to have better typeid checks · fa2cd75d
      Adam Simpkins authored
      Summary:
      Update the ExceptionWrapperTest to check typeid strings against the result of
      calls to `demangle()`, rather than expecting `typeid(int)` to always be
      demangled as the string "int".  When building with gcc-7.2 on Ubuntu 17.10
      these type strings appear to be demangled simply as "i".
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6817545
      
      fbshipit-source-id: 134952106ad812f6980516247081bb9718b5ab38
      fa2cd75d
    • Adam Simpkins's avatar
      enable logging to stderr by default in test binaries · 6bd3f255
      Adam Simpkins authored
      Summary:
      Update folly's TestMain program to enable glog logging to stderr by default.
      
      Some of the tests in folly/experimental/test/TestUtilTest.cpp require that this
      is enabled, and fail if log messages are not logged to stderr.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6817543
      
      fbshipit-source-id: 87724c52124e72ad19f65524bcbd6536680f02ec
      6bd3f255
  3. 31 Jan, 2018 22 commits
    • Lee Howes's avatar
      Rename hazptr DEBUG_PRINT macro to HAZPTR_DEBUG_PRINT to avoid name clashes... · 8a278994
      Lee Howes authored
      Rename hazptr DEBUG_PRINT macro to HAZPTR_DEBUG_PRINT to avoid name clashes with other uses in code.
      
      Reviewed By: yfeldblum, magedm
      
      Differential Revision: D6863117
      
      fbshipit-source-id: 1626eacafbdddcfdaf181b2a5d0f6e216425b1ff
      8a278994
    • Adam Simpkins's avatar
      update README to require Ubuntu 16.04 at a minimum · 20260a99
      Adam Simpkins authored
      Summary:
      Drop instructions for building on Ubuntu 12.04, 13.10, and 14.04.  The oldest
      Ubuntu platform we support these days is 16.04.
      
      Our Travis CI configurations do still test building on Ubuntu 14.04 for now,
      but it is not a vanilla 14.04 installation.  We upgrade gcc to 4.9 and CMake to
      3.2 in order to build folly on this older Ubuntu version.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6780815
      
      fbshipit-source-id: 0d27cdbb928d32c1527623c8862d50ce2215dd48
      20260a99
    • Joe Loser's avatar
      Fix some unused parameters · 4dfc912b
      Joe Loser authored
      Summary:
      Fix a few unused parameters. One was unconditional; the other two are conditional based on some configuration values set during CMake configure time.
      Closes https://github.com/facebook/folly/pull/747
      
      Reviewed By: djwatson
      
      Differential Revision: D6858958
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: acb7fa5a79b9abfdf3dc210f649d0dea8ca4a87a
      4dfc912b
    • Yedidya Feldblum's avatar
      Generate group varint tables at compile time in C++ · 5a1dec3a
      Yedidya Feldblum authored
      Summary: [Folly] Generate group varint tables at compile time in C++, rather than as a separate custom build step in Python.
      
      Reviewed By: simpkins
      
      Differential Revision: D6832563
      
      fbshipit-source-id: fa218c512cbac383f153e7b6fd4df7f181bcb0de
      5a1dec3a
    • Yedidya Feldblum's avatar
      Generate escape tables at compile time in C++ · 82d6df58
      Yedidya Feldblum authored
      Summary: [Folly] Generate format tables at compile time in C++, rather than as a separate custom build step in Python.
      
      Reviewed By: ot
      
      Differential Revision: D6830372
      
      fbshipit-source-id: 25770676e59c8070eaef7cbb691a5ba1c4b0a8f8
      82d6df58
    • Yedidya Feldblum's avatar
      Generate format tables at compile time in C++ · 7f7abd9f
      Yedidya Feldblum authored
      Summary: [Folly] Generate format tables at compile time in C++, rather than as a separate custom build step in Python.
      
      Reviewed By: ot
      
      Differential Revision: D6829681
      
      fbshipit-source-id: 160b5a7616b015cc37ff389adabfec095cf136ec
      7f7abd9f
    • Lee Howes's avatar
      Add getVia, getTryVia and waitVia with durations to SemiFuture API. · 4950f56d
      Lee Howes authored
      Summary: Fleshes out the SemiFuture API with waiting versions of xVia calls that take a TimedDrivableExecutor that can be driven until some time point.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6658862
      
      fbshipit-source-id: 74906d8101d2a762a27da1a1ec8348f106037f5d
      4950f56d
    • Yedidya Feldblum's avatar
      Use invoke in applyTuple implementation · ad1abbab
      Yedidya Feldblum authored
      Summary:
      [Folly] Use `invoke` in `applyTuple` implementation.
      
      V.s. reimplementing `invoke` as `makeCallable`
      
      Reviewed By: spacedentist
      
      Differential Revision: D6843993
      
      fbshipit-source-id: 82f3e121486972245b75f808654d0a1299b7eafe
      ad1abbab
    • Yedidya Feldblum's avatar
      Fix missing "last-minute-reprieve" load-acquire in Baton and SaturatingSemaphore · 4bd057b2
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix missing "last-minute-reprieve" load-acquire in `Baton` and `SaturatingSemaphore`.
      
      If the CAS fails, it is because `post` with its store-release was invoked just after spinning but just before parking the thread. So the failure load needs a matching load-acquire.
      
      We cannot actually move the load-acquire into the CAS until C++17, since the failure memory order must be not stronger than the success memory order until C++17. Therefore, simulate the effect with an acquire fence in the CAS failure case.
      
      The CAS success case does not need a load-acquire; there is already a load-acquire after the thread is unparked.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D6851304
      
      fbshipit-source-id: a43243ad6a35bd9a53a9d2a5958b50a6c8806419
      4bd057b2
    • Joe Loser's avatar
      wrap CMAKE_CXX_FLAGS_COMMON arguments using strings · 7052c751
      Joe Loser authored
      Summary:
      It can be dangerous to set a CMake variable and not wrap the values as strings at times. The arguments can be forwarded to the compiler in use which will not know how to handle multiple arguments getting treated as one. For an example error using CMake 3.9.6 and Clang 5.0.1, if you do not wrap `CMAKE_CXX_FLAGS_COMMON` using string literals, you will get an error:
      
      ```
      Problems were encountered while collecting compiler information:
      	clang-5.0: error: unknown argument: '-g;-Wall;-Wextra'
      ```
      
      Closes https://github.com/facebook/folly/pull/746
      
      Reviewed By: simpkins
      
      Differential Revision: D6854510
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: c3ae626033e6733d0ce6f19fc6c06190315bf0db
      7052c751
    • Yedidya Feldblum's avatar
      make_array_with, for making std::array given size and item ctor · 11e1b8ad
      Yedidya Feldblum authored
      Summary: [Folly] `make_array_with`, for making `std::array` given size and item ctor
      
      Reviewed By: ot
      
      Differential Revision: D6831280
      
      fbshipit-source-id: 448bbf4843ffa70324f1a1d2d9e2790dc296548d
      11e1b8ad
    • Patryk Zaryjewski's avatar
      Fix flaky test. · 28962b90
      Patryk Zaryjewski authored
      Summary: Flakyness was caused by a small chance that the function would still be in the heap when adding a function. Increased delay to 3 seconds.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6855408
      
      fbshipit-source-id: 47d4035698a5d14a7ed71902656210f0e17b0b5d
      28962b90
    • Maged Michael's avatar
      hazptr: add checks for double retire in non-debug modes · 0e60f61d
      Maged Michael authored
      Summary: Add steps to hazptr_obj construction and retirement to catch misuse bugs such as double retire.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6851965
      
      fbshipit-source-id: 026e578b595792e3118b6b4b9a22c8c1dce6acba
      0e60f61d
    • Lee Howes's avatar
      Drain TimedDrivableExecutor on destruction to correctly clean up future chains. · 26276668
      Lee Howes authored
      Summary: In future chains destruction of the future then the promise will cause an exception to propagate. If all the work builds up in the executor and the executor does not drain then the exception does not propagate.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6837229
      
      fbshipit-source-id: 095650b8aae0de4ddbe86c044d78a6fac45f9c46
      26276668
    • Adam Simpkins's avatar
      make the SKIP() macro report tests as successful · 2e6097a3
      Adam Simpkins authored
      Summary:
      The googletest framework does not have a built-in mechanism for skipping tests
      at run-time.  Folly uses a `SKIP()` macro for some tests to report themselves
      as skipped.  For our internal builds these are reported as failures with a
      special message that gets handled by our test runner framework.  However for
      open source builds it is better to report these tests as passing rather than as
      failing.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6843331
      
      fbshipit-source-id: f74f29354305703448e5757ddc0ec3e72380a8f7
      2e6097a3
    • Yedidya Feldblum's avatar
      Revert D6851455: [folly][PR] Add missing override for adjacent_tokens_only · 9cdeafc3
      Yedidya Feldblum authored
      Summary:
      This reverts commit 5ad448f0aad8f51f4328bfe9af37d63023089e88
      
      bypass-lint
      
      An infra SEV is better than not reverting this diff.
      If you copy this password, see you in SEV Review!
      cause_a_sev_many_files
      
      Differential Revision: D6851455
      
      fbshipit-source-id: d96ac9c2f907f09a4086ccf65ec4a3ef47cad205
      9cdeafc3
    • Yedidya Feldblum's avatar
      Fix when the Timekeeper is destroyed with in-flight delays · e45360b5
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix when the Timekeeper is destroyed with in-flight delays.
      
      Previously, the Timekeeper dtor would immediately trigger the delayed callbacks early with a success result. But there are various situations where that is wrong behavior, such as when the callback enqueues more delayed callbacks in the success path. Higher-level, a future returned by `Timekeeper::after` or `sleep` would be completed early with a value.
      
      Now, let it immediately trigger the delayed callbacks early with an error result. Higher-level, a future returned by `Timekeeper::after` or `sleep` will be completed early with an error.
      
      Also: use `NoTimeout` consistently, and, on interrupt, pass the interrupt exception through.
      
      Differential Revision: D6837669
      
      fbshipit-source-id: 7d18d7f57999d56bbb5269cacdb443ac22448cf0
      e45360b5
    • Yedidya Feldblum's avatar
      Be more explicit about exceptions in ThreadWheelTimekeeper · e7c9b18f
      Yedidya Feldblum authored
      Summary: [Folly] Be more explicit about exceptions in `ThreadWheelTimekeeper`.
      
      Differential Revision: D6842211
      
      fbshipit-source-id: 9ef9c7149b610bbad76a08ef771aa13870d4467f
      e7c9b18f
    • Yedidya Feldblum's avatar
      When invoking stealPromise, capture the result · cd964941
      Yedidya Feldblum authored
      Summary: [Folly] When invoking `stealPromise`, capture the result.
      
      Differential Revision: D6842173
      
      fbshipit-source-id: 517a88744ecaff660f0e6615af541211018fa690
      cd964941
    • Yedidya Feldblum's avatar
      Use stealPromise v.s. releasePromise in ThreadedWheelTimekeeper · b59a7617
      Yedidya Feldblum authored
      Summary:
      [Folly] Use `stealPromise` v.s. `releasePromise` in `ThreadedWheelTimekeeper`.
      
      This makes it easier to to combine working with the promise with releasing the promise.
      
      Differential Revision: D6842090
      
      fbshipit-source-id: ff3859ed25c1d2a779068603109d1fc801771377
      b59a7617
    • Adam Simpkins's avatar
      skip AsyncSocketTest.ConnectTimeout if the address is unreachable · a4290316
      Adam Simpkins authored
      Summary:
      The code in AsyncSocketTest.ConnectTimeout attempts to pick an IP address to
      connect to that will time out rather than failing immediately.  It checks to
      see if IPv4 or IPv6 is available, but it cannot easily check if routes are
      available.  If IPv6 is available but no routes are configured it will use IPv6,
      and then the connect attempt will fail immediately rather than timing out.
      
      This changes the test to simply report itself as skipped in this case rather
      than failing.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6843332
      
      fbshipit-source-id: 02ef3dd42f1d4b6e35edfe93b2e5e42c6666fa52
      a4290316
    • Adam Simpkins's avatar
      cmake: mark the xlog tests as BROKEN · 600568ee
      Adam Simpkins authored
      Summary:
      The xlog test currently fails due to the way that CMake invokes the compiler
      with absolute path names.  In the future we should probably update the xlog
      code with the ability to strip off some directory prefixes.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6817547
      
      fbshipit-source-id: 40f08d56d0199c21808a4046ebc1a3a9d70a33e9
      600568ee
  4. 30 Jan, 2018 2 commits
    • Adam Simpkins's avatar
      fix buffer math in AsyncSocketTest.WriteErrorCallbackBytesWritten · 71dafdce
      Adam Simpkins authored
      Summary:
      The logic in `AsyncSocketTest.WriteErrorCallbackBytesWritten` relied on overly
      strict assumptions about how socket buffering would be implemented by the
      kernel.  The tests would fail spuriously if the kernel allowed more data to be
      buffered than the test assumed.
      
      This updates the tests to send more data and allow the kernel to buffer more
      data than it initially expects.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6843330
      
      fbshipit-source-id: a53e19028d50c5d646654e67518a80d6b68106a2
      71dafdce
    • Joe Loser's avatar
      Add missing override for adjacent_tokens_only · 1e36e866
      Joe Loser authored
      Summary:
      The UNIX builds treat all warnings as errors, and this missing `override` keyword causes a warning which is then a hard error in the build. In Boost 1.59 and later, `Boost.ProgramOptions` provides a virtual method `adjacent_tokens_only()` which the class `GFlagValueSemanticBase` wants to override. As such, mark it using `override`.
      Closes https://github.com/facebook/folly/pull/743
      
      Differential Revision: D6851455
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 5ad448f0aad8f51f4328bfe9af37d63023089e88
      1e36e866