1. 30 Sep, 2018 2 commits
  2. 29 Sep, 2018 1 commit
    • Yedidya Feldblum's avatar
      Closer guarantee of constexpr Fingerprint tables computation · 2d042e64
      Yedidya Feldblum authored
      Summary: [Folly] Closer guarantee of `constexpr` Fingerprint tables computation. Works around a limitation that `template <...> constexpr` functions are only sometimes `constexpr` and may be non-`constexpr` for some instantiations with no warning by enforcing `constexpr` for the instantiations used.
      
      Differential Revision: D10116556
      
      fbshipit-source-id: f7014e5b2fce411c27c331874a7fd33841e14df3
      2d042e64
  3. 28 Sep, 2018 8 commits
    • Dan Melnic's avatar
      This fixes a linker issue · aa472be6
      Dan Melnic authored
      Summary: This fixes a linker issue
      
      Reviewed By: tuomaspelkonen
      
      Differential Revision: D10109866
      
      fbshipit-source-id: bf4193eafc8eb6f75b84241ff6e2ef89ef866642
      aa472be6
    • Neel Goyal's avatar
      Ensure SSL is initialized in getOpenSSLCipherNames · 4156360f
      Neel Goyal authored
      Summary: SSL_CTX_new can fail if OpenSSL is not initialized.  This ensures it is.
      
      Reviewed By: bolekk
      
      Differential Revision: D10105302
      
      fbshipit-source-id: 4da40d4714747b0e6a359a52fa594fc29bb93c0a
      4156360f
    • Andrii Grynenko's avatar
      Change makeObserver to compute the first value inline · f43ce6d6
      Andrii Grynenko authored
      Summary:
      Current thread was previously blocked waiting on the Future to be completed anyway, so there's no reason to not treat it like one of the ObserverManager threads (if it isn't one already) and run the computation inline.
      Without this change nested makeObserver calls could result in a deadlock if recursion depth was greater than the number of ObserverManager threads.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10097363
      
      fbshipit-source-id: eb781ed5aea0ad9415da40fbc7f1c15ed481e92f
      f43ce6d6
    • HC Zhu's avatar
      Allow std::ignore in split() · a7937a66
      HC Zhu authored
      Summary:
      This allows a caller to throw away unwanted parts e.g.
      
      ```
      std::string user;
      folly::split('/', "ads_lla/admarket/adfox", std::ignore, user, std::ignore);
      
      ```
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10057247
      
      fbshipit-source-id: 8198d4cb207bbd2007635db1e5796759dccf367c
      a7937a66
    • Anton Likhtarov's avatar
      Expose defaultValue() · 061ea836
      Anton Likhtarov authored
      Summary:
      SettingsMetadata provides a type-erased view, so the default value is stored as a string representation.
      This method allows getting the actual original default value.
      
      Differential Revision: D10077879
      
      fbshipit-source-id: 2c6bf15eba57da5cb33ad1c657bc9bd51bcd2946
      061ea836
    • Anton Likhtarov's avatar
      Move in global setting APIs into Snapshot · cf7517b8
      Anton Likhtarov authored
      Summary: This forces users to take a Snapshot and makes global settings updates both atomic and more explicit.
      
      Differential Revision: D10055254
      
      fbshipit-source-id: 73ce34acdadad19d5b75e74ad26f13dc7763228d
      cf7517b8
    • Anton Likhtarov's avatar
      Basic Snapshot functionality · 845a46cc
      Anton Likhtarov authored
      Summary:
      See the unit test for example usage.
      
      ```
      folly::settings::Snapshot snapshot;
      
      // Now changes to `FOLLY_SETTING(project, name)` and `snapshot(FOLLY_SETTING(project, name))`
      // are independent from each other.
      // Any updates to the settings in the snapshot can be published via snapshot.publish()
      ```
      
      Basic version with a global lock, there are ways to optimize this later.
      
      Differential Revision: D9926070
      
      fbshipit-source-id: 66ee7f28539c242a08b688eab4a18e4a42a8b0ff
      845a46cc
    • Yedidya Feldblum's avatar
      Various noexcept specifiers in IOBuf · 66a3d1c1
      Yedidya Feldblum authored
      Summary: [Folly] Various `noexcept` specifiers in `IOBuf`.
      
      Reviewed By: Orvid
      
      Differential Revision: D10081705
      
      fbshipit-source-id: 5516e7deca4edd50ea99e61e10cd413f3c0f17ae
      66a3d1c1
  4. 27 Sep, 2018 1 commit
    • Yedidya Feldblum's avatar
      Compute fingerprint tables at constexpr time · aaf9e970
      Yedidya Feldblum authored
      Summary: [Folly] Compute fingerprint tables at constexpr time, v.s. as a separate build step which generates a source file.
      
      Reviewed By: Orvid
      
      Differential Revision: D10081043
      
      fbshipit-source-id: f01f7587aafd29fc1c44515730b759325e1566d8
      aaf9e970
  5. 26 Sep, 2018 4 commits
    • Teng Qin's avatar
      ElfFile: unmap on init error · 1d10cf85
      Teng Qin authored
      Summary: Currently for `ElfFile::openNoThrow`, if `init` fails (due to mal-formatted content etc.) it won't unmap and close the file. They will only be unmapped / closed on destruction. This Diff calls `reset()` on that case.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D9997690
      
      fbshipit-source-id: c30907fb793c813a5ad40d249919dd1752a2d711
      1d10cf85
    • Jun Wu's avatar
      Use a larger stack if sigaltstack is too small · fc36aa9f
      Jun Wu authored
      Summary:
      The signal handler might use nearly 9KB stack for symbolization. That would
      cause stack overflow if the signal handler is running on a small alternative
      stack set by sigaltstack. We have seen that in Rust programs. The Rust stdlib
      sets up [8KB](https://github.com/rust-lang/libc/blob/4bd52f5e3ef5d6c8abdd1fbaf7c9975800a0dc93/src/unix/notbsd/linux/other/b64/x86_64.rs#L505) stacks [using sigaltstack](https://github.com/rust-lang/rust/blob/55b54a999bcdb0b1c1f42b6e1ae670beb0717086/src/libstd/sys/unix/stack_overflow.rs#L173) for all threads created by Rust on x64 Linux.
      
      Talked with jsgf, we'd still like to get a nice symbolized stack trace if
      segfault happens in a binary including both Rust and C++ code, since it's
      more likely the C++ part being wrong, so C++ symbol demangling is more
      important than Rust demangling.
      
      This diff detects the small sigaltstack case, then allocates larger stack for
      symbolization. Note the stack manipulation logic is not signal-safe, so it's
      not used for non-small-sigaltstack cases. Programs not using sigaltstack, or
      use sigaltstack with >9KB stacks won't be affected.
      
      As we're here, teach the signal handler to save and restore errno. Also add
      a note about golang's SA_ONSTACK requirement.
      
      Reviewed By: luciang
      
      Differential Revision: D9846902
      
      fbshipit-source-id: f0dc81b1c1249d8a724e112906e0ff0b14c14ea9
      fc36aa9f
    • Andrii Grynenko's avatar
      Possible deadlock with InlineTask and Mutex · d62c61c5
      Andrii Grynenko authored
      Summary: This demonstrates a deadlock that's possible when using InlineTask.
      
      Reviewed By: lbrandy
      
      Differential Revision: D9883432
      
      fbshipit-source-id: 45bb14181f6cfec41851315c0369232a30ba13d9
      d62c61c5
    • Neel Goyal's avatar
      Clear error stack in unsetNextProtocols · 6c70bf25
      Neel Goyal authored
      Summary:
      It seems like memdup may fail in certain builds with nullptr, 0 and cause OpenSSL to put a malloc failure on the stack.  See https://github.com/openssl/openssl/blob/master/ssl/ssl_lib.c#L2752
      
      This diff clears the error stack when we do this.
      
      Reviewed By: knekritz
      
      Differential Revision: D10037676
      
      fbshipit-source-id: ea7b136cafde818564e8ee2401f0cef30f52a45d
      6c70bf25
  6. 25 Sep, 2018 4 commits
    • Andrii Grynenko's avatar
      Add support for returning SemiFuture/Future from defer functor · 2b1e8dc5
      Andrii Grynenko authored
      Summary: Because DeferredExecutor now acts as a simple proxy to user executor, we can actually support multi-hop SemiFutures.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D9928793
      
      fbshipit-source-id: c7e030bac3582b2931bc9639c766a4398ce23a76
      2b1e8dc5
    • Amol Bhave's avatar
      use heterogenous operations for get_ptr(dynamic) · c09be5f4
      Amol Bhave authored
      Summary:
      This diff adds support for doing heterogenous lookups
      to the dynamic::get_ptr(dynamic) function.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10007208
      
      fbshipit-source-id: 2453f3fe8ab36dfd9e5627aa75cf8eb7aee51699
      c09be5f4
    • Andrii Grynenko's avatar
      Simplify DeferredExecutor · bdb2a715
      Andrii Grynenko authored
      Summary: Move the wait() and timed_wait() functionality out of DeferredExecutor. This is now possible because folly::Futures are using Executor::KeepAlive to manage executors' life-time.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D9925417
      
      fbshipit-source-id: e9818417048f44ee66648439e781060fdabca6b9
      bdb2a715
    • Alexey Kozhevnikov's avatar
      Fix futures MSVC compilation issue · e3f27085
      Alexey Kozhevnikov authored
      Summary:
      MSVC (14.12.25827, VS 2017 15.5) fails to compile with internal error when using `/std:c++14` parameter:
      ```
      Future-inl.h(1484): fatal error C1001: An internal error has occurred in the compiler.
      (compiler file 'msc1.cpp', line 1507)
       To work around this problem, try simplifying or changing the program near the locations listed above.
      ```
      
      Reviewed By: yfeldblum, Orvid
      
      Differential Revision: D10018915
      
      fbshipit-source-id: ba886265b68684aacc2bf471c79ba6c39e611c8e
      e3f27085
  7. 24 Sep, 2018 4 commits
    • Philip Pronin's avatar
      make parallel generator movable · 0964862b
      Philip Pronin authored
      Summary:
      If `Source` isn't copyable, parallel generator cannot be composed
      further due to implicitly deleted move ctor.
      
      Example:
      
      ```
      byLines(File(...))
      | parallel(map(...))
      | sum;
      ```
      
      Reviewed By: ddrcoder, ot
      
      Differential Revision: D10004477
      
      fbshipit-source-id: 51ce23e834413bd53547a683f8ed89a1811f74a2
      0964862b
    • Amol Bhave's avatar
      Fix error messages in folly/dynamic · 4ca1b685
      Amol Bhave authored
      Summary:
      Some of the error messages had the incorrect expected types.
      Fix those occurences
      
      Reviewed By: shixiao
      
      Differential Revision: D10003775
      
      fbshipit-source-id: ba8e3b7d14ee2c5442dfd24b9fbf7775d601f6f0
      4ca1b685
    • Lee Howes's avatar
      Deprecate legacy forms of Future::then · 2139ed4c
      Lee Howes authored
      Summary:
      Deprecate the legacy forms of Future::then to assist migration to thenValue and thenTry.
      
      This is part of a longer process to improve type correctness for folly::Future. By separating the forms of then we no longer have ambiguity when passing a polymorphic lambda as a continuation and can more easily tweak the implementation to modernise it.
      
      Reviewed By: yfeldblum, WillerZ
      
      Differential Revision: D9974379
      
      fbshipit-source-id: 26f986329cb5d2d33d366b8f9e7b2664656642ff
      2139ed4c
    • Amol Bhave's avatar
      Add implementation for std::hash<MacAddress> · 07f90764
      Amol Bhave authored
      Summary:
      Add implementation for std::hash<MacAddress> so that it can be used in
      maps.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10004544
      
      fbshipit-source-id: 46cb177577123b1248cd8ff679f0fbe286596819
      07f90764
  8. 22 Sep, 2018 5 commits
    • Lee Howes's avatar
      Remove .then from FutureSplitter · b7ac6b77
      Lee Howes authored
      Summary: To allow deprecation, remove use cases of Future::then inside FutureSplitter.h
      
      Reviewed By: yfeldblum
      
      Differential Revision: D9995264
      
      fbshipit-source-id: d44c63c45a08ca675b9bff33fabcbb2836ea2a64
      b7ac6b77
    • Lee Howes's avatar
      Remove thenValue from map that needs to be generic · 372025a2
      Lee Howes authored
      Summary: Went a step too far removing then from inside Future-inl.h. Map needs to be generic over value/try. Just remove that change for now.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10002565
      
      fbshipit-source-id: c37f744d47f9dd123114b6b62c1c832519cb4f8e
      372025a2
    • Yedidya Feldblum's avatar
      A faster empty() shortcut in IOBufCompare · ac009d2f
      Yedidya Feldblum authored
      Summary: [Folly] A faster `empty()` shortcut in `IOBufCompare`.
      
      Reviewed By: spalamarchuk
      
      Differential Revision: D9981606
      
      fbshipit-source-id: 4a9762b83fe2f26b1387c162a1e23c201088977f
      ac009d2f
    • Yedidya Feldblum's avatar
      Let IOBufCompare have a self-compare shortcut · aa554761
      Yedidya Feldblum authored
      Summary: [Folly] Let `IOBufCompare` have a self-compare shortcut.
      
      Reviewed By: vitaut
      
      Differential Revision: D9981523
      
      fbshipit-source-id: e984cffc2816a0f4f06bf418b16d4d3eb055f6ef
      aa554761
    • Lee Howes's avatar
      Remove use of then inside Future · 271f9740
      Lee Howes authored
      Summary: To allow deprecation, remove use cases of Future::then inside Future.h/Future-inl.h.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D9984465
      
      fbshipit-source-id: 48e8a5b2985c86fd5384e43e6df282da298b1d99
      271f9740
  9. 21 Sep, 2018 11 commits
    • Igor Sugak's avatar
      update clang-format in fbsource and format folly · f68a5213
      Igor Sugak authored
      Reviewed By: zertosh
      
      Differential Revision: D9993527
      
      fbshipit-source-id: 52c4c0bfe6b5c73c652dd350f599fb846a003a4f
      f68a5213
    • Andrii Grynenko's avatar
      Fix WTCallback::interruptHandler to not use nullptr EventBase · 0289870c
      Andrii Grynenko authored
      Summary: (Note: this ignores all push blocking failures!)
      
      Reviewed By: spalamarchuk
      
      Differential Revision: D9994424
      
      fbshipit-source-id: 2055d3b09ce2e1d783624a9902463efade4714d4
      0289870c
    • Anton Likhtarov's avatar
      Perf: trivialStorage lookup optimization · 074417c3
      Anton Likhtarov authored
      Summary:
      This is known at compile time, but we still pay the cost since
      SettingCore has to look it up through its own reference.
      Hint it directly at the callsite instead.
      
      Differential Revision: D9983460
      
      fbshipit-source-id: 1c6ca5e3cbd9e859ba88d641cdca59f0d4d65dfb
      074417c3
    • Anton Likhtarov's avatar
      Easy: store metadata with SettingsCore object · 2ea7e939
      Anton Likhtarov authored
      Summary: Requires a new header to break the circular dependency
      
      Differential Revision: D9983196
      
      fbshipit-source-id: f15ab3c6128d30906ac25384df92813aa9d76c9a
      2ea7e939
    • Anton Likhtarov's avatar
      Perf: specialization for small types · ecdcc6d8
      Anton Likhtarov authored
      Summary:
      - Change the get() API to return T by value if T is small
      - Internally store small T in a global atomic to avoid thread local lookups
      
      Differential Revision: D9982433
      
      fbshipit-source-id: c42d06a75b9ff48307a90f77d0bb72bfa6375d6c
      ecdcc6d8
    • Anton Likhtarov's avatar
      Trivial: rename Type -> T · 3a2d6a36
      Anton Likhtarov authored
      Summary: Makes further changes cleaner
      
      Differential Revision: D9982335
      
      fbshipit-source-id: 19268c8e3fc1b6aee589a8d3d38b0348db8c5a43
      3a2d6a36
    • Anton Likhtarov's avatar
      Perf: easy, don't inline the slow path of tlValue · 50d93463
      Anton Likhtarov authored
      Summary: inline the small, fast path only
      
      Differential Revision: D9982097
      
      fbshipit-source-id: f1bcbab2b444d372e178aa548175a5c27be972b6
      50d93463
    • Anton Likhtarov's avatar
      Perf: inline lookup, cache location of the Meyer's singleton · e948b514
      Anton Likhtarov authored
      Summary:
      With this change the setting lookup is now inlined at each callsite as:
      ```
      if (UNLIKELY(global_setting_ptr == 0)) {
        global_setting_ptr = &initialize_setting(); // OK to race
      }
      // use *global_setting_ptr
      ```
      
      Differential Revision: D9981958
      
      fbshipit-source-id: a04b296d8345d1bb37dc06ce72277e00e745a94a
      e948b514
    • Lewis Baker's avatar
      Improve folly::coro::Task<T> support for move-only types · d1cadedd
      Lewis Baker authored
      Summary:
      The folly::coro::Task<T> and folly::coro::Future<T> types would previously return an lvalue-reference to the result when you co_await them.
      
      This means that for move-only types that code like `auto x = co_await someTask;` would fail to compile. Instead you would need to write `auto x = std::move(co_await someTask);`.
      
      Awaiting a Task<T> or Future<T> now returns type T instead of T&.
      
      As part of this change we now only allow co_awaiting an rvalue folly::coro::Task<T>, folly::coro::Future<T> as well as folly::coro::Future<T> to indicate that the operation is destructive and a one-time operation.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D9731525
      
      fbshipit-source-id: bee9e633b57b203a0d048cf3eb0e2fc48b899481
      d1cadedd
    • Andrii Grynenko's avatar
      Fix destruction race-condition in ThreadWheelTimekeeper · 9933f34f
      Andrii Grynenko authored
      Summary: It was possible for interruptHandler() to be called concurrently with the ThreadWheelTimekeeper shutdown resulting in use-after-free when trying to schedule work on the EventBase.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D9948555
      
      fbshipit-source-id: 4eff3cce0488778559dffc47bfc6eb59a65bb203
      9933f34f
    • Lee Howes's avatar
      Remove r-value qualification of folly::Try in makeSemiFuture and makeFuture. · 268c812c
      Lee Howes authored
      Summary: The && overload here caused me to call the wrong function and delay an error as it changed the type of the Future completely. There seems to be little benefit to making this r-value qualified, and is likely a side effect of consistency with the forwarding reference in the non-Try overload.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D9979805
      
      fbshipit-source-id: e8121d5bc2e5fe02d38d6ea9cb83adbe98010df2
      268c812c