1. 07 Mar, 2018 6 commits
    • Adam Simpkins's avatar
      logging: add a LoggerDB::getFullConfig() method · c5724761
      Adam Simpkins authored
      Summary:
      This method can be used to get configuration about all currently defined log
      categories, including ones that are using the default config settings.
      
      The existing LoggerDB::getConfig() method only returns information about
      categories that have non-default config settings.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7164833
      
      fbshipit-source-id: e1c043553dc4f69be58c33f2bc5b1a63763f0984
      c5724761
    • Qinfan Wu's avatar
      Suppress deprecation warning in Promise.h · d8345822
      Qinfan Wu authored
      Summary:
      [Folly][coro] Suppress deprecation warning in `Promise.h`.
      
      `Try(std::exception_ptr ep)` is deprecated. The underlying behavior doesn't improve much with this diff. But there would be a whole lot of warnings once `Promise.h` gets included by more files.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D7178381
      
      fbshipit-source-id: 9f45706283a5aaa436cbab3e7b02e085bdc8c792
      d8345822
    • Qinfan Wu's avatar
      Let all Promise<T> be friend of Task · c39b0c3b
      Qinfan Wu authored
      Summary:
      [Folly][coro] Let all `Promise<T>` be friend of `Task`.
      
      The code would not compile:
      
      ```lang=c++
      coro::Task<void> taskVoid() {
        co_await task42();
        co_return;
      }
      ```
      
      ```
      folly/experimental/coro/Promise.h:84:28: error: 'viaInline' is a private member of 'folly::coro::Task<int>'
          return std::move(task).viaInline(executor_);
                                 ^
      folly/experimental/coro/tests/CoroTest.cpp:40:3: note: in instantiation of function template specialization 'folly::coro::Promise<void>::await_transform<int>' requested here
        co_await task42();
        ^
      folly/experimental/coro/Task.h:60:13: note: declared private here
        Future<T> viaInline(folly::Executor* executor) && {
                  ^
      ```
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D7178238
      
      fbshipit-source-id: 7dca6834ac56f4c9bdb4d702996b51e932f2aae6
      c39b0c3b
    • Adam Simpkins's avatar
      logging: move test utility functions into a helper module · d455cfc4
      Adam Simpkins authored
      Summary:
      Move some utility functions from ConfigParserTest and ConfigUpdateTest into a
      new ConfigHelpers module.  This eliminates some duplicated logic and will make
      it easier to re-use these functions in other tests in the future.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7164831
      
      fbshipit-source-id: 115a227e4cb2db486f57079483b8ae9aadaa0187
      d455cfc4
    • Adam Simpkins's avatar
      define FOLLY_ATTR_WEAK in CPortability.h · bfe2b889
      Adam Simpkins authored
      Summary:
      Define a FOLLY_ATTR_WEAK helper macro in CPortability.h, and update existing
      code in folly that declares functions as weak to use this new macro.  This will
      make it easier to declare weak functions in other files in the future.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7164834
      
      fbshipit-source-id: 87e03401400f2912fcd5e719af0d667251cd642b
      bfe2b889
    • Adam Simpkins's avatar
      cmake: define interface include directories · bf255392
      Adam Simpkins authored
      Summary:
      Define interface include directories for the folly target.
      
      This lets downstream dependencies of folly list Folly::folly in
      target_link_libraries() and have the correct include directories be
      added automatically.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7162335
      
      fbshipit-source-id: 2a6aad57142e038450fd35a94446f5b865029155
      bf255392
  2. 06 Mar, 2018 8 commits
    • Neel Goyal's avatar
      free up existing session in setSSLSession · 853e5e42
      Neel Goyal authored
      Summary: Free up the session if its not null before assigning a new one
      
      Reviewed By: shamdor-fb
      
      Differential Revision: D7169809
      
      fbshipit-source-id: fd026e8688525a764b9937c7f4b7bfb0cdece9eb
      853e5e42
    • Lee Howes's avatar
      toUnsafeFuture to avoid propagating InlineExecutor through caller code during transition. · 634c47ea
      Lee Howes authored
      Summary: toUnsafeFuture is intended to return a future that is the same as .via(&folly::InlineExecutor::instance()) without propagating InlineExecutor throughout future-using code during a transition to SemiFuture. This will highlight call sites better and encourage either fixing, or making clear that this non-deterministic behaviour is the intent.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7162989
      
      fbshipit-source-id: c7092a53560e05d463d9170be254a50d23cc6ef7
      634c47ea
    • Mark Williams's avatar
      Fix a GuardPageAllocator range check · 7e012aea
      Mark Williams authored
      Summary:
      The range check to identify its "own" memory could inadvertently pick
      up an allocation from outside the range, resulting in an alignment
      assertion later on, and causing us to permanently leak the memory
      (when assertions are disabled).
      
      Reviewed By: alikhtarov, andriigrynenko
      
      Differential Revision: D7146394
      
      fbshipit-source-id: d9d8b63eea1ffa045e1bd07c0258d1f2b089e9bf
      7e012aea
    • Lee Howes's avatar
      Remove Promise::getFuture from Future-inl.h 4/4 - window · 5b1c46fb
      Lee Howes authored
      Summary: Modify folly::window to replace Promise::getFuture calls with Promise::getSemiFuture. The requirement for an executor on the semifuture here meant that I had to modify all of the SemiFutures with an executor in the vector. This may come with a small performance hit in some cases, but appears to be behaviourally better.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7104920
      
      fbshipit-source-id: 7d105df553c28bb362b37ff64270ee16bf59fbd6
      5b1c46fb
    • Lee Howes's avatar
      Ensure that SemiFuture executor is correctly chained to deal with deferred work. · 9af220fa
      Lee Howes authored
      Summary: There was previously a bug in that defer used within a continuation would not correctly chain the deferred executor on the executor in the returned (and hence in the original) folly::Future like it would when .via was called on a SemiFuture. This fixes that situation by returning a semifuture from a continuation by correctly chaining it onto the outer future's executor.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7156241
      
      fbshipit-source-id: ed6db3ad0de7a921b72459fcd2b1228114832853
      9af220fa
    • Lee Howes's avatar
      Add getSemiFuture and storage of executor to FutureSplitter so that returned... · e0d04ed7
      Lee Howes authored
      Add getSemiFuture and storage of executor to FutureSplitter so that returned future completes on the expected executor.
      
      Summary:
      Remove calls to Promise::getFuture in FutureSplitter test.
      
      Add getSemiFuture to FutureSplitter for consistency with Promise.
      
      Keep getFuture method but ensure that it completes on the same executor as the input future (or Inline if the executor on the input future was null, due to legacy code).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7105806
      
      fbshipit-source-id: 63a919ba9dcf0f189782a3e2a362fad4d86ac91f
      e0d04ed7
    • Yedidya Feldblum's avatar
      Fix waiting in Baton, SaturatingSemaphore · f0d42801
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix waiting in `Baton`, `SaturatingSemaphore`.
      
      If condition passes or overall deadline expires, just return. If only a component timeout expires, continue on to the next component.
      
      Reviewed By: magedm
      
      Differential Revision: D7151564
      
      fbshipit-source-id: 48c33ccc6970604b23221bc94af247945bdc34e5
      f0d42801
    • Lee Howes's avatar
      Remove Promise::getFuture from Future-inl.h 3/4 - onError · af978f69
      Lee Howes authored
      Summary: Replaces calls to Promise::getFuture in onError calls. Modifies the returned future to complete on the same executor as the caller. No assumption that the future already has an executor (though it should in principle, the codebase is not ready for that yet).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7104850
      
      fbshipit-source-id: ea152102f8ecd612e322b98a54d9440495b14bf8
      af978f69
  3. 05 Mar, 2018 7 commits
    • Igor Sugak's avatar
      fix invalid-null-argument UBSAN error in IOBufQueue.cpp · c3a1cd78
      Igor Sugak authored
      Summary:
      UndefinedBehaviorSanitizer: invalid-null-argument folly/io/IOBufQueue.cpp:53:38
      ```
      
      Add a check that the length is greater than zero.
      
      Reviewed By: meyering
      
      Differential Revision: D7139027
      
      fbshipit-source-id: 37585092429af52d14c98c193ecc495752bbda1c
      c3a1cd78
    • Andrii Grynenko's avatar
      Basic coroutine library · 2b4a5c9a
      Andrii Grynenko authored
      Summary: This implements Executor-aware coroutine library.
      
      Reviewed By: wqfish
      
      Differential Revision: D7133189
      
      fbshipit-source-id: 43022e0b4a44378dae670720d8144f2e042f1a54
      2b4a5c9a
    • Gustavo Stor's avatar
      Fix cUnescape for non-strict cases · 8a515308
      Gustavo Stor authored
      Summary: Strings terminating in a backslash shouldn't throw if strict is set to false. However, the default implementation results in an undefined behavior, since the iterator goes beyond the end position of the string.
      
      Reviewed By: simpkins
      
      Differential Revision: D7123155
      
      fbshipit-source-id: 4311037ccdbfd95f402109dcc1b5862e52fb97a1
      8a515308
    • Yedidya Feldblum's avatar
      Fix waiting in UnboundedQueue · 32f91898
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix waiting in `UnboundedQueue::dequeue` suite.
      
      `SaturatingSemaphore::try_wait_until` does not return early with the result `false`, so the loop could result in incorrect long waits.
      
      Reviewed By: magedm
      
      Differential Revision: D7151562
      
      fbshipit-source-id: cd90583f0b4520464ed1877df8396df43ebbef00
      32f91898
    • Yedidya Feldblum's avatar
      Simplify MemoryIdler pre-idle check · c027cddd
      Yedidya Feldblum authored
      Summary: [Folly] Simplify `MemoryIdler` pre-idle check.
      
      Reviewed By: magedm
      
      Differential Revision: D7151565
      
      fbshipit-source-id: 34ae69f16439640669cd9aaf02a09282a1a1cc3f
      c027cddd
    • Yedidya Feldblum's avatar
      An extra deadline check in DynamicBoundedQueue enqueue path · c8be0173
      Yedidya Feldblum authored
      Summary: [Folly] An extra deadline check in `DynamicBoundedQueue` enqueue path just for completeness.
      
      Reviewed By: magedm
      
      Differential Revision: D7151563
      
      fbshipit-source-id: 2d6abd906091db20a650d0f3120bf4b1d8bcf00c
      c8be0173
    • Yedidya Feldblum's avatar
      Move folly/MicroSpinLock.h to folly/synchronization/ · d5dd5107
      Yedidya Feldblum authored
      Reviewed By: igorsugak
      
      Differential Revision: D7078903
      
      fbshipit-source-id: 13cdc49369f24cdadc3f9405d1ce609a79ff8988
      d5dd5107
  4. 04 Mar, 2018 1 commit
    • Xiao Shi's avatar
      add std::list/deque, small_vector to fbvector benchmark · 306be9f1
      Xiao Shi authored
      Summary:
      Adding a few other data structures to the benchmark. Code clean-up:
      * split `insert` into `insertFront` and `pushBack`
      * delete current `erase` benchmark, which is mostly spinning since `iters` can
        easily be larger than the original vector size.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7067000
      
      fbshipit-source-id: 3073f7c396888787b49993468c7e6fdac70b77ac
      306be9f1
  5. 03 Mar, 2018 3 commits
    • Yedidya Feldblum's avatar
      Remove the spin-lock protecting Future's executor · f9fb46d1
      Yedidya Feldblum authored
      Summary:
      [Folly] Remove the spin-lock protecting `Future`'s executor.
      
      The executor can be set in a few places:
      * When constructing a new `Promise` and `Future` pair before handing off the `Promise` in `Future::thenImplementation`.
      * After invoking `SemiFuture::wait` and `Future::wait` in the non-timeout case.
      * In `SemiFuture` dtor, if it has a core.
      
      In the first case, the executor is set in the future thread before being read by the promise thread. In the second case, the executor is set after being read by the promise thread. In the third case, if there is a core, then no callback could have been attached. But there is no race between setting and reading.
      
      Reviewed By: djwatson
      
      Differential Revision: D7115700
      
      fbshipit-source-id: 5a0f90a9f01a7dcf295f39d323959e91aeae26da
      f9fb46d1
    • Andrii Grynenko's avatar
      Revert D7130814: [folly] Always suspend coroutine before destruction · fa45ee46
      Andrii Grynenko authored
      Summary:
      This reverts commit bf3e2b8f4a086f1786ab46f453c3dd9171d018e8
      
      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:
      D7130814
      
      Original commit changeset: bf3e2b8f4a08
      
      fbshipit-source-id: 8f67c9ec365853f8fbc736e0fd29133fd7653a59
      fa45ee46
    • Xiao Shi's avatar
      fix HAVE_INT128_TRAITS cmake test · 49efc3ab
      Xiao Shi authored
      Summary:
      C++17 defined integer traits for `__int128` as well as a (trivial) std::hash,
      this diff adds the check in `FOLLY_SUPPLY_MISSING_INT128_TRAITS`.
      
      There was an unintended linebreak in the cmake test which rendered it non
      functional. This diff fixes it.
      
      Original issue:
      https://github.com/facebook/folly/commit/b2b96f59c57cd7aba686cc4f61ceba0314cdeb72#comments
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7138006
      
      fbshipit-source-id: ca1841b9ca847f1f6570b58e95380f50fe092345
      49efc3ab
  6. 02 Mar, 2018 6 commits
    • Giuseppe Ottaviano's avatar
      Fix bounds check in fbstring::at · 8e458f98
      Giuseppe Ottaviano authored
      Summary:
      From http://en.cppreference.com/w/cpp/string/basic_string/at
      
      > Throws std::out_of_range if pos >= size().
      
      Furthermore it was inconsistent between the `const` and non-`const` version.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: philippv, luciang
      
      Differential Revision: D6355911
      
      fbshipit-source-id: 54acbba791fc5a8aeb4fdf46e786f8519fd18701
      8e458f98
    • Lee Howes's avatar
      Remove Promise::getFuture from Future-inl.h 2/4 - waitImpl · 6afcbf48
      Lee Howes authored
      Summary: Replace calls to Promise::getFuture in waitImpl with getSemiFuture. There is a slight behavioural change here in that we now set the executor on the returned future, but this appears to be the correct behaviour.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7104627
      
      fbshipit-source-id: fd19c3f6884b560f7d5ea1276f3c80c082dfc53d
      6afcbf48
    • Nathan Bronson's avatar
      add comment to help people debugging an assertion failure · a440441d
      Nathan Bronson authored
      Summary:
      SharedMutex asserts that all locks have been released before
      destruction.  This diff adds a comment near those asserts making it more
      clear what they are checking.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7137906
      
      fbshipit-source-id: 082a804616950d9a962ee932c9021c453f43a35d
      a440441d
    • Brian Gesiak's avatar
      Always suspend coroutine before destruction · 57c236fe
      Brian Gesiak authored
      Summary:
      Suspending the coroutine before it's destroyed prevents a dangling
      reference to its value.
      
      This dangling reference is exposed when running tests that were
      built with `-O3` with ASAN. To run tests at this level, split the
      tests up: move tests that cannot be compiled with ASAN at `-O3`,
      due to https://bugs.llvm.org/show_bug.cgi?id=34289, into their
      own file. The remaining tests stay where they are, with `-O3`
      re-enabled.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7130814
      
      fbshipit-source-id: bf3e2b8f4a086f1786ab46f453c3dd9171d018e8
      57c236fe
    • Boris Momčilović's avatar
      CMake: folly-deps: gflags is gflags-shared on Fedora #753 · 42ee21f1
      Boris Momčilović authored
      Summary:
      This targets Fedora specifically. More details are available in #753
      
      I personally do not think this is the best way to handle this, but it's something (and works). Still, there might be a chance for this to get merged in? Thank you!
      
      /cc yfeldblum
      Closes https://github.com/facebook/folly/pull/789
      
      Reviewed By: simpkins
      
      Differential Revision: D7111531
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 508aeeeb7bfaf2402150cd33f7d6c8b726539053
      42ee21f1
    • Dan Melnic's avatar
      CHECK(ev->ev_base) so we get a proper message instead of just a SIGSEGV · 43e42d0c
      Dan Melnic authored
      Summary: CHECK(ev->ev_base) so we get a proper message instead of just a SIGSEGV
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7118625
      
      fbshipit-source-id: 9426ac54fc32e0d34ad36df97708e3f0ae6043a9
      43e42d0c
  7. 01 Mar, 2018 9 commits
    • Adam Simpkins's avatar
      logging: add an FB_LOG_RAW() macro · 634f2652
      Adam Simpkins authored
      Summary:
      `FB_LOG_RAW()` is similar to `FB_LOG()` but allows the caller to pass in the
      log level as a variable, and to specify an alternate file name and line number.
      
      This is useful for callers that wish to implement their own logging utility
      functions that log a message, but pass through their caller's file name and
      line number.
      
      Reviewed By: wez
      
      Differential Revision: D7128091
      
      fbshipit-source-id: 1fec158a9312b9c9dc53cf3dc87004d42f9806c6
      634f2652
    • Xiao Shi's avatar
      add hashers for __int128 and unsigned __int128 · b2b96f59
      Xiao Shi authored
      Summary: Add hashers for signed and unsigned int128 for platforms that have them.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7101875
      
      fbshipit-source-id: ab5df6d06c7f292204318e479d172560ae2a4ec6
      b2b96f59
    • Xiao Shi's avatar
      adjust config for FOLLY_SUPPLY_MISSING_INT128_TRAITS · b4881fa5
      Xiao Shi authored
      Summary:
      * remove the redundant `!defined(_WIN32)` condition;
      * llvm added traits for (u)int128 in
        https://reviews.llvm.org/D2917; and std::hash in
        https://reviews.llvm.org/rL266587.
      
      Reviewed By: nbronson
      
      Differential Revision: D7111138
      
      fbshipit-source-id: 91a05354846575677eddd48c8b8f4e05c53b01cb
      b4881fa5
    • Ian Petersen's avatar
      Remove some undefined behaviour from const Lazy. · 6229600d
      Ian Petersen authored
      Summary:
      operator()() const uses const_cast to forward its implementation
      to operator()(), which invokes UB when writing to the internal state.
      This change marks the internal state mutable, which means we can delete
      the const_cast.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7089568
      
      fbshipit-source-id: 09f726e6399a95987075d6170ce6fb8103189552
      6229600d
    • Amir Livneh's avatar
      Add compatibility function for X509_STORE_up_ref() · 35970f56
      Amir Livneh authored
      Reviewed By: yfeldblum
      
      Differential Revision: D7111876
      
      fbshipit-source-id: eba9e29321e0ac89084ceae410bdcb4ebb86f91c
      35970f56
    • Yedidya Feldblum's avatar
      Switch away from using the legacy Synchronized macros · 65105e81
      Yedidya Feldblum authored
      Summary: [Folly] Switch away from using the legacy `Synchronized` macros within Folly.
      
      Reviewed By: simpkins
      
      Differential Revision: D7118324
      
      fbshipit-source-id: 328ecdd572d84bb99a28ddb8689bdc4ae08421a6
      65105e81
    • Yedidya Feldblum's avatar
      Cut build config items for bits/functexcept.h · 2d40a641
      Yedidya Feldblum authored
      Summary:
      [Folly] Cut build config items for `bits/functexcept.h`.
      
      Folly no longer uses the non-portable functions declared in that internal libstdc++ header.
      
      Reviewed By: mzlee
      
      Differential Revision: D7119064
      
      fbshipit-source-id: 6879dc6a5bc490726b188d65d7686a2eca136980
      2d40a641
    • Lee Howes's avatar
      Remove Promise::getFuture from Future-inl.h 1/4 - simple cases · 8e00d117
      Lee Howes authored
      Summary:
      Removing calls to folly::Promise::getFuture from Future-inl.h's simpler cases. Replacing with getSemiFuture.
      
      In the case of the collect variants I continue to return a Future, completing inline, until those functions are modified to return SemiFuture.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7103938
      
      fbshipit-source-id: 3737887a934cd0fe8f7c1511ae2ba252ea047a49
      8e00d117
    • Joe Loser's avatar
      Fix unused variable error in AsyncUDPSocket · 4503a319
      Joe Loser authored
      Summary:
      Some OSes do not define `IP_MTU_DISCOVER` or `IPV6_MTU_DISCOVER`. As such, this would result in the function argument parameter `df` being unused, which is a warning that is then treated as an error.
      
      Earlier today (2806dda4), this logic was added about setting the DF which broke Mac builds.
      Closes https://github.com/facebook/folly/pull/791
      
      Reviewed By: igorsugak
      
      Differential Revision: D7116863
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 5092891c8977a44ab58723f8cef352dd4eaa1210
      4503a319