1. 04 Nov, 2019 1 commit
    • Bo Dong's avatar
      remove the namespace dependency of BENCHMARK_COUNTERS · b35bea8f
      Bo Dong authored
      Summary: BENCHMARK_COUNTERS tests need to set `using folly::UserCounters` or `using namespace folly`. Add absolute namespace path in the macro to get rid of this requirement.
      
      Reviewed By: Orvid
      
      Differential Revision: D18271700
      
      fbshipit-source-id: 084041142b7c245e3c861943570416ac89ea6c34
      b35bea8f
  2. 02 Nov, 2019 1 commit
  3. 01 Nov, 2019 5 commits
    • Luca Wehrstedt's avatar
      Support non-byte and non-1d memoryviews when converting to IOBufs · 8718c37f
      Luca Wehrstedt authored
      Summary:
      Using `shape[0]` as the length of the IOBuf means using the number of _elements_ along the first dimension, rather than the total number of bytes in the memoryview. Thus
      - if the element size is not 1 byte, this will get only a fraction of the memory;
      - if the memoryview is shapeless, the code will segfault;
      - if the memoryview is multidimensional, it will only get a fraction of the memory (and, if the memory is C-contiguous, it will be an odd slice: in a 2x3 memoryview, it will get the entire first row and half of the second).
      
      Perhaps the above was intentional, but I believe that when converting a shaped and typed object to an unshaped and untyped buffer, it's more intuitive to ignore the type and size and just look at the memory backing it.
      
      I also added a check to ensure the view is contiguous. IOBufs can't represent a non-contiguous buffer, except by using a chain, which however in this case could have an arbitrary unbounded length, making it unadvisable. Alternatively we could copy the memory, but this is probably not what the user would expect. Disallowing this seems the safest option.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D18006273
      
      fbshipit-source-id: f21dbb462266eee68f1a5ce0ecea85b1a46e0a8b
      8718c37f
    • David Carlier's avatar
      FreeBSD build fix regarding native parts. · 328ab26d
      David Carlier authored
      Summary: Pull Request resolved: https://github.com/facebook/folly/pull/1248
      
      Reviewed By: yfeldblum
      
      Differential Revision: D18094432
      
      Pulled By: Orvid
      
      fbshipit-source-id: 115afedc62be8881941cfb4d0e02748be349763f
      328ab26d
    • Amol Bhave's avatar
      create unorderedReduceSemiFuture method · 9b2ba17c
      Amol Bhave authored
      Summary:
      create a unorderedReduceSemiFuture method that returns a SemiFuture
      instead of just a Future.
      
      Reviewed By: mhlakhani
      
      Differential Revision: D18248163
      
      fbshipit-source-id: ba1f8ede93c95ea0b877ac306056e7e38c4452e6
      9b2ba17c
    • Chad Austin's avatar
      enable -Wunused-exception-parameter · 1966558d
      Chad Austin authored
      Summary:
      Build folly with -Werror and -Wunused-exception-parameter to prevent
      them from sneaking back in.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D18232483
      
      fbshipit-source-id: 7154d3dfec6c672aa3aa46299456bd3c4d757709
      1966558d
    • Luca Niccolini's avatar
      windows build · 323cd710
      Luca Niccolini authored
      Summary: ^
      
      Reviewed By: mjoras
      
      Differential Revision: D18256970
      
      fbshipit-source-id: 4d07b961ab5ab145b620d9e10fa67116236bbf80
      323cd710
  4. 31 Oct, 2019 2 commits
    • Mingtao Yang's avatar
      ssl: Only invoke RAND_poll on older versions of OpenSSL · af0d320e
      Mingtao Yang authored
      Summary:
      Only do RAND_poll on older versions of OpenSSL.
      
      RAND_poll is not required on OpenSSL 1.1.0+, as the RNG is implicitly seeded. On OpenSSL 1.1.1., RAND_poll became aliased to RAND_add. With some custom RNG implementations that did not implement RAND_add, (e.g. python-cryptography's osrandom implementation), this would manifest as a failure.
      
      Reviewed By: ngoyal, yfeldblum
      
      Differential Revision: D16786271
      
      fbshipit-source-id: 4fb7876525006517c3e554d70736d7071bd3b4e3
      af0d320e
    • Matt Ma's avatar
      Change QMS iterator to take const QMS* in constructor. · 73c65d44
      Matt Ma authored
      Summary: The functions in QMS are all marked as const already.
      
      Reviewed By: philippv
      
      Differential Revision: D18240371
      
      fbshipit-source-id: 113f5c968207f0a4ff9b780cd43de43cb90f758b
      73c65d44
  5. 30 Oct, 2019 3 commits
    • Mikhail Shatalov's avatar
      Removed unnecessary cast · 55cb92ef
      Mikhail Shatalov authored
      Summary: Floating-point scale conversion doesn't require a cast
      
      Reviewed By: yfeldblum
      
      Differential Revision: D18052505
      
      fbshipit-source-id: 3d87a916da5cec03b23041908066a9862fab6fde
      55cb92ef
    • Felix Handte's avatar
      Check Compression Context Pool Doesn't Return nullptr · 9aea2092
      Felix Handte authored
      Summary:
      Minor improvements to the CompressionContextPool. Although it should be
      impossible, this diff checks that we do not retrieve `nullptr`s out of the
      stack.
      
      I also threw in a quick refactor to not store a copy of the deleter in the
      RTPDeleter.
      
      Reviewed By: terrelln
      
      Differential Revision: D18131791
      
      fbshipit-source-id: eda1856720fdb86a69ee0a2a867b25bb20ebc319
      9aea2092
    • Sermet Iskin's avatar
      Add peer name auth (i.e. server auth) support to AsyncSSLSocket through SSLContext · d9d30843
      Sermet Iskin authored
      Summary:
      This change adds basic support for server auth through AsyncSSLSocket and fills in the implementation under SSLContext::authenticate() to support peer name verification.
      
      virtual void SSLContext::authenticate(
            bool checkPeerCert,
            bool checkPeerName,
            const std::string& peerName = std::string());
      
      SSLContext::authenticate signature has parameters intended for server-auth scenarios, but it doesn't have an implementation underneath it and silently ignores the checkPeerName and peerName parameters. This change implements the intended behavior through OPENSS's SSL_set1_host. The intended behavior is as follows:
      * When checkPeerName is false, the behavior is unchanged and this should cover all existing use cases.
      * When checkPeerName is true, either the peerName or the servername (suppled through the AsyncSSLSocket constructor) in this given order is expected to be present in the SAN or CN of the peer's certificate as described in [the OPENSSL documentation](https://www.openssl.org/docs/man1.1.0/man3/SSL_add1_host.html). Socket will error our if neither name is supplied. Wildcard matching when checking the name is intentionally disabled for now since there is no known need for it at the moment.
      
      Unit tests are added to cover both positive and negative scenarios around SSL server name auth.
      
      Reviewed By: mingtaoy
      
      Differential Revision: D18162775
      
      fbshipit-source-id: d275f5e2e9e760895c27ba9d73cf8b6a2d0ff599
      d9d30843
  6. 28 Oct, 2019 7 commits
    • Yedidya Feldblum's avatar
      Use cacheline_aligned in LifoSem · f4fb4266
      Yedidya Feldblum authored
      Summary: [Folly] Use simpler `cacheline_aligned` v.s. `CachelinePadded` in `LifoSem`, per comments atop `CachelinePadded`.
      
      Reviewed By: aary
      
      Differential Revision: D18166262
      
      fbshipit-source-id: 807c668666fbbc9c16d5f449fa20234e56b29042
      f4fb4266
    • Kyle Nekritz's avatar
      Handle close_notify as standard writeErr in AsyncSSLSocket. · c321eb58
      Kyle Nekritz authored
      Summary: Fixes CVE-2019-11934
      
      Reviewed By: mingtaoy
      
      Differential Revision: D18020613
      
      fbshipit-source-id: db82bb250e53f0d225f1280bd67bc74abd417836
      c321eb58
    • Giuseppe Ottaviano's avatar
      Improve EliasFanoCodingTest coverage of 64-bits values and corner cases · df7b6652
      Giuseppe Ottaviano authored
      Summary: `EliasFanoCoding` is used with 64-bits values in some logic, but we have no tests for that. Also, we weren't testing the larges admissible value. Finally, clarify in the comments what the various size types are for.
      
      Reviewed By: philippv
      
      Differential Revision: D18146549
      
      fbshipit-source-id: e97ec9e1344db6e56a591a9b4c77c5929e10b22b
      df7b6652
    • generatedunixname89002005287564's avatar
      Remove dead includes in folly/functional · acf4b746
      generatedunixname89002005287564 authored
      Reviewed By: Orvid
      
      Differential Revision: D18169787
      
      fbshipit-source-id: 1580df251c9ae87e9c268f1599d8c61232b48a4d
      acf4b746
    • Yedidya Feldblum's avatar
      Use attribute-based suppression in free-invoke traits · fd84bde1
      Yedidya Feldblum authored
      Summary: [Folly] Use attribute-based suppression in free-invoke traits v.s. pragma-based suppression for suppressing warnings about unused functions.
      
      Reviewed By: vitaut
      
      Differential Revision: D18112966
      
      fbshipit-source-id: 2519f94d4ff4609c8418d4fd009a24acefe23ab2
      fd84bde1
    • Yedidya Feldblum's avatar
      Remove classname from free-invoke traits inner names · 00319abe
      Yedidya Feldblum authored
      Summary: [Folly] Remove `classname` from free-invoke traits inner names - it's already present for disambiguation in the outer private namespace name. Also adjust some of the names better to fit a singular pattern.
      
      Reviewed By: vitaut
      
      Differential Revision: D18112947
      
      fbshipit-source-id: 0a3e76a72a16fff7d4c127c2994a8c38639083e2
      00319abe
    • Yedidya Feldblum's avatar
      is_constexpr_default_constructible · 67a1d1d5
      Yedidya Feldblum authored
      Summary: [Folly] `is_constexpr_default_constructible`, for deciding whether a type is constexpr default-constructible.
      
      Reviewed By: vitaut
      
      Differential Revision: D18092652
      
      fbshipit-source-id: a4642726a9495135abca1506c5dbb3d57c0e0558
      67a1d1d5
  7. 27 Oct, 2019 1 commit
    • Yedidya Feldblum's avatar
      Cut folly/futures/exercises/ · db30bf97
      Yedidya Feldblum authored
      Summary: [Folly] Cut `folly/futures/exercises/`, which was never finished.
      
      Reviewed By: fugalh
      
      Differential Revision: D18149557
      
      fbshipit-source-id: ec5654c2d37996c42a3673523422bafe2a64c89e
      db30bf97
  8. 26 Oct, 2019 6 commits
  9. 25 Oct, 2019 2 commits
    • Yedidya Feldblum's avatar
      Change an ifdef to a constexpr ternary · 2cb34df8
      Yedidya Feldblum authored
      Summary: [Folly] Change an `#ifdef` to a constexpr ternary for `MemoryMapping`.
      
      Reviewed By: meyering
      
      Differential Revision: D18024494
      
      fbshipit-source-id: 7ee040891ecee9bccf46af1dc43e54946e676c70
      2cb34df8
    • Wez Furlong's avatar
      getdeps: memoize eden prefetched dirs · 60df0a6b
      Wez Furlong authored
      Summary:
      currently, the implementation of `eden prefetch` calls into
      a mercurial function that is overly eager in making network connections,
      which results in what should be a fast NOP second prefetch call taking
      more time than is desirable.
      
      This diff adds a little cache to avoid repeatedly calling prefetch
      for the same directory more than once for the life of the getdeps
      process.
      
      Given the usage pattern of getdeps it is OK that we don't provide
      a way to invalidate this cache.
      
      Reviewed By: fanzeyi
      
      Differential Revision: D18005408
      
      fbshipit-source-id: 0ec3f477da1043a5a715704b512c81fcfaa0acde
      60df0a6b
  10. 24 Oct, 2019 1 commit
    • Yedidya Feldblum's avatar
      Optimize Function::operator() codegen · 6e0a487c
      Yedidya Feldblum authored
      Summary:
      [Folly] Optimize `Function::operator()` codegen for size and speed.
      
      * Avoid translating between values and references for trivially-copyable values.
      * Avoid shifting all arguments to make room for the function object address.
      
      In the optimal case, the codegen for calling a `Function` with many arguments translates into just a `jmp`.
      
      See:
      * https://github.com/thecppzoo/zoo/commits/master/inc/zoo/AnyCallable.h
      * https://github.com/bloomberg/bde/blob/3.38.0.1/groups/bsl/bslstl/bslstl_function.h
      * https://github.com/bloomberg/bde/blob/3.38.0.1/groups/bsl/bslmf/bslmf_forwardingtype.h
      
      Given this example code:
      
      ```lang=c++,name=check.cpp
      extern "C" void check_0(folly::Function<void()>& f) { f(); }
      extern "C" void check_1(int i, folly::Function<void(int)>& f) { f(i); }
      extern "C" void check_2(int i, int j, folly::Function<void(int, int)>& f) { f(i, j); }
      extern "C" void check_3(int i, int j, int k, folly::Function<void(int, int, int)>& f) { f(i, j, k); }
      extern "C" void check_4(int i, int j, int k, int l, folly::Function<void(int, int, int, int)>& f) { f(i, j, k, l); }
      ```
      
      Before:
      
      ```name=check.o
      0000000000000000 <check_0>:
         0:   ff 67 30                jmp    QWORD PTR [rdi+0x30]
      0000000000000000 <check_1>:
         0:   55                      push   rbp
         1:   48 89 f0                mov    rax,rsi
         4:   48 89 e5                mov    rbp,rsp
         7:   48 83 ec 10             sub    rsp,0x10
         b:   89 7d fc                mov    DWORD PTR [rbp-0x4],edi
         e:   48 8d 75 fc             lea    rsi,[rbp-0x4]
        12:   48 89 c7                mov    rdi,rax
        15:   ff 50 30                call   QWORD PTR [rax+0x30]
        18:   c9                      leave
        19:   c3                      ret
      0000000000000000 <check_2>:
         0:   55                      push   rbp
         1:   48 89 d0                mov    rax,rdx
         4:   48 89 e5                mov    rbp,rsp
         7:   48 83 ec 10             sub    rsp,0x10
         b:   89 7d f8                mov    DWORD PTR [rbp-0x8],edi
         e:   89 75 fc                mov    DWORD PTR [rbp-0x4],esi
        11:   48 8d 55 fc             lea    rdx,[rbp-0x4]
        15:   48 8d 75 f8             lea    rsi,[rbp-0x8]
        19:   48 89 c7                mov    rdi,rax
        1c:   ff 50 30                call   QWORD PTR [rax+0x30]
        1f:   c9                      leave
        20:   c3                      ret
      0000000000000000 <check_3>:
         0:   55                      push   rbp
         1:   48 89 c8                mov    rax,rcx
         4:   48 89 e5                mov    rbp,rsp
         7:   48 83 ec 10             sub    rsp,0x10
         b:   89 7d f4                mov    DWORD PTR [rbp-0xc],edi
         e:   89 75 f8                mov    DWORD PTR [rbp-0x8],esi
        11:   89 55 fc                mov    DWORD PTR [rbp-0x4],edx
        14:   48 8d 4d fc             lea    rcx,[rbp-0x4]
        18:   48 8d 55 f8             lea    rdx,[rbp-0x8]
        1c:   48 8d 75 f4             lea    rsi,[rbp-0xc]
        20:   48 89 c7                mov    rdi,rax
        23:   ff 50 30                call   QWORD PTR [rax+0x30]
        26:   c9                      leave
        27:   c3                      ret
      0000000000000000 <check_4>:
         0:   55                      push   rbp
         1:   4c 89 c0                mov    rax,r8
         4:   48 89 e5                mov    rbp,rsp
         7:   48 83 ec 10             sub    rsp,0x10
         b:   89 7d f0                mov    DWORD PTR [rbp-0x10],edi
         e:   89 75 f4                mov    DWORD PTR [rbp-0xc],esi
        11:   89 55 f8                mov    DWORD PTR [rbp-0x8],edx
        14:   89 4d fc                mov    DWORD PTR [rbp-0x4],ecx
        17:   4c 8d 45 fc             lea    r8,[rbp-0x4]
        1b:   48 8d 4d f8             lea    rcx,[rbp-0x8]
        1f:   48 8d 55 f4             lea    rdx,[rbp-0xc]
        23:   48 8d 75 f0             lea    rsi,[rbp-0x10]
        27:   48 89 c7                mov    rdi,rax
        2a:   ff 50 30                call   QWORD PTR [rax+0x30]
        2d:   c9                      leave
        2e:   c3                      ret
      ```
      
      After:
      
      ```name=check.o
      0000000000000000 <check_0>:
         0:   ff 67 30                jmp    QWORD PTR [rdi+0x30]
      0000000000000000 <check_1>:
         0:   ff 66 30                jmp    QWORD PTR [rsi+0x30]
      0000000000000000 <check_2>:
         0:   ff 62 30                jmp    QWORD PTR [rdx+0x30]
      0000000000000000 <check_3>:
         0:   ff 61 30                jmp    QWORD PTR [rcx+0x30]
      0000000000000000 <check_4>:
         0:   41 ff 60 30             jmp    QWORD PTR [r8+0x30]
      ```
      
      Reviewed By: luciang
      
      Differential Revision: D17523239
      
      fbshipit-source-id: beed0bae827aad8290e807374e8596f71f98ce99
      6e0a487c
  11. 23 Oct, 2019 3 commits
    • Lewis Baker's avatar
      Add .startInlineUnsafe() method to folly::coro::Task · f01cb070
      Lewis Baker authored
      Summary: This allows the caller to guarantee that the coroutine starts executing on the current thread. This can be necessary for correctness in some situations, where having the coroutine enqueued to the executor, as `.start()` does, and potentially allowing other code to run in the meantime could invalidate some assumptions.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D18076197
      
      fbshipit-source-id: a6c5c226f2d7189f37e8f9713a30896767e9b8e9
      f01cb070
    • Kaz Ondo's avatar
      Initialize addrStorage on stack · 1b99423a
      Kaz Ondo authored
      Summary:
      MemorySanitizer was failing due to uninitialized memory in the stack.
      
      ```
      ==596112==WARNING: MemorySanitizer: use-of-uninitialized-value
      [testserver][INFO]: IOBuff received. Len = 128
          #0 0x9d4b21 in folly::SocketAddress::updateUnixAddressLength(unsigned int) xplat/folly/SocketAddress.cpp:710:7
          #1 0x9d4740 in folly::SocketAddress::setFromSockaddr(sockaddr_un const*, unsigned int) xplat/folly/SocketAddress.cpp:338:3
      
        Uninitialized value was created by an allocation of 'addrStorage' in the stack frame of function '_ZN5folly17AsyncServerSocket12handler
      ReadyEtNS_13NetworkSocketEt'
          #0 0x7de840 in folly::AsyncServerSocket::handlerReady(unsigned short, folly::NetworkSocket, unsigned short) xplat/folly/io/async/Asyn
      cServerSocket.cpp:835
      ```
      
      Differential Revision: D18086738
      
      fbshipit-source-id: f36013b157d7b34d3b29c08d4533f01be1a1a8c9
      1b99423a
    • Alexey Spiridonov's avatar
      Don't use private googletest API in TestUtils.h · d32d4344
      Alexey Spiridonov authored
      Summary:
      Until [very recently](https://github.com/google/googletest/pull/2517), `googletest` did not print the skip message in any shape or form, so nothing can possibly depend on us customizing the skip message here.
      
      The default is perfectly fine, let's keep it simple.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D18051635
      
      fbshipit-source-id: f7b889b0adf5e34a70c2579a34748bb159809b3c
      d32d4344
  12. 22 Oct, 2019 5 commits
  13. 21 Oct, 2019 3 commits
    • Yedidya Feldblum's avatar
      Guard the forward declaration of fibers::Baton · b440ee45
      Yedidya Feldblum authored
      Summary: [Folly] Guard the forward declaration of `fibers::Baton` by the same condition which determines whether `fibers::Baton` is ever used in futures.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D17962552
      
      fbshipit-source-id: 2494026999cd170c36adec91108732254212abf1
      b440ee45
    • Yedidya Feldblum's avatar
      Prefer a C++ symbol over back-defining MAP_POPULATE · 54a20c00
      Yedidya Feldblum authored
      Summary: [Folly] Prefer a C++ symbol over back-defining `MAP_POPULATE`.
      
      Reviewed By: nbronson
      
      Differential Revision: D18024313
      
      fbshipit-source-id: 7f3b754a7911d6947e5a6f34860f9f0d3833aa51
      54a20c00
    • Yedidya Feldblum's avatar
      Add missing inline to co_current_executor · 979cdf43
      Yedidya Feldblum authored
      Summary: [Folly] Add missing `inline` to `co_current_executor`.
      
      Reviewed By: ericniebler
      
      Differential Revision: D18034078
      
      fbshipit-source-id: 8c212ef6278112cc8e90075494a3038d9111bb64
      979cdf43