1. 31 Jan, 2018 19 commits
    • 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
  2. 30 Jan, 2018 11 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
    • Adam Simpkins's avatar
      update OpenSSLPortabilityTest to work with old OpenSSL versions · f2ad762c
      Adam Simpkins authored
      Summary:
      Update OpenSSLPortabilityTest to work with older OpenSSL versions that do not
      have the ASN1_TIME_diff() function.
      
      Reviewed By: anirudhvr
      
      Differential Revision: D6843333
      
      fbshipit-source-id: 1d9cb104676296170df28fda9285c76680f8ef92
      f2ad762c
    • Adam Simpkins's avatar
      fix NpnTestNoOverlap SSL test with OpenSSL 1.0.2g · bfed8ebb
      Adam Simpkins authored
      Summary:
      Update NextProtocolTest.NpnTestNoOverlap to work with OpenSSL 1.0.2g.
      The test previously had a comment explicitly indicating that it did not work
      with this version of OpenSSL.
      
      Reviewed By: anirudhvr
      
      Differential Revision: D6843334
      
      fbshipit-source-id: 2c179597e5b48b5284601ca84299da8b9a9c0e62
      bfed8ebb
    • Lee Howes's avatar
      Make DrivableExecutor::drive and decendents noexcept. · aaf79543
      Lee Howes authored
      Summary: Added noexcept to drive functionality of executors as exceptions should not be leaking from these operations.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6846415
      
      fbshipit-source-id: 569819ef94d28c9c8c060cc8015247c416b8ab45
      aaf79543
    • Patryk Zaryjewski's avatar
      Fix FunctionScheduler::resetFunctionTimer · 10f39e11
      Patryk Zaryjewski authored
      Summary: Keeping moved out functions on the heap leads to segfaults. Let's fix that by calling make_heap each time we need to update. We will regress resetFunctionTimer complexity to O(n), which is exactly what it was before D5668557.
      
      Reviewed By: simpkins
      
      Differential Revision: D6822488
      
      fbshipit-source-id: 94f75789b01ff85e2df271822b767160285462c3
      10f39e11
    • Adam Simpkins's avatar
      fix flaky time handling and other issues in EventBaseTest.IdleTime · e3fd8c27
      Adam Simpkins authored
      Summary:
      Update EventBaseTest.IdleTime() to drive the loop once before starting the bulk
      of the test logic.  This triggers the initial NotificationQueue callbacks which
      can otherwise slow down the test slightly and make it more prone to failing due
      to not accounting for the time required for these callbacks.
      
      Also replace `ASSERT_*()` checks inside a lambda with `EXPECT_*()`.
      The googletest `ASSERT_*()` macros only work directly inside the main test
      function, as they `return` from the current function.  When used inside the
      lambda these skip the remainder of the lambda but continue running the
      remainder of the test checks, which causes incorrect failures.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6843335
      
      fbshipit-source-id: 879901edb6e5a5a84736705fb2d1cb8d2e0cc252
      e3fd8c27
    • Adam Simpkins's avatar
      Include fbcode_builder sources in the folly github repository · a54dfc73
      Adam Simpkins authored
      Summary:
      Include the fbcode_builder sources in the folly repository under
      build/fbcode_builder/.  These build scripts will make it easier. to set
      up continuous integration for the opensource github repository.
      
      Note that for folly this is potentially slightly confusing, since this
      will now add a top-level build directory in addition to the existing
      folly/build subdirectory.  However, it seems easiest for now to follow
      the default fbcode_builder conventions.
      
      This does not yet include configuration files for the folly build--I
      will add those in a subsequent diff.
      
      Test Plan:
      Confirmed the CI build work with the upcoming configuration files.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6700052
      
      fbshipit-source-id: ba026835e866bda5eed0776ec8bbf1ac51014034
      a54dfc73
    • Joe Loser's avatar
      cmake: add config check for openmp support · e8696645
      Joe Loser authored
      Summary:
      Some compilers such as Apple Clang do not support the compiler flag `-fopenmp`. So, do not add it by default to the list of `CXX_FLAGS` that are expected for *every* compiler to support. Instead, check if the `CXX_COMPILER` specified by `CMake` supports `-fopenmp` by using `CHECK_CXX_COMPILER_FLAG`.
      Closes https://github.com/facebook/folly/pull/741
      
      Reviewed By: simpkins
      
      Differential Revision: D6843171
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 671958d867400b5802d7d563036639d61d11f615
      e8696645
    • Adam Simpkins's avatar
      support CMake versions back to 3.0.2 · b1646f92
      Adam Simpkins authored
      Summary: Update CMakeLists.txt to support CMake versions as old as 3.0.2.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6843104
      
      fbshipit-source-id: 43c2fc685c63df373ed33183f8144de779c97edf
      b1646f92
    • Jason Rahman's avatar
      Correctly propagate cancellations through within() · ca0f799d
      Jason Rahman authored
      Summary:
      Within() is not properly propegating cancellations and other
      interrupts via raise() since it technically breaks the normal propegation
      mechnaism of copying the interrupt handler pointer.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6838285
      
      fbshipit-source-id: 8f3efbd3eebe21c2f348b6aba991b0997be4f14f
      ca0f799d
  3. 29 Jan, 2018 4 commits
    • Yedidya Feldblum's avatar
      Move folly/PicoSpinLock.h to folly/synchronization/ · 65215eed
      Yedidya Feldblum authored
      Summary: [Folly] Move `folly/PicoSpinLock.h` to `folly/synchronization/`.
      
      Differential Revision: D6830101
      
      fbshipit-source-id: 529df14d9cda46bae5989f901ca73effbe0022e5
      65215eed
    • Yedidya Feldblum's avatar
      Fixed initialization of Tearable with libstdc++-v4.9.2 · bd7e8c04
      Yedidya Feldblum authored
      Summary: [Folly] Fixed initialization of `Tearable` with libstdc++-v4.9.2, which is missing definitions of `atomic_init`.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D6833004
      
      fbshipit-source-id: 88d4cc91f90618a98df110bec5e434c35e750b16
      bd7e8c04
    • Adam Simpkins's avatar
      fix SingletonTestGlobal in shared library builds · 137443e8
      Adam Simpkins authored
      Summary:
      The SingletonTestGlobal code asserted that there was exactly one singleton
      object registered (the one defined in this test file).  However if folly is
      built as a shared library, all of it will be loaded, and several other
      singletons are also defined by other parts of folly.  (Currently 7 singletons
      get registered.)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6817544
      
      fbshipit-source-id: de3947770690ffb68d097040bbbfbe42bce3bf94
      137443e8
    • Neel Goyal's avatar
      Add more types to OpenSSLPtrTypes · b60217fa
      Neel Goyal authored
      Summary: Add more types and a macro to make defining them easier.
      
      Reviewed By: mingtaoy
      
      Differential Revision: D6823450
      
      fbshipit-source-id: eb13a8b48efb1625fc3f8035356812f918703c6d
      b60217fa
  4. 28 Jan, 2018 1 commit
    • Lee Howes's avatar
      HAS_FEATURE fix · 543aa5ca
      Lee Howes authored
      Summary: Foolishly #defined __has_feature when it wasn't and let it leak, but something later must have been relying on something similar. This replaces the uses with FOLLY_HAS_FEATURE.
      
      Reviewed By: yfeldblum, magedm
      
      Differential Revision: D6829724
      
      fbshipit-source-id: 40635dd67135316f27be2aa2a6b2d579dbf843e1
      543aa5ca
  5. 27 Jan, 2018 3 commits
    • Lee Howes's avatar
      Disable thread caching (and hence TLS) on mobile hazptr builds. · dc96624a
      Lee Howes authored
      Summary: thread_local does not work on certain mobile builds. This will disable it if FOLLY_MOBILE is set.
      
      Reviewed By: yfeldblum, magedm
      
      Differential Revision: D6785773
      
      fbshipit-source-id: 6a74edec739f42562045aadb4e1ee39d121ce90d
      dc96624a
    • Teng Qin's avatar
      Add Semaphore support for folly's Static Tracepoint · cfaf60f0
      Teng Qin authored
      Summary:
      This Diff adds new `FOLLY_SDT_WITH_SEMAPHORE` Macro that allows the (potentially expensive) Static Tracepoints be gated with Semaphore and be enabled on-demand.
      The Semaphores are compatible with SystemTap's Tracepoint Semaphores, with the following difference:
      - Instead of having build Process generate a header file containing the Semaphore variable and check function, and to be included, this Diff uses the approach that users need to explicitly define the semaphore using `FOLLY_SDT_SEMAPHORE_DEFINE` before using `FOLLY_SDT_WITH_SEMAPHORE`. Then the check function could be used in the same file, or in any other linked module with doing `FOLLY_SDT_SEMAPHORE_DECLARE` first. This is inspired from GFlag's defining and declaring.
      - We keep allowing original `FOLLY_SDT` with no Semaphore for flexibility.
      
      Differential Revision: D6814268
      
      fbshipit-source-id: e1e4463c71539b4d2071b21880d4ee7689fedce8
      cfaf60f0
    • Xiao Shi's avatar
      mark constexpr member function const to be forward compatible. · 24d7e260
      Xiao Shi authored
      Summary:
      Since C++14, constexpr non-static member function will not be implicitly marked
      const. See the blog post below for more details.
      https://akrzemi1.wordpress.com/2013/06/20/constexpr-function-is-not-const/
      
      Reviewed By: mzlee
      
      Differential Revision: D6819658
      
      fbshipit-source-id: 4a756191fca3e744bda3c63c2669e24d6b16861e
      24d7e260
  6. 26 Jan, 2018 2 commits