1. 13 Mar, 2018 2 commits
    • Yedidya Feldblum's avatar
      Suppress -Wshadow-compatible-local in folly/test/stl_tests/StlVectorTest.cpp · 2e4740ed
      Yedidya Feldblum authored
      Summary:
      [Folly] Suppress `-Wshadow-compatible-local` in `folly/test/stl_tests/StlVectorTest.cpp`.
      
      That test source file is heavily macro-driven, and using `SCOPED_TRACE` repeatedly in macros can lead to violations of `-Wshadow-compatible-local`.
      
      Reviewed By: meyering
      
      Differential Revision: D7231029
      
      fbshipit-source-id: 122e1d86032cf884a83ef1716fa48b8f4864a363
      2e4740ed
    • Mingtao Yang's avatar
      SSLContext: Report error codes in hexadecimal. · 72eebc56
      Mingtao Yang authored
      Summary: For compatiblity with `openssl errstr`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7246053
      
      fbshipit-source-id: dcf77b67ae3b3dd7b6b85e9b73f2d382e59aa7b9
      72eebc56
  2. 12 Mar, 2018 6 commits
    • Dave Watson's avatar
      Add timed_wait · 5a500c70
      Dave Watson authored
      Summary:
      Add try_wait_for and try_wait_until.
      
      Algorithm -
      
      We could use a doubly-linked list, but this would double the number of contended
      CAS for push/post.  Instead, assume timeouts are infrequent, and just walk the list
      from the head to remove nodes.
      
      A lock bit is added to the head, which is taken only on timeout.  We assume
      timeouts are infrequent.
      
      If a concurrent post() removes the node before the timeout can remove it,
      we must wait for the corresponding post() (but it is likely to arrive soon),
      instead of timing out.
      
      Reviewed By: magedm
      
      Differential Revision: D7167894
      
      fbshipit-source-id: ea5242098d9ccd286a72fade6292223e95c44a81
      5a500c70
    • Dan Melnic's avatar
      Use unbounded queue in NotificationQueue · c9dd3e5e
      Dan Melnic authored
      Summary: Use unbounded queue in NotificationQueue
      
      Reviewed By: djwatson
      
      Differential Revision: D7164130
      
      fbshipit-source-id: d1b445d6730cbb2a68ad78506abe0165e28f5811
      c9dd3e5e
    • Dan Melnic's avatar
      Add folly::Optional<T> UnboundedQueue::try_dequeue() method · 8a14ddfa
      Dan Melnic authored
      Summary: Add folly::Optional<T> UnboundedQueue::try_dequeue() method
      
      Reviewed By: magedm
      
      Differential Revision: D7164049
      
      fbshipit-source-id: 659de2d26067bb1a5bdea50f4cd7711e6955ba61
      8a14ddfa
    • Dan Melnic's avatar
      NotificationQueue benchmark · 9b55b900
      Dan Melnic authored
      Summary: NotificationQueue benchmark
      
      Reviewed By: yfeldblum, djwatson
      
      Differential Revision: D7163944
      
      fbshipit-source-id: f7fe2124b8c61ff3ab39be94d9c50c82a6f8816b
      9b55b900
    • Yedidya Feldblum's avatar
      Fix propagate_const under gcc49 · 5fbd25bb
      Yedidya Feldblum authored
      Summary: [Folly] Fix `propagate_const` under gcc49.
      
      Reviewed By: andrewjcg
      
      Differential Revision: D7230851
      
      fbshipit-source-id: 0cd4df15d5a0f7ae06e26a82ca725b30d479f458
      5fbd25bb
    • Yedidya Feldblum's avatar
      Rewrite allocators for the era of std::allocator_traits · 0085c239
      Yedidya Feldblum authored
      Summary:
      [Folly] Rewrite allocators for the era of `std::allocator_traits`.
      
      Provide minimal interfaces which comply with all required elements of C++ concept `Allocator`. Change all (*) uses to use `std::allocator_traits` consistently, as is required of all allocator-aware library types.
      
      * Rename `SysAlloc`.
      * Replace `StlAllocator` with `CxxAllocatorAdaptor` with stricter semantics.
      * `Arena` is no longer a C++ Allocator because it is not freely copyable. Change code which used it as a C++ Allocator to use `CxxAllocatorAdaptor` instead.
      * `ThreadCachedArena` likewise.
      
      (*) Hopefully.
      
      Reviewed By: nbronson
      
      Differential Revision: D7208794
      
      fbshipit-source-id: 270588c9c3d817f4abd9fb49eed5eb9f03f96da2
      0085c239
  3. 10 Mar, 2018 3 commits
  4. 09 Mar, 2018 5 commits
    • Giuseppe Ottaviano's avatar
      Make hasher<float> avalanching · 88b3fb8e
      Giuseppe Ottaviano authored
      Summary: It currently only sets the lower 32 bits.
      
      Reviewed By: nbronson, philippv
      
      Differential Revision: D7216798
      
      fbshipit-source-id: 090f6dba990eeb7f1a9cc56e8615161c11eea026
      88b3fb8e
    • Nathan Bronson's avatar
      add IsAvalanchingHasher trait · 5ca9b9dc
      Nathan Bronson authored
      Summary:
      This diff adds folly::IsAvalanchingHasher<H, K>, which identifies
      hash functors that exceed the standard's quality requirement by also
      being avalanching.  This is useful for code that wants to map hash values
      onto a restricted range or compute a secondary hash value without doing
      extra work.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7180217
      
      fbshipit-source-id: 8c402937d0a654c0ec32c62666e9dc4e0943f769
      5ca9b9dc
    • Nathan Bronson's avatar
      clang-format in preparation for other changes · 73c483aa
      Nathan Bronson authored
      Summary:
      This diff clang-formats a couple of files in preparation for
      additional changes.
      
      Reviewed By: yfeldblum, shixiao
      
      Differential Revision: D7197983
      
      fbshipit-source-id: 8995bdaca29bcc44cd5379fc64c76cee89635ac1
      73c483aa
    • Adam Simpkins's avatar
      logging: add a getBaseLoggingConfig() function · 92dbb6a8
      Adam Simpkins authored
      Summary:
      Update folly::initLogging() to call getBaseLoggingConfig() to get a base
      configuration string that is applied before the argument that it was called
      with.  getBaseLoggingConfig() is defined as a weak symbol, and is intended to
      be overridden on a per-executable basis if desired.
      
      This allows individual programs to control their default logging settings, but
      still let them be overridden via a command line flag.  The command line flag is
      used to update this base configuration.  The command line flag can fully
      override all of the base configuration settings if desired, but settings from
      the base config that are not overridden will still be used.
      
      For example, if the base configuration defines settings for the categories
      "foo" and "bar", and the command line flag defines settings for the categories
      "bar" and "wub", the base configuration settings for "foo" will still be used.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7164832
      
      fbshipit-source-id: e172f746d7bd004948872adbbb87c597765e283c
      92dbb6a8
    • Andrii Grynenko's avatar
      Make via a free function · f999d202
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D7203193
      
      fbshipit-source-id: 440daa2f79a919aa95ae3fdb4006f8d501c0ad93
      f999d202
  5. 08 Mar, 2018 4 commits
    • Kostia Balytskyi's avatar
      msvc2015u3: extend D4988025 fix to one more place · 67a5865f
      Kostia Balytskyi authored
      Summary: This just extends D4988025 to one more location, which wasn't covered in the initial fix.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7181160
      
      fbshipit-source-id: 8dd0866d916674870f04252a80725ecce0cd69e1
      67a5865f
    • Nathan Bronson's avatar
      folly::hasher<T> should convert args to T before hashing · 2bd76586
      Nathan Bronson authored
      Summary: folly::hasher<T> for integral and floating point types T uses a different algorithm depending on the key type.  At the moment this is taken from the actual argument type, rather than the explicitly provided one.  This is likely to be confusing.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7194941
      
      fbshipit-source-id: efa3e4bbad62e53842ec6fb80d316706324e98aa
      2bd76586
    • Dave Watson's avatar
      Add a buckets + size seqlock · aeac6f59
      Dave Watson authored
      Summary:
      There is currently an unnecessary data dependency loading the
      current backing buckets + size, reading the size, then again indexing
      in to the array.
      
      Rework the Buckets struct to make a single allocation, and store the bucket_count_ in the Segment directly.  The bucket pointer and segment are protected by a seqlock.
      
      Reviewed By: ot
      
      Differential Revision: D7167919
      
      fbshipit-source-id: 10ddceffad19f54c790b3ab7a87260445571f81d
      aeac6f59
    • Sarang Masti's avatar
      Support custom comparator in EvictingCacheMap · b6a27e14
      Sarang Masti authored
      Summary: Allow passing in a custom comparator to compare keys
      
      Reviewed By: yfeldblum, aary
      
      Differential Revision: D7175777
      
      fbshipit-source-id: e1e8d836a908b595a74b172b04ca847a5c5eb435
      b6a27e14
  6. 07 Mar, 2018 7 commits
    • Adam Simpkins's avatar
      logging: fix the open source build · 417035de
      Adam Simpkins authored
      Summary:
      Add ConfigHelpers.cpp to the folly_test_support library.
      This was accidentally broken in D7164831, but wasn't caught due to
      infrastructure errors kicking off the continuous OSS builds.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7186076
      
      fbshipit-source-id: f13bdd920bb289ae19fdb46e265123fe088b42c3
      417035de
    • 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
  7. 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
  8. 05 Mar, 2018 5 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