- 20 May, 2016 2 commits
-
-
Christopher Dykes authored
Summary: The configure script doesn't define `FOLLY_HAVE_PREADV` if `preadv` isn't supported, so these checks were wrong. Undefined defines expand to `0`, so this is safe. Fixes https://github.com/facebook/folly/issues/412 Reviewed By: mzlee, yfeldblum Differential Revision: D3329405 fbshipit-source-id: faee8951c68d4c67e06e7720dfc142e63a9dbd9f
-
Shubhanshu Agrawal authored
Summary: This diff templates folly::fibers::await by Baton. This would be helpful in passing in custom BatonType's, which is needed for D3007734 Depends on: D3314891 Reviewed By: andriigrynenko Differential Revision: D3314925 fbshipit-source-id: 9052dc503b9509f16cd41b5e3ede0479a98067aa
-
- 19 May, 2016 8 commits
-
-
Alejandro authored
Summary: The current use case of `std::memory_order_consume` in this project was intended to provide the appropriate synchronization in cases where a consumer spins on `while( spsc_queue.empty() ) {} `, and then attempts to use an element of the queue since the loop was broken out of, according to comments [here](https://reviews.facebook.net/D48141). Consume semantics do not provide this guarantee according to the standard since there is no data dependency from the producer that can be carried to the consumer by doing a load-consume from the corresponding functions. What is needed is a load-acquire. Current compilers promote `memory_order_consume` to `memory_order_acquire`. Thus, this example appears to work simply due to the promotion from consume to acquire, but would fail to generate the right synchronization instructions on weaker architectures once `memory_order_consume` is implemented as intended. Therefore, the `memory_order` should be tightened to `memory_order_acquire` to guarantee visibility to the consumer Closes https://github.com/facebook/folly/pull/381 Reviewed By: djwatson Differential Revision: D3173574 Pulled By: nbronson fbshipit-source-id: b109be2e74f016750a3fe1f848e3fc66e609b9d2
-
Yedidya Feldblum authored
Summary: [Folly] Extract `Try` to top-level. It was in `folly/futures/`, but this diff moves it to `folly/`. It is needed for futures, but it is are more general than futures and can be used separately. Use `folly/Try.h` instead of `folly/futures/Try.h`. Also fixes up all `#include` sites: hg grep -lw folly/futures/Try | xargs perl -pi -e 's,\bfolly/futures/Try\b,folly/Try,g' Reviewed By: markisaa Differential Revision: D3309908 fbshipit-source-id: cdf13f0ac0b0e36aa07e0f1d04870d06500c5874
-
Lucian Grijincu authored
Summary: ``` buck-out/gen/folly/__default_headers__#default,headers/folly/FBString.h:365:7: runtime error: null pointer passed as argument 2, which is declared to never be null third-party-buck/build/glibc/include/string.h:70:33: note: nonnull attribute specified here #0 0x433a39 in _ZZN5folly13fbstring_coreIcEC1EPKcmbENKUlvE_clEv ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/FBString.h:365:7 #1 0x4335a9 in _ZN5folly14ScopeGuardImplIZNS_13fbstring_coreIcEC1EPKcmbEUlvE_E7executeEv ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/ScopeGuard.h:153:29 #2 0x4335a9 in _ZN5folly14ScopeGuardImplIZNS_13fbstring_coreIcEC1EPKcmbEUlvE_ED2Ev ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/ScopeGuard.h:130 #3 0x4335a9 in folly::fbstring_core<char>::fbstring_core(char const*, unsigned long, bool) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/FBString.h:427 #4 0x4353fa in folly::basic_fbstring<char, std::char_traits<char>, std::allocator<char>, folly::fbstring_core<char> >::basic_fbstring(char const*, unsigned long, std::allocator<char> const&) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/FBString.h:1038:9 ``` Reviewed By: Gownta Differential Revision: D3321266 fbshipit-source-id: 28d5aef16e91a98066a1de6bab95403fbc63eaab
-
Andrii Grynenko authored
Summary: folly::fibers have been used by mcrouter for more than 2 years, so not really experimental. Reviewed By: pavlo-fb Differential Revision: D3320595 fbshipit-source-id: 68188f92b71a4206d57222993848521ca5437ef5
-
Shubhanshu Agrawal authored
Summary: This diff adds a static await method to Promise. Also after this, folly::fibers::await is just a wrapper around Promise::await. This also removes the friend relationship between Promise and await. This would be helpful in making the folly::fibers::await templated by Baton changes easier to make. Reviewed By: andriigrynenko Differential Revision: D3314891 fbshipit-source-id: 361546c078caafd067734d2f474c617d7fb888b0
-
Yedidya Feldblum authored
Summary: [Folly] Make `Try` independent of `Future`. `Try` is useful for futures, but it can be used independently from futures as well. Reviewed By: djwatson Differential Revision: D3319130 fbshipit-source-id: badfcaa482dee6e7bdef14a501b4efc91634fa51
-
Andrii Grynenko authored
Reviewed By: yfeldblum Differential Revision: D3317666 fbshipit-source-id: f5558b117c8da74789ee444cdaa00231e75dc31e
-
iivlev authored
Summary: Closes https://github.com/facebook/folly/pull/403 Reviewed By: yfeldblum Differential Revision: D3320043 Pulled By: elliottneilclark fbshipit-source-id: 5d21421216180fb601015a40a3de79e3dd2a162e
-
- 18 May, 2016 5 commits
-
-
Yedidya Feldblum authored
Summary: [Folly] Flesh out the comments about `Unit`. * Remove mention of `Future`. * Compare `unit` to `void`. Reviewed By: djwatson Differential Revision: D3316114 fbshipit-source-id: d30cf36cc029025734bb16c5bdbd640a289cad79
-
Yedidya Feldblum authored
Summary: [Folly] Extract `Unit` to top-level. It was in `folly/futures/`, but this diff moves it to `folly/`. It is needed for futures, but it is more general than futures and can be used separately. Users must replace `folly/futures/Unit.h` with `folly/Unit.h`. Also codemods existing usage sites: ``` hg grep -lw folly/futures/Unit.h | xargs perl -pi -e 's,\bfolly/futures/Unit\.h\b,folly/Unit.h,g' ``` Reviewed By: igorsugak Differential Revision: D3314280 fbshipit-source-id: 16279b76b1d24529bec49077ccb36cd7d39f23b8
-
Ilya Maykov authored
Summary: Added a version of IOBuf::wrapBuffer() which returns the new IOBuf by value rather than heap-allocating it. Motivation: we have a lot of places in the crypto code that do something like this: // take a string or vector parameter auto buf = folly::IOBuf::wrapBuffer( /* string or vector goes here */); // do something with buf // return In these cases, a stack-allocated IOBuf would save us from an unnecessary heap allocation. But calling `folly::IOBuf(folly::IOBuf::WrapBufferOp::WRAP_BUFFER, ...)` is gross and in practice people just call the much more readable `wrapBuffer()` function. Hypothesis: readability trumps performance, but if we had a readable version that returned a stack-allocated IOBuf, it might see usage. Reviewed By: yfeldblum Differential Revision: D3314037 fbshipit-source-id: 4d4b5ec1d067762a27de1d7d6f7cac406388bfa3
-
Andrii Grynenko authored
Summary: Baton::post has to be the last step of Promise::setTry. If Promise is not owned by the posting thread, it may be destroyed right after Baton::post is called. Reviewed By: pavlo-fb Differential Revision: D3312506 fbshipit-source-id: 6d5c3f0925c3bb9cd3f981e7550f888d5ed76189
-
Yedidya Feldblum authored
Summary: [Folly] Keep the `Unit` test suite free of `Promise` and `Future`. Move the `Promise`-related tests to the `Promise` test suite and the `Future`-related tests to the `Future` test suite. Reviewed By: djwatson Differential Revision: D3313635 fbshipit-source-id: 05c82c8719719d7709063ad58a4806036ca10fb3
-
- 17 May, 2016 3 commits
-
-
Yedidya Feldblum authored
Summary: [Folly] Simplify `Unit`. Specifically: * Make `Unit::Lift` and `Unit::Drop` simply be aliases to `std::conditional<...>`. No need for anything more complicated. * Remove `is_void_or_unit`, which is unused and unnecessary. Reviewed By: djwatson Differential Revision: D3312481 fbshipit-source-id: 280d40aa8ef91c52f96a51b03e0a109d76c939ec
-
Marcus Holland-Moritz authored
Reviewed By: meyering, luciang Differential Revision: D3310683 fbshipit-source-id: c86471d54062b2f3455f15fb73340fac486d9e44
-
Yedidya Feldblum authored
Summary: [Folly] `IPAddress::validate`. Reviewed By: igorsugak Differential Revision: D3308683 fbshipit-source-id: 48af18d6930f16718372021a4cc08062bf17327e
-
- 16 May, 2016 2 commits
-
-
Andrii Grynenko authored
Summary: This fixes a race which can only be exposed if Promise is owned by the same thread which was calling await and Promise is fulfilled from a different thread. What could happen then was: 1. Thread 2 fulfills the promise and thus saves the value and posts Baton. 2. Thread 1 wakes up, await returns and then Thread 1 destroys the Promise. 3. Promise destructor checks value_, which is still not null, so it tries to fulfil it with exception. Reviewed By: spalamarchuk Differential Revision: D3306969 fbshipit-source-id: adf799cfd7b75b0201fa675a9e44ac7c7c42ac95
-
Andrii Grynenko authored
Summary: This fixes fibers::await to correctly handle exception thrown by user-passed lambda. Await still always waits for the promise to be fulfilled (if the promise was not moved out, it will be destroyed and thus auto-fulfilled with "promise not fulfilled" exception). However if user-passed lambda throws, promise result is ignored (even if exception) and exception thrown by lambda is re-thrown. Reviewed By: pavlo-fb Differential Revision: D3303393 fbshipit-source-id: c4ba01fde0e156cc88e5d07aaf763e3abe121d11
-
- 14 May, 2016 5 commits
-
-
Yedidya Feldblum authored
Summary: [Folly] Prefer `constexpr` to preprocessor conditionals when checking endianness. Using `if (folly::kIsLittleEndian) {` v.s. `#if __BYTE_ORDER__ == __LITTLE_ENDIAN__`. Reviewed By: meyering Differential Revision: D3296770 fbshipit-source-id: b26df83fdd42a50663746fc7c9d5fbe67e6671eb
-
Yedidya Feldblum authored
Summary: [Wangle] A thread-per-task executor. Moved from Folly into Wangle and fleshed out. * Starts task threads from a control thread, rather than starting task threads from the submitter thread. Because starting task threads is likely to be more expensive than moving a functor. * Joins task threads as they finish, rather than joining all task threads in the executor's destructor. Suitable for running tasks which spend most of their time sleeping. Such as blocking IO, blocking fork-exec-wait, etc., when it is inconvenient to use the nonblocking variants with an IO executor. Reviewed By: simpkins Differential Revision: D3286988 fbshipit-source-id: 4b91133a7d55332ebbae020c1515c60e816906b3
-
Lucian Grijincu authored
folly: fbstring: ubsan: memcpy/memmove are marked as nonnull - avoid calling them when size == 0 and (likely) source is nullptr Summary: Also see {D3295811} Differential Revision: D3302564 fbshipit-source-id: 3f2dbf5a6cfa8199682cb4af90aac372d501919a
-
Lucian Grijincu authored
Reviewed By: ot Differential Revision: D3300437 fbshipit-source-id: 7e0add5dab6dc1c891b742b4bcedea656c8284a9
-
Lucian Grijincu authored
Reviewed By: meyering Differential Revision: D3283226 fbshipit-source-id: 7ae2ec7741ca53c494e8325e30f2995a241674c0
-
- 13 May, 2016 5 commits
-
-
Mirek Klimos authored
Summary: ^, as discussed on D3279644 Reviewed By: andriigrynenko Differential Revision: D3299473 fbshipit-source-id: dc302132db64399f768d69c641f848d0da1075c4
-
Mirek Klimos authored
Summary: To make sure RequestContext is properly unset when we stop processing request on a thread. This changes the API in Fibers, NotificationQueue, HHWheelTimer and AsyncTimeout, and fixes RequestContext handling in Futures (reset RC after the callback is done) Reviewed By: andriigrynenko Differential Revision: D3279644 fbshipit-source-id: a6a1c2840cdce179334aa1a3b28fa514cd5358c1
-
Chad Parry authored
Summary: This diff standardizes `HHWheelTimer` construction. It's not that safe to allow anyone to call `new HHWheelTimer` because the caller needs to remember to call `DelayedDestruction::destroy`. Once callers are made to be safer, I'll be able to change the `HHWheelTimer` to use standard smart pointers instead of `DelayedDestruction`. This picks up some work that I started in D2627941 but had to postpone. This was mostly a mechanical change: ( fbgs -ls 'new HHWheelTimer' ; fbgs -ls 'new folly::HHWheelTimer' ) | xargs perl -pi -e 's/\bnew\s+((?:folly::)?HHWheelTimer)\b/$1::newTimer/g' Then I manually inspected the code. I reverted `folly/io/async/HHWheelTimer.h`, since the `newTimer` factory method is the one place that we still want to call `new HHWheelTimer`. I manually edited `proxygen/lib/utils/SharedWheelTimer.cpp`, since that was using a `shared_ptr` with a custom destructor, which isn't needed anymore. I reverted `common/io/async/d` since the D shim is meant to pass around only raw pointers. I had to replace each instance of `foo.reset(…)` with `foo = …` . Then I made manual edits to `common/clientpool/ClientPool2-inl.h` because that code wants to store the timer in a `ThreadLocalPtr`. Reviewed By: yfeldblum Differential Revision: D3237530 fbshipit-source-id: 96bfb6987098618ad5430c21b1314f385f04a93d
-
Mark Santaniello authored
Summary: This -Wbool-compare is apparently new in GCC 5. We should ignore it, similar to the existing suppression of -Wsign-compare. Reviewed By: pixelb, yfeldblum Differential Revision: D3293675 fbshipit-source-id: 5f90b0dbf049a06c0f6c3df2cdfcc8055358e367
-
Subodh Iyengar authored
Summary: Error message might be < 256 bytes in which case buf.size() would be greater than the size of the message written out and we might have garbled bytes at the end. ERR_error_string_n null terminates the string so just use that. Reviewed By: anirudhvr Differential Revision: D3297320 fbshipit-source-id: 2ae626ce4c49ca478806c0bcc40a390e5a84f24b
-
- 12 May, 2016 5 commits
-
-
Andrii Grynenko authored
Summary: This updates FiberManager to automatically register custom stack for signal handlers. This ensures signal handlers will work correctly not only in case of stack overflow, but also if fiber stack size is just not enough for them. Reviewed By: yfeldblum Differential Revision: D3289912 fbshipit-source-id: 44959b727f70e1f1748d837b1a06c7414433e5ec
-
Chad Parry authored
Summary: This `ThreadLocalPtr::reset` overload will accept a `unique_ptr`. It's actually not totally exception safe, simply because `ElementWrapper::set` is not exception safe. The best I can say is that my additional code is exactly as safe as the underlying implemenation. liketolivedangerously Reviewed By: ericniebler Differential Revision: D3271563 fbshipit-source-id: 774bcf31924b1ed4e29a6cb1c0a36ad710ab6034
-
Chad Parry authored
Summary: While making an unrelated change, (D3271563, which was needed from an unrelated change, (D3237530)), I noticed a lack of exception safety here. If `std::bad_alloc` were thrown, then we don't want to leak memory. Reviewed By: ericniebler Differential Revision: D3271911 fbshipit-source-id: 0d316c0fa865a7d64622c1d62160bb0c2b061d78
-
Michael Lee authored
Summary: According to the POSIX definition, IOV_MAX is defined in limits.h. Given that IOVec.h is used to provide IOV_MAX and similar, it seems like we should add limits.h as well. Differential Revision: D3291996 fbshipit-source-id: 238140ebef7b1b90a28f3a67a25c5f5863538fc7
-
Christopher Dykes authored
Summary: Windows doesn't have sys/uio.h, so implement it. This doesn't adjust any includes of it yet, I'll leave that for a separate diff. Reviewed By: yfeldblum Differential Revision: D2978042 fbshipit-source-id: 16d398a856de50b6c662f739eb11dfb851096592
-
- 11 May, 2016 4 commits
-
-
Subodh Iyengar authored
Summary: Add server support for TFO to wangle. Reviewed By: Orvid Differential Revision: D3275427 fbshipit-source-id: 466baa342e2e0c4751e9c96d1e660cffb90e0634
-
Lucian Grijincu authored
Summary: abs(-INT_MIN) is UB. Avoid it by first casting the number to its unsigned equivalent and then negating that. Reviewed By: yfeldblum Differential Revision: D3280835 fbshipit-source-id: 40922d686173e6467e15d5a6dc2b62ad718349b5
-
Christopher Dykes authored
Summary: MSVC builds of libevent expect `evutil_socket_t` to be `HANDLE` values, but Folly, HHVM, and Thrift all use them as file descriptors. This adds a `folly_event_set` function that always expects a file descriptor rather than a socket. This also changes the places in Folly that use it. Reviewed By: mzlee, yfeldblum Differential Revision: D2874655 fbshipit-source-id: 66cfd86fd69a9fbac30d150445e4814cd5ca799e
-
Subodh Iyengar authored
Summary: We shouldn't rely on the internal buffer size of openssl for errors. This makes it more explicit. Reviewed By: knekritz Differential Revision: D3285918 fbshipit-source-id: 452bf16a3de151d0aa79c774f2fdfc1e08ee6f9c
-
- 10 May, 2016 1 commit
-
-
Neel Goyal authored
Summary: Add NETWOR_ERROR to switch so it doesn't fall into Invalid Exception block. Differential Revision: D3282448 fbshipit-source-id: 2cc5d21e436e6ac8f2f6581d99341ac47cf5b023
-