1. 07 Feb, 2017 1 commit
    • Phil Willoughby's avatar
      Run clang-format over Format*.h · 9773e441
      Phil Willoughby authored
      Summary:
      Changes are planned, this will make it easier for the new code to look good
      without making the older code look weird.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4514839
      
      fbshipit-source-id: 43f8cd7d85901e1915cc434a0f4b5fd6bce1ec7a
      9773e441
  2. 06 Feb, 2017 2 commits
    • Christopher Dykes's avatar
      Support compiling in C++14 mode · 3259ce0e
      Christopher Dykes authored
      Summary:
      The rest of Folly isn't dependent on C++17 mode in MSVC, so modify this to support not having it enabled.
      This will make adoption easier as C++17 mode acts on the things the standard says are removed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4509919
      
      fbshipit-source-id: f4644f5f5ba78de8ab5192b89ac6320767b51084
      3259ce0e
    • Sven Over's avatar
      execute callbacks as rvalue references · 8898db44
      Sven Over authored
      Summary:
      Callable objects may implement a separate `operator()` for when
      they are called as rvalue references. For example, `folly::partial`
      will move captured objects to the function call when invoked as
      rvalue reference. That allows e.g. to capture pass a `unique_ptr`
      to `folly::partial` for a function that takes a `unique_ptr` by
      value or rvalue-reference.
      
      Callbacks for `folly::Future`s are only ever executed once. They
      may consume captured data. If the callback is an object that
      implements a `operator()() &&`, then that one should be invoked.
      
      This diff makes sure, callbacks passed to `folly::Future` are
      invoked as rvalue references.
      
      Reviewed By: ericniebler, fugalh
      
      Differential Revision: D4404186
      
      fbshipit-source-id: 9f33e442a634acb8797183d3d869840d85bd5d15
      8898db44
  3. 04 Feb, 2017 2 commits
    • Andrey Ignatov's avatar
      Expose testing callbacks from AsyncSocketTest2. · ef2e3d4b
      Andrey Ignatov authored
      Summary:
      `TestConnectionEventCallback` and `TestAcceptCallback` are very handy and can
      be used in other tests outside folly. Specifically I'm going to use them in
      `ConnectHookTest`. It'll also allow to avoid copy/paste in `TransparentTlsTest`.
      
      Reviewed By: plapukhov
      
      Differential Revision: D4507461
      
      fbshipit-source-id: dfaa97e26036ebb11da17a53d4a73431a295f4d4
      ef2e3d4b
    • Matt Glazar's avatar
      Fix environ enumeration on Apple platforms · c847b1b4
      Matt Glazar authored
      Summary:
      environ is documented to not work very well from .dylib-s (dynamic libraries) on macOS. Use the _NSGetEnviron function instead to get a pointer to environ.
      
      <crt_externs.h> is missing from some iOS SDKs, so forward-declare _NSGetEnviron in such cases.
      
      Reviewed By: Orvid, mzlee
      
      Differential Revision: D4491044
      
      fbshipit-source-id: 886d19bdd63dea14225992446b7ba132faf35054
      c847b1b4
  4. 03 Feb, 2017 3 commits
    • Xuli Liu's avatar
      Expose more functions/constructors on BucketedTimeSeries · c10a6640
      Xuli Liu authored
      Summary: Currently BucketedTimeSeries does not expose enough functions to allow assessing its data, therefore there is no way to do serialization/deserialization. Adding functions/constructors to support this.
      
      Reviewed By: simpkins
      
      Differential Revision: D4500075
      
      fbshipit-source-id: 656ac8a208547d8d3fadf9ea150606b6e74775c9
      c10a6640
    • Mark Logan's avatar
      Add ContainerT&& ctors to sorted_vector_map and sorted_vector_set. · b90498bc
      Mark Logan authored
      Summary:
      Add ContainerT&& ctors to sorted_vector_map and sorted_vector_set,
      to support more efficient bulk-construction of these containers. With the
      prior constructors, the only way to do bulk-construction efficiently was
      by using the iterator constructors with a pre-sorted range. If you didn't
      have a presorted range, you would need to make a temporary container in
      order to get a sorted range. Repeatedly calling insert() without a sorted
      range is quadratic, hence not an option.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4491299
      
      fbshipit-source-id: 041c546578f44ee6928c5506e8d8191092143b12
      b90498bc
    • Mark Logan's avatar
      Fix worst-case quadratic behavior of iterator constructors and range insert() · 3ffcb010
      Mark Logan authored
      Summary:
      The iterator constructors and the range insert() method previously
      had quadratic runtime if given an unsorted range. This is now fixed. We
      append the entire range to the container, sort that subrange, and merge it
      into the already-sorted container. Sorting and merging is skipped when possible.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4493534
      
      fbshipit-source-id: e6d73b5c19e374001f9e340ff527c5257bef2ca3
      3ffcb010
  5. 02 Feb, 2017 2 commits
    • Pádraig Brady's avatar
      Fix build failure with GCC 5 · 30db459f
      Pádraig Brady authored
      Summary:
      GCC 5 doesn't recognize LOG(FATAL) as [[noreturn]],
      so remove [[noreturn]] to avoid that warning and build failure.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4484625
      
      fbshipit-source-id: ca129ca3a52239becd7d80f99107e64745bf8838
      30db459f
    • Christopher Dykes's avatar
      Correct the API of some functions in the portability headers · 23688fa8
      Christopher Dykes authored
      Summary: They were based on the signatures of the original functions as defined by MSVC. They should be based on the signatures as defined by Posix instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4471711
      
      fbshipit-source-id: 8a6fd60ba2b326ca57058c119fc77c46f1d21d10
      23688fa8
  6. 01 Feb, 2017 4 commits
    • Yedidya Feldblum's avatar
      Assorted cleanups for folly/portability/BitsFunctexcept.h · 55e591f9
      Yedidya Feldblum authored
      Summary: [Folly] Assorted cleanups for `folly/portability/BitsFunctexcept.h`.
      
      Reviewed By: Orvid, smeenai
      
      Differential Revision: D4492264
      
      fbshipit-source-id: 5e85ac2ad96ef84627cc5473ec0b16c4c9b5da26
      55e591f9
    • Scott Michelson's avatar
      MPMCQueue Wrapper with priorities · cf24f985
      Scott Michelson authored
      Summary: In many cases where MPMCQueue would be used, it's useful to be able to prioritize requests. This implements a thin wrapper on MPMCQueue to accomplish this (albeit in a bit of a memory inefficient way)
      
      Reviewed By: haijunz
      
      Differential Revision: D4465498
      
      fbshipit-source-id: 6630b80ccf3138b5c135e7f7f281133b37d82b4d
      cf24f985
    • Christopher Dykes's avatar
      Swap a few APIs to reduce sign and implicit truncations required to work with it · 41365ea6
      Christopher Dykes authored
      Summary: This results in a more uniform API within Folly, allowing for a more uniform API to use outside of Folly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4471471
      
      fbshipit-source-id: f798a6498bd1a05ed12adea362ff4aedd25789ee
      41365ea6
    • Christopher Dykes's avatar
      Use std::chrono::high_resolution_clock for folly::Benchmark · e0b75e77
      Christopher Dykes authored
      Summary: `clock_gettime(CLOCK_REALTIME)` is based on `std::system_clock` on Windows, but that only has a resolution that's the same as `FILETIME` (100s of nanoseconds), so modernize things and use `std::chrono::high_resolution_clock` which is intended for this purpose.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4476671
      
      fbshipit-source-id: 3db1debc8f408f689b5c9fe1966a72b8dad4da93
      e0b75e77
  7. 31 Jan, 2017 3 commits
    • Igor Adamski's avatar
      FunctionScheduler - set running_ when it has actually started running · b6916a3a
      Igor Adamski authored
      Summary:
      When start() throws because of reasons (in my case it was std::system_error("Resource temporarily unavailalble") coming from std::thread constructo)
      and during the exception propagation we will have to destroy FunctionScheduler then
      thread_.join() in shutdown will throw again.
      This diff sets running_ after the thread is created.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4469816
      
      fbshipit-source-id: cde54dfbf39f04d3ea9dfa02a65295f5440e5ea4
      b6916a3a
    • Phil Willoughby's avatar
      Require compile-time constant format strings to `shellify` · 84d872be
      Phil Willoughby authored
      Summary:
      Because it's impossible to require that a parameter to a function is a compile-time constant string this replaces `shellify()` with the user-defined-literal suffix `_shellify()`.
      
      It's trivial to convert previously-correct code: `shellify("whatever {}", A)` => `"whatever {}"_shellify(A)`
      
      The previous `folly::shellify()` API is still present as a transition measure. Compilers will issue a deprecation warning if it is used.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4435512
      
      fbshipit-source-id: 6639cd91280dc72108e47a8a7775c5160a4e644f
      84d872be
    • Michael Lee's avatar
      crt_externs.h is not available on all platforms · 0cd1f847
      Michael Lee authored
      Summary: Different deployments of don't always have access to crt_externs.h.
      
      Reviewed By: yfeldblum, Orvid
      
      Differential Revision: D4480621
      
      fbshipit-source-id: f0b18d15fa253d6ba28dee68859cf9a34bf41255
      0cd1f847
  8. 30 Jan, 2017 2 commits
    • Michael Lee's avatar
      Fix folly/Makefile.am · d1af84b6
      Michael Lee authored
      Summary: Missed a `\`
      
      Reviewed By: Orvid
      
      Differential Revision: D4483602
      
      fbshipit-source-id: 91451c3476756125abdbd0dd98ab9fb38bcf2c32
      d1af84b6
    • Michael Lee's avatar
      Split up experimental/TestUtil · ceac4e9e
      Michael Lee authored
      Summary: TestUtil is primarily a temporary file and temporary directory.  Split out the env variable manipulation into a different file.
      
      Reviewed By: Orvid
      
      Differential Revision: D4482071
      
      fbshipit-source-id: 9d1a4a08010a8fad270aa56a7e1432829eb6484c
      ceac4e9e
  9. 29 Jan, 2017 1 commit
    • Michael Lee's avatar
      char ** enivron is inconsistent on some platforms · 0637780a
      Michael Lee authored
      Summary: The forward declaration of `extern char ** environ` is inconsistent on some platforms.
      
      Reviewed By: strager, Orvid
      
      Differential Revision: D4474856
      
      fbshipit-source-id: c73a7c7d5a247e962fab06aeb65df7815f0e3bcb
      0637780a
  10. 28 Jan, 2017 2 commits
    • Jason Rahman's avatar
      RFC: Include timeout duration in exception message · 0ea1868e
      Jason Rahman authored
      Summary: For debugging purposes, it's often extremely useful to have the duration of the expired timeout in the exception message (in case the timeout was excessively low, or to understand exactly how long the operation ran before failing due to timeout). Here we make a best effort to include the timeout when possible.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4476038
      
      fbshipit-source-id: f2d0aa5e1f6367a3cfe20579c27577ab91fd8d9c
      0ea1868e
    • Christopher Dykes's avatar
      Actually do the stress test on RCURefCount and make the TLRefCountTest not take 2 minutes · dc3979b0
      Christopher Dykes authored
      Summary: Adjusting the iteration count significantly reduces the runtime of the `TLRefCount.Stress` test to ~5 seconds. Working with that same timeframe, we can get away with increasing the iteration count of the (now tested) `RCURefCount.Stress` test to 100k, up from it's previous 10k.
      
      Reviewed By: markisaa
      
      Differential Revision: D4477750
      
      fbshipit-source-id: 6a89dbb65f460655db0cb33926cc331dc1904f1c
      dc3979b0
  11. 27 Jan, 2017 4 commits
    • Phil Willoughby's avatar
      Namespace rename from UpperCamelCase to snake_case · 581791b3
      Phil Willoughby authored
      Summary:
      `folly::literals` is to `folly` what `std::literals` is to `std`.
      
      More importantly we should be consitent;  snake_case is how other folly sub-namespaces are named, such as:
      
      `array_detail`
      `apply_tuple`
      `format_value`
      `threadlocal_detail`
      `recordio_helpers`
      `exception_tracer`
      
      Reviewed By: ericniebler
      
      Differential Revision: D4468281
      
      fbshipit-source-id: de10bec74c9a38f387d62bd55da947291c23970b
      581791b3
    • Angelo Failla's avatar
      Implemented IPAddressV6::getMacAddressFromLinkLocal · dd71ee63
      Angelo Failla authored
      Summary: It is possible to extract a MAC address from a link-local IPv6 address. This diff provides the logic for it.
      
      Reviewed By: simpkins
      
      Differential Revision: D4461970
      
      fbshipit-source-id: cb4a5d774c3b4a20716d1742c961e02952ddf80d
      dd71ee63
    • Christopher Dykes's avatar
      Move the Environment portability header to the stdlib header · c7b4aca6
      Christopher Dykes authored
      Summary: This completely kills the environment portability header, which was among the earliest, and was created before the general convention of splitting based on the header they are in, in the standard library, existed. The functions that were defined in it are expected to be in stdlib, so move them there.
      
      Reviewed By: mzlee
      
      Differential Revision: D4462502
      
      fbshipit-source-id: c4549b9d1ea623644223db4365b81507f443ad5e
      c7b4aca6
    • Christopher Dykes's avatar
      Make most implicit integer truncations and sign conversions explicit · fa172175
      Christopher Dykes authored
      Summary:
      This makes a large number of implicit truncations and sign conversions into explicit casts, in preparation for eventually enabling `-Wconversion` on Folly.
      This set of changes should have zero semantic change.
      
      This focuses on the core of Folly and leaves the tests alone for the most part. A future diff will cleanup the warnings in the tests as well.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4454096
      
      fbshipit-source-id: af1e1831675a804ec5679266c30c1fae62e8c35c
      fa172175
  12. 26 Jan, 2017 1 commit
    • Christopher Dykes's avatar
      Add __builtin___clear_cache to the portability headers · cc0ca971
      Christopher Dykes authored
      Summary:
      HHVM uses this heavily in it's ARM JIT, so provide an implementation. With GCC & Clang this function is a no-op on x86_64 where the requirement doesn't exist, so do the same in the portability header.
      This doesn't include the Windows portability header on x64 specifically because it is a very heavy header and this is currently very lightweight.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4451032
      
      fbshipit-source-id: 0af57448577635f9cd690ea9b09ce46a244191e1
      cc0ca971
  13. 25 Jan, 2017 6 commits
    • Daniel Sommermann's avatar
      Add ability to set custom SSLContext on TestSSLServer · d0d34d8e
      Daniel Sommermann authored
      Summary:
      This is needed if you want to test other scenarios where the
      server has other OpenSSL settings.
      
      Differential Revision: D4463587
      
      fbshipit-source-id: ffd4019e921649dee703363b2ff028b4d8063210
      d0d34d8e
    • Michael Lee's avatar
      Re-Gate setenv/unsetenv · 2eab3687
      Michael Lee authored
      Summary: `setenv`/`unsetenv` is not always declared the same way on all of the places folly is compiled.
      
      Reviewed By: matbd
      
      Differential Revision: D4462056
      
      fbshipit-source-id: 6dd68f6fc5a6a435f145cbaa43bee02b5fa7170c
      2eab3687
    • Daniel Sommermann's avatar
      Split out SSL test server for reuse · f1317625
      Daniel Sommermann authored
      Summary:
      The TestSSLServer is useful to have on its own for reuse. This
      diff separates it out to make reuse possible.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4457976
      
      fbshipit-source-id: 1fe6b71e930859ef04487e29047dcf603a79834b
      f1317625
    • Christopher Dykes's avatar
      Fix JemallocNodumpAllocator when compiled without folly-config.h · 904ebc63
      Christopher Dykes authored
      Summary: HHVM compiles without `folly-config.h`, so this was preventing us from updating to the newest version of Folly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4456890
      
      fbshipit-source-id: ed118ff0cf7f254a5f99be68f171d1b34ebf5c5c
      904ebc63
    • Petr Lapukhov's avatar
      Add disableTransparentTls call · a73e2ed6
      Petr Lapukhov authored
      Summary: Similar to AsyncSocket, allow setting reserved sockopt after bind(). This will be recognized by intercepted accept4() call and forked sockets will properly have the TLS flag disabled.
      
      Reviewed By: djwatson
      
      Differential Revision: D4458831
      
      fbshipit-source-id: fa753b9d849bd661563364d36229113f7abb0ee0
      a73e2ed6
    • Christopher Dykes's avatar
      Actually allow SFINAE to occur with setThreadName · eb8b2d91
      Christopher Dykes authored
      Summary:
      It wasn't actually SFINAE the way it was setup previously, which meant it was just a hard error under MSVC.
      Whoops.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4453702
      
      fbshipit-source-id: 5be600fb5ecdc8255795fefbd37c1fe26e7266dd
      eb8b2d91
  14. 24 Jan, 2017 3 commits
    • Mathieu Baudet's avatar
      folly: remove unused includes · b1974960
      Mathieu Baudet authored
      Summary:
      Found with our include analysis tool.
      
      I had to tweak `portability/Environment.h` to avoid a false positive breaking win32.
      
      Reviewed By: yfeldblum, Orvid
      
      Differential Revision: D4452463
      
      fbshipit-source-id: e2e862e204892037ddde8815218e4deab1bfbb06
      b1974960
    • Ryan Wilson's avatar
      Add needsPeerVerification function to check if peer cert should be verified · a857f83b
      Ryan Wilson authored
      Summary:
      This patch adds a function to AsyncSSLSocket, so the user can check if the peer cert
      should be verified. This allows the user to implement custom logic for peer cert validation.
      
      Reviewed By: Orvid
      
      Differential Revision: D4456402
      
      fbshipit-source-id: 2f8a5c932d0341d6c9290bcb52264dd4fa174263
      a857f83b
    • Christopher Dykes's avatar
      Ensure portability/Windows.h is included before OpenSSL headers · a393e1cc
      Christopher Dykes authored
      Summary: Because OpenSSL is evil to Windows, and you have to forcefully include winsock2 before winsock.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4453742
      
      fbshipit-source-id: 3b1b5b1f999722559693164148245f52b1e94104
      a393e1cc
  15. 20 Jan, 2017 4 commits
    • Igor Zinkovsky's avatar
      fix use-after-free in addFunctionOnce · 61d6143a
      Igor Zinkovsky authored
      Summary: see title
      
      Reviewed By: meyering
      
      Differential Revision: D4441266
      
      fbshipit-source-id: 4a8f589e2995a463e54b3979035a623824acf39e
      61d6143a
    • Maged Michael's avatar
      Made atomics generic in hazptr_owner member functions · dd5a72f2
      Maged Michael authored
      Summary:
      As suggested by the C++ committee in November 2016, made atomics generic to allow other atomic types (e.g.,  folly::DeterministicAtomic<T*>),
      
      Also removed obsolete comments.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D4443355
      
      fbshipit-source-id: d9e21a959f2c7e3dd07c0ed4808236da80ef6dcd
      dd5a72f2
    • Christopher Dykes's avatar
      Define AF_LOCAL in the socket portability layer · 3866e5d3
      Christopher Dykes authored
      Summary: It's the exact same as `PF_LOCAL`, and is used interchangibly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4439558
      
      fbshipit-source-id: fd1ff813db5349369fc77888dfd854fc36a2a3be
      3866e5d3
    • Kyle Nekritz's avatar
      Clear OpenSSL error stack after loading certificate file. · d9793261
      Kyle Nekritz authored
      Summary: SSL_CTX_load_verify_locations interally end up using X509_load_cert_crt_file, which has an unchecked call to X509_STORE_add_cert. This can fail and add an error to the error stack without causing SSL_CTX_load_verify_locations to return an error.
      
      Reviewed By: siyengar
      
      Differential Revision: D4442017
      
      fbshipit-source-id: a4cf7f5ee2c18d90d5d61baf3acb99ffca6b8af0
      d9793261