Tags: kexianda/folly
Tags
Adding yaml-cpp fboss code for oss Summary: Added yaml-cpp library to the fboss OSS build Reviewed By: shri-khare Differential Revision: D25126509 fbshipit-source-id: 1e88150dbf8c96a5ac696e003265dc1f14bec105
Add API to AsyncServerSocket that allows potentially stale connection… …s to be dropped Summary: Added a timestamp to `AsyncServerSocket::QueueMessage` so that `NotificationQueue` can ignore new connection messages which are deemed *expired*. Expired messages represent sockets which have *probably* timed out already. The TTL is configured per `AsyncServerSocket` instance and is applied to all future messages that are queued by it. By default, messages do not expire. This can be configured with `AsyncServerSocket::setQueueTimeout`. Reviewed By: andriigrynenko Differential Revision: D24667870 fbshipit-source-id: 0f9d6c235627393d964e280a0d5956676010c7aa
Fix missing #include <limits> (facebook#1482) Summary: Hello, The compilation with the HEAD of gcc 11 fails: ``` FAILED: CMakeFiles/folly_base.dir/folly/TimeoutQueue.cpp.o g++ ... -c ../folly/TimeoutQueue.cpp ../folly/TimeoutQueue.cpp: In member function 'int64_t folly::TimeoutQueue::nextExpiration() const': ../folly/TimeoutQueue.cpp:39:32: error: 'numeric_limits' is not a member of 'std' 39 | timeouts_.empty() ? std::numeric_limits<int64_t>::max() | ^~~~~~~~~~~~~~ ../folly/TimeoutQueue.cpp:39:54: error: expected primary-expression before '>' token 39 | timeouts_.empty() ? std::numeric_limits<int64_t>::max() | ^ ../folly/TimeoutQueue.cpp:39:57: error: '::max' has not been declared 39 | timeouts_.empty() ? std::numeric_limits<int64_t>::max() | ^~~ ../folly/TimeoutQueue.cpp:39:57: note: suggested alternatives: In file included from /opt/1A/toolchain/x86_64-v21.0.8/include/c++/11.0.0/functional:65, from ../folly/TimeoutQueue.h:31, from ../folly/TimeoutQueue.cpp:17: /opt/1A/toolchain/x86_64-v21.0.8/include/c++/11.0.0/bits/stl_algo.h:3464:5: note: 'std::max' 3464 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ ``` It is nothing to fix. Regards, Laurent Pull Request resolved: facebook#1482 Reviewed By: yfeldblum Differential Revision: D24757105 Pulled By: Orvid fbshipit-source-id: 8a5382edbe5b7c11cace5a1cd4c0645dfd2a9d37
Disable an exception-throw stress test for DistributedMutex under TSAN Summary: This test inexplicably aborts when ran under TSAN. TSAN reports a read-write race where the exception is freed by the lock-holder / combiner thread and read concurrently by the thread that requested the combine operation. TSAN reports a similar read-write race for this code as well https://gist.github.com/aary/a14ae8d008e1d48a0f2d61582209f217 (copied below). Which is easier to verify as being correct. Though this does not conclusively prove that this test and implementation are race-free, the above repro combined with error-free stress runs of this test under other modes (optimized builds with and without both ASAN and UBSAN) give us a high signal at TSAN's error being a false-negative. So disabling it for now until some point in the future where TSAN stops reporting this as a false-negative ``` namespace { struct Storage { std::atomic<std::uint64_t> futex_{0}; std::atomic<std::uint64_t> next_; std::aligned_storage_t<48, 8> storage_; }; template <typename Waiter> void transferCurrentException(Waiter* waiter) { assert(std::current_exception()); new (&waiter->storage_) std::exception_ptr{std::current_exception()}; waiter->futex_.store(1, std::memory_order_release); } template <template <typename> class Atom = std::atomic> void concurrentExceptionPropagationStress( int, std::chrono::milliseconds) { auto exceptions = std::vector<std::unique_ptr<Storage>>{}; exceptions.resize(1000000); for (auto i = std::size_t{0}; i < exceptions.size(); ++i) { exceptions[i] = std::make_unique<Storage>(); } auto throwing = std::function<void(std::uint64_t)>{[&](auto counter) { if (counter % 2) { throw std::runtime_error{folly::to<std::string>(counter)}; } }}; std::cout << "Started test" << std::endl; auto writer = std::thread{[&]() { for (auto i = std::size_t{0}; i < exceptions.size(); ++i) { try { std::this_thread::yield(); throwing(i); } catch (...) { transferCurrentException(exceptions.at(i).get()); continue; } exceptions.at(i)->futex_.store(2, std::memory_order_release); } }}; auto reader = std::thread{[&]() { for (auto i = std::size_t{0}; i < exceptions.size(); ++i) { auto value = std::uint64_t{}; while (!(value = exceptions.at(i)->futex_.load(std::memory_order_acquire))) {} if (value == 1) { try { auto buf = reinterpret_cast<std::exception_ptr*>(&exceptions.at(i)->storage_); auto ex = folly::launder(buf); auto copy = std::move(*ex); ex->exception_ptr::~exception_ptr(); std::rethrow_exception(std::move(copy)); } catch (std::exception& exc) { assert(folly::to<std::uint64_t>(exc.what()) == i); } } } }}; reader.join(); writer.join(); } } // namespace ``` Reviewed By: yfeldblum Differential Revision: D24653383 fbshipit-source-id: 3ce166766eb42b22ec7b8cfaf8d31ca53580ff9e
Use static_cast instead of function-style cast in ConstexprMath.h Summary: Some llvm toolsets mis-parse the function-like C-style casts in ConstexprMath.h as function declarations, resulting in strange compiler errors. Prefer `static_cast` to eliminate the ambiguity. Note: We cannot use brace-initialization syntax, because that would error on narrowing conversions. Reviewed By: ispeters, Mizuchi Differential Revision: D24463342 fbshipit-source-id: 5d5aabb08cd20e91a1a5f5460cc4505cafb3cdfc
Add `midpoint()` calculation to folly Summary: A number of libraries at Facebook include interval midpoint calculations; however, doing these in a mathematically precise way (without over/underflow) can be tricky. Doing them wrong can break binary searches over large datasets and give imprecise floating-point calculations. This function provides an early opportunity to fix binary searches and other calculations which can later be updated to `std::midpoint()` when C++20 becomes available. Reviewed By: yfeldblum Differential Revision: D23997097 fbshipit-source-id: 373e0dc1d1ff071f697ee782be46fb0d49a2f8f7
Add support for UDP RX timestamps Summary: Add support for UDP RX timestamps Reviewed By: mjoras Differential Revision: D24146914 fbshipit-source-id: 381839fc5402f13e428364c47c5752473acda6af
Remove --skip-project-specific flag Summary: This doesn't do anything anymore and is going to be removed in D23993306, let's remove it here first. Reviewed By: yns88 Differential Revision: D23993954 fbshipit-source-id: 4d7dd5f992e34be7a0da16ce7cf59810407649c4
Make SymbolizerTest pass if compiled as PIE. Summary: The symbolizer takes mapped addresses (address listed in ELF, offset by the binary offset (which is zero for non-PIE)) and symbolizes it into non-mapped addresses. In a couple of places in SymbolizerTest, we took the non-mapped addresses and symbolized them again, which wouldn't work if the binary was compiled with PIE. In another place in SymbolizerTest, the mapped address was used to look up DWARF information, whereas we needed the non-mapped address. This diff addresses these issues. Additionally, I discovered that r_debug::r_map->l_addr is the "right" way to get the PIE offset, so this diff pulls that common functionality to symbolizer/detail/Debug.h and use it for Symbolizer and the three tests so far that need PIE relocation adjustments. Reviewed By: yfeldblum Differential Revision: D23492850 fbshipit-source-id: 62353e576c50b44070b323b5477fea9bb4c0b500
fix overflow in EF::UpperBitsReader::reposition Reviewed By: ot Differential Revision: D23802800 fbshipit-source-id: 993060123790058b44d13c0b38eb4a04a28462a2
PreviousNext