1. 23 Apr, 2020 5 commits
    • Lucas Dobson-Defenbaugh's avatar
      Fix deprecation warnings for collectXSemiFuture · b646e5df
      Lucas Dobson-Defenbaugh authored
      Summary:
      We're recommending collectAny as a replacement for
      collectAllSemiFutures :(
      
      Reviewed By: LeeHowes
      
      Differential Revision: D21197163
      
      fbshipit-source-id: 0055e0feb5cc74a767370bc1dc9fe8e4d8dffcfc
      b646e5df
    • Dan Melnic's avatar
      Let AsyncUDPSocket send to multiple addresses · 43b0911a
      Dan Melnic authored
      Summary:
      Add support for variable number of addrs so we can send data to multiple destinations.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: kevin-vigor
      
      Differential Revision: D21032857
      
      fbshipit-source-id: f73b98d44f5d7d92f3692dfddb9b1c76ebcc51c5
      43b0911a
    • Andrew Doran's avatar
      Disable TSAN instrumentation across StaticMetaBase::onThreadExit(). · d08b8a41
      Andrew Doran authored
      Summary:
      Disable TSAN instrumentation across StaticMetaBase::onThreadExit() to avoid a shortcoming in TSAN on Linux that produces sprurious failures.
      
      This was recently worked around by ignoring TSAN failures in ld-linux's _dl_deallocate_tsd() (D20597534), but that turns out to be insufficient, because other TSAN failures can occur on the TLS area after the dynamic linker has called free() on it.  This diff backs out the change from D20597534, and works around the problem in a more direct & complete way.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20671620
      
      fbshipit-source-id: 05a74e709b620391f18467c7a5e4d14dcf9f4a1e
      d08b8a41
    • Michael Park's avatar
      Fix inaccurate deprecation message for `collectAllSemiFuture`. · bd44e567
      Michael Park authored
      Summary: Fixes a copy-paste mistake from the `collectAnySemiFuture` deprecation message.
      
      Reviewed By: Orvid
      
      Differential Revision: D21199692
      
      fbshipit-source-id: e61b740ea238dcbd6ca8481e1ba578a5073fe7bf
      bd44e567
    • Yedidya Feldblum's avatar
      Remove virtual inheritance in AsyncSocket · 97abe3c9
      Yedidya Feldblum authored
      Summary: [Folly] Remove unused virtual inheritance in `AsyncSocket`.
      
      Differential Revision: D20966977
      
      fbshipit-source-id: 502ab00438eebed0d8ebcf32ef602af50b05df47
      97abe3c9
  2. 22 Apr, 2020 3 commits
    • James Donald's avatar
      Fix -Winvalid-return warnings in Singleton · 1864bd5f
      James Donald authored
      Summary:
      Resolves these warnings:
      ```
      folly\Singleton.cpp(102,1): warning: function declared 'noreturn' should not return [-Winvalid-noreturn]
      }
      ^
      folly\Singleton.cpp(108,1): warning: function declared 'noreturn' should not return [-Winvalid-noreturn]
      }
      ^
      folly\Singleton.cpp(126,1): warning: function declared 'noreturn' should not return [-Winvalid-noreturn]
      }
      ^
      folly\Singleton.cpp(134,1): warning: function declared 'noreturn' should not return [-Winvalid-noreturn]
      }
      ^
      folly\Singleton.cpp(145,1): warning: function declared 'noreturn' should not return [-Winvalid-noreturn]
      }
      ```
      
      Reviewed By: mzlee, yfeldblum
      
      Differential Revision: D21130719
      
      fbshipit-source-id: a0f198d69c4fde44f9a5250b6915e36b6ee68642
      1864bd5f
    • Chris Sarbora's avatar
      Correctly handle Android not having malloc_usable_size below API17 · 5ead4c5e
      Chris Sarbora authored
      Summary: Android doesn't expose `malloc_usable_size` below API-level 17. Correctly reflect this in folly-config.h, and then ensure that all code paths that use `malloc_usable_size` are unreachable when compiling without it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20721326
      
      fbshipit-source-id: d60b3caa1910dc2bf8ed0844177f5cb93a9fd067
      5ead4c5e
    • Chris Sarbora's avatar
      Let small_vector pop_back a non-assignable type · eb877c83
      Chris Sarbora authored
      Summary: Relying on `erase()`, which must be able to move elements when erasing in front of other valid elements, causes compilation failures when trying to erase non-assignable elements at the end of the vector even though no elements actually need to be moved (and thus assigned) in that case. Here we help the compiler out and extract the destruction/resizing logic away from the moving logic.
      
      Reviewed By: yfeldblum, ot, mkatsevVR
      
      Differential Revision: D20718712
      
      fbshipit-source-id: 51c4e6636bc33577494c0c10e95da5f92b58d4b6
      eb877c83
  3. 21 Apr, 2020 4 commits
  4. 20 Apr, 2020 1 commit
    • Andrew Krieger's avatar
      Change DCHECK to assert to remove glog dep from Range · 97fc9b61
      Andrew Krieger authored
      Summary:
      This one DCHECK is the only thing keeping Range from
      being free of external deps. Lets make it not be a thing, so
      people are more inclined to pull in folly because Range is an
      easy gateway class to the rest of folly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21121743
      
      fbshipit-source-id: 2a54e94074135c951526c50d4bb63ebf2076a72f
      97fc9b61
  5. 18 Apr, 2020 2 commits
    • Jonathan Sailor's avatar
      update public README about supported platforms, compilers · fb0e252e
      Jonathan Sailor authored
      Summary:
      The README stated "folly requires gcc 5.1+ and a version of boost..." which
      some people might thing means that folly only supports gcc.
      
      Edit the README with more details about supported compilers and platforms.
      I tried to strike a balance between informative (FB uses folly on many
      platforms), conservative (the CMake build might not support all of them),
      and not mentioning specific versions (likely to get outdated.)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21093741
      
      fbshipit-source-id: 3a541f22b30736201361d2a10d861d61bd278e47
      fb0e252e
    • Scott Wolchok's avatar
      Convert throw in IPAddress to throw_exception · 4ee17e23
      Scott Wolchok authored
      Summary: Unbreak -fno-exceptions support for this file.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21043400
      
      fbshipit-source-id: aceea45c32d143c723ad6bae68a7403f14d7e0f2
      4ee17e23
  6. 17 Apr, 2020 1 commit
  7. 16 Apr, 2020 4 commits
    • Andrew Huang's avatar
      Implement abstracted SSL session in folly · 52a8633f
      Andrew Huang authored
      Summary: Repurpose the existing `folly::ssl::SSLSession` to be an abstraction for SSL sessions, with the internal implementation hidden. The intention is to soon move to using these abstracted sessions instead of directly using OpenSSL sessions.
      
      Reviewed By: yfeldblum, mingtaoy
      
      Differential Revision: D20143848
      
      fbshipit-source-id: 01e175668c0afcf8b91d19a289368496717d3150
      52a8633f
    • Maged Michael's avatar
      RequestContext: Fix overwrite of null data · 0e29494c
      Maged Michael authored
      Summary:
      Fix a bug in overwrite of null data.
      
      Null old data should be erased so that the insert of the new data can succeed.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D20908574
      
      fbshipit-source-id: 6873d9c76daf1289f1d5b97b001c21473c41ea3f
      0e29494c
    • Dan Melnic's avatar
      Fix typo · e1cdd680
      Dan Melnic authored
      Summary:
      Fix typo
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: mokomull
      
      Differential Revision: D21056053
      
      fbshipit-source-id: 3bf4295f9c6be1c50cdc64f6bbdf1b34cce6bece
      e1cdd680
    • Adam Simpkins's avatar
      getdeps: make several improvements to the eden manifest · d2a4722e
      Adam Simpkins authored
      Summary:
      - Indicate that the EDEN_VERSION_OVERRIDE environment variable affects the
        build.
      - Exclude eden/config.py from the shipit  path map, as this file is
        auto-generated in open source builds.
      - Include pexpect as a dependency, as this is needed for some of the
        integration tests.
      
      Reviewed By: genevievehelsel
      
      Differential Revision: D21000163
      
      fbshipit-source-id: 8eec378f66487229c995f637c4787eae530c7845
      d2a4722e
  8. 14 Apr, 2020 1 commit
    • Misha Shneerson's avatar
      Lift RequestContext root-id into task stats · 7469e0b5
      Misha Shneerson authored
      Summary: We want to use observer API to correlate tasks across same Thrift request. `RequestContext::getRootId` is the thing for it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20600485
      
      fbshipit-source-id: 1a79bde0f6c5b3692b4fb3805c98f377b1b317c9
      7469e0b5
  9. 10 Apr, 2020 2 commits
    • Felix Handte's avatar
      Make the Zstd Codec use the Context Singletons · 0938cf41
      Felix Handte authored
      Summary: Use pre-existing cached local contexts, rather than creating our own.
      
      Reviewed By: bimbashrestha
      
      Differential Revision: D18890550
      
      fbshipit-source-id: d53d0bdf35ebfcfa5dfb45da6b99a886022d5f8b
      0938cf41
    • Dan Melnic's avatar
      Fix PollIoBackend compile error · d1ec5727
      Dan Melnic authored
      Summary:
      Fix PollIoBackend compile error
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum, kevin-vigor
      
      Differential Revision: D20955224
      
      fbshipit-source-id: a2c7a34d9129cb282d3652607e79dcee1ce1cc78
      d1ec5727
  10. 09 Apr, 2020 7 commits
    • Wez Furlong's avatar
      getdeps: export fbsource commit date into environment · 4a29e9cb
      Wez Furlong authored
      Summary:
      This diff extracts the fbsource commit hash and the date of that
      commit and maintains that in place of just the commit hash that
      we were previously extracting.
      
      This data is exported into the environment that we pass on to
      builders so that it is available if they choose to use it.
      
      In a follow on diff I'll use this to default a version number
      in the watchman project.
      
      Reviewed By: fanzeyi
      
      Differential Revision: D20949666
      
      fbshipit-source-id: dc12bffe5f0efc4297b15ba0140c4c67a23ab0fd
      4a29e9cb
    • Kirk Shoop's avatar
      Add Support for nested MasterPtr and Cleanup tasks · 8045a2a0
      Kirk Shoop authored
      Summary:
      Allow a T that derives from EnableMasterFromThis<T> to use masterLockFromThis() to get a non-owning shared_ptr to this and to use masterRefFromThis() to get a MasterPtrRef<> from this.
      
      Adds MasterPtr::cleanup() that returns SemiFuture<Unit>. join() just does a blocking wait on the SemiFuture returned from cleanup().
      
      Allows a T to provide a T::cleanup() method that will be composed into the MasterPtr::cleanup() work.
      
      MasterPtr now uses SemiFuture<Unit> instead of Baton. This allows users of MasterPtr::cleanup() to compose cleanup work with other tasks.
      
      Andrii suggested that the cleanup feature be extracted out of MasterPtr
      
      Adds cleanup traits (that MasterPtr satisfies) and a Cleanup type that satisfies the cleanup traits and allows objects that are not heap-allocated to participate in structured concurrency by deriving from Cleanup.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D19584561
      
      fbshipit-source-id: aa2d608effe613ec84b08f902a1c61561f3458bb
      8045a2a0
    • Yedidya Feldblum's avatar
      Simplify some tests-in-loop in unit-tests · 4bce7f6d
      Yedidya Feldblum authored
      Summary: [Folly] Simplify a few cases of writing a loop to test each element of the loop in small-locks and spin-locks unit-tests.
      
      Reviewed By: markisaa
      
      Differential Revision: D20936029
      
      fbshipit-source-id: fd8a922d8e7b0a00ccd524c9905c641fd97a32f9
      4bce7f6d
    • Lewis Baker's avatar
      Add coroutine-frame memory allocation hooks to enable identifying async... · ddcf8ada
      Lewis Baker authored
      Add coroutine-frame memory allocation hooks to enable identifying async coroutine allocations in traces
      
      Summary:
      Customises the coroutine-frame allocation for all async coroutine types to call through
      the new `folly_coro_async_malloc` and `folly_coro_async_free` functions when heap-allocating
      coroutine frames.
      
      This should allow the identification of samples/traces that are calling into memory allocation
      for allocating coroutine frames and should enable better quantification of the CPU cycles
      and memory usage attributable to coroutine-frame allocations by filtering to samples that
      contain these functions in their stack-traces.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D20929042
      
      fbshipit-source-id: a94691377b92fab42736942ec8c7316c82a4205d
      ddcf8ada
    • Eric Niebler's avatar
      Fix the Folly OSS build by guarding the include of range-v3 header · 6d299ca1
      Eric Niebler authored
      Summary: Folly OSS does not list range-v3 as a dependency. As a result, test/RangeTest.cpp fails to compile because it tries to include a range-v3 header. This change gates the inclusion of the header with `__has_include`, making the dependency optional.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20839733
      
      fbshipit-source-id: 2d5e9c17427a0913f40f1ee80e868e27080a68f0
      6d299ca1
    • Dan Melnic's avatar
      Improve IOBuf::clone and IOBuf::cloneOne() perf · 96f9e38d
      Dan Melnic authored
      Summary: Improve IOBuf::clone and IOBuf::cloneOne() perf
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20882203
      
      fbshipit-source-id: ce37c2bf3c0fbdbe3c316856dc431a0108e4b9bf
      96f9e38d
    • Dan Melnic's avatar
      Fix folly::AsyncUDPSocket::gro_.value() check - GRO is enabled if the value is > 0 · dc0571b7
      Dan Melnic authored
      Summary:
      Fix folly::AsyncUDPSocket::gro_.value() check - GRO is enabled if the value is > 0
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: kevin-vigor
      
      Differential Revision: D20930544
      
      fbshipit-source-id: 6672b65cafe3f9859f86ad34a6c3a2d65c2dc355
      dc0571b7
  11. 08 Apr, 2020 4 commits
    • Matthieu Martin's avatar
      Folly coro: avoid KeepAlive copy in promise · 458af540
      Matthieu Martin authored
      Summary: This prevents one acquire/release.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D20924353
      
      fbshipit-source-id: 8c5135bd2ebc03b736b1ea3dbb385e01218cffbc
      458af540
    • Hasnain Lakhani's avatar
      Further improve sorted_vector_types standard compliance · 007c0045
      Hasnain Lakhani authored
      Summary:
      This is a follow up from D16427231; after testing the code in a similar situation on a mac (with `clang` and `libc++`) I realized there were still standards compliance issues.
      
      In that diff, the guarantee we provide is:
      
      ```
       *   - insert() single key variants, emplace(), and emplace_hint() only provide
       *     the strong exception guarantee (unchanged when exception is thrown) when
       *     std::is_nothrow_move_constructible<value_type>::value is true.
      ```
      
      The implementation is eventually backed by `std::vector`.
      
      The guarantees provided by `std::vector` in the standard are slightly weaker (https://en.cppreference.com/w/cpp/container/vector/insert):
      
      ```
      If an exception is thrown when inserting a single element at the end, and T is CopyInsertable or std::is_nothrow_move_constructible<T>::value is true, there are no effects (strong exception guarantee).
      ```
      
      i.e. it only provides this safety guarantee if the element is inserted at the end, and that's exactly what the new test shows.
      
      After discussion with nbronson we discovered that `libstdc++` and `libc++` are using different techniques to handle the corner case of `v.insert(0, v[1])` for `insert(iter, value_type const&)`. `libstdc++` makes the copy into a temporary, and then moves it in, so it does in fact provide a stronger guarantee than necessary. `libc++` checks the address of the reference it is given, and if it is in the moved range it adjusts it (!) and then uses the copy assignment operator. This means on copy assignment exception there will be a moved-from element at the desired index.
      
      Section 26.2.1 para 11 says that `insert` or `emplace` will have no effects if an exception is thrown, unless otherwise specified. 26.3.11.5 is the `vector` modifiers, but that only mentions `insert`. That means we can fix this by merely switch our uses of `std::vector::insert` to `std::vector::emplace` inside `sorted_vector_map/set`. On `libstdc++` this should't have any effect, since both insert and emplace make a temporary copy for the non-end insertion case (in different but similar code paths). On `libc++` this will avoid the address-adjusting trick and use the temporary copy technique like in `libstdc++`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20785383
      
      fbshipit-source-id: 290c3c7c061dedf1660da9534f4b9cc338da6224
      007c0045
    • Matthieu Martin's avatar
      Folly coro: missing executor move · f2fa1176
      Matthieu Martin authored
      Summary: This should reduce refcounting
      
      Reviewed By: lewissbaker
      
      Differential Revision: D20911114
      
      fbshipit-source-id: be941a5e0a095652c916e4704b0dd29874e0979d
      f2fa1176
    • Lee Howes's avatar
      Deprecate collectXSemiFuture · ff22ce9a
      Lee Howes authored
      Summary:
      Migration from Future-returning executor-erasing collectX forms to
      SemiFuture-returning forms, that are less risky in particular with coroutines.
      
      Earlier changes added collectXSemiFuture and collectXUnsafe as a migration
      path. We then migrated collectX callsites to collectXSemiFuture or
      collectXUnsafe and switched the implementation of collectX to the SemiFuture
      form.
      
      This diff adds deprecation flag to collectXSemiFuture during the migration to
      collectX and and removes from folly tests that are not specific to testing those
      operations.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20841855
      
      fbshipit-source-id: 30818711362c88c3296cfc976cd75fbd94e1c15c
      ff22ce9a
  12. 07 Apr, 2020 6 commits
    • Nathan Bronson's avatar
      support VS2019 in UninitializedMemoryHacks, fix VS2017 · b077851b
      Nathan Bronson authored
      Summary:
      VS2019 changes the internal implementation of basic_string and vector.
      This diff adds support for the new internals, and fixes a linkage
      problem on VS2017.  It also adds the UninitializedMemoryHacksTest to
      the getdeps-built tests.
      
      For basic_string a single version handles both old and new.
      basic_string::_Eos changed from public to private, so code that uses
      the template specialization hack to invoke it when it is private will
      work for the older public method as well.
      
      vector does not have any suitable internal methods, so we need to adapt
      to the new internal structure.
      
      This diff fixes the issues addressed by
      https://github.com/facebook/folly/pull/1345 , but uses an alternate
      strategy to avoid reinterpret_cast.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20838799
      
      fbshipit-source-id: eba7db2bd6feade1349d51be224c481a9156732b
      b077851b
    • Zeyi (Rice) Fan's avatar
      respect DISABLED flag reported by ctest · a9d3606b
      Zeyi (Rice) Fan authored
      Reviewed By: simpkins
      
      Differential Revision: D20885314
      
      fbshipit-source-id: 8c3a5ccbfd6630107b421b0d6953f17a93da2412
      a9d3606b
    • Maged Michael's avatar
      RequestContext: Optimize copying · 7e2877a3
      Maged Michael authored
      Summary:
      Reduce the cost of copying by keeping a vector of cleared RequestData references instead of keeping a hash map of the state of all RequestData references.
      
      Also, added FOLLY_ALWAYS_INLINE to functions called in copying of request contexts.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20863318
      
      fbshipit-source-id: 29cc38ac6e8abde3acaffcf8fa4d1e7ccbd45e87
      7e2877a3
    • Maged Michael's avatar
      SingleWriterFixedHashMap: Optimize copying · a2c4f8cf
      Maged Michael authored
      Summary: Use memcpy for copying maps with the same capacity instead of rehashing.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20863257
      
      fbshipit-source-id: 11e52f9f2246440fb724a94c2611e44e253e462d
      a2c4f8cf
    • Kirk Shoop's avatar
      add support for adopting a shared_ptr · 2f75edd3
      Kirk Shoop authored
      Summary:
      When incrementally adding in MasterPtr to an existing code-base there are some shared_ptr<> (eg. returned from factories) that need to be stored in MasterPtr.
      
      since unique_ptr converts to shared_ptr, just take and store a shared_ptr
      
      Yes, this removes the guarantee that ~T() will run in join(). I am open to suggestions
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D19583122
      
      fbshipit-source-id: 3daf0436d56b9c396b5e82d397ebaf93ed1a2a2d
      2f75edd3
    • Kirk Shoop's avatar
      add EnableMasterFromThis · 1f5ce2de
      Kirk Shoop authored
      Summary:
      when T derives from EnableSharedFromThis<T> and T is placed in a MasterPtr<T> then users of T have access to MasterPtr<T> functionality.
      
      `EnableSharedFromThis<T>::masterLockFromThis()`
      `EnableSharedFromThis<T>::masterRefFromThis()`
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D19583025
      
      fbshipit-source-id: ee12e9de30fd844b5be36c39d7e1ade830e27bbb
      1f5ce2de