1. 10 Dec, 2017 1 commit
    • Yedidya Feldblum's avatar
      Fix signed integer overflow in StaticTracepointTest.cpp · 01530690
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix signed integer overflow in `StaticTracepointTest.cpp`.
      
      It is undefined behavior and is caught by UBSAN in some test runs.
      
      Reviewed By: Orvid
      
      Differential Revision: D6528445
      
      fbshipit-source-id: e4a199e9005b57bcd93c8c4b69f37ccb1e072bdf
      01530690
  2. 09 Dec, 2017 3 commits
    • Yedidya Feldblum's avatar
      Split Baton wait methods into fast and slow paths · bca34971
      Yedidya Feldblum authored
      Summary:
      [Folly] Split `Baton` wait methods into fast and slow paths.
      
      Force-inline the fast paths, and force-outline the slow paths.
      
      Reviewed By: magedm
      
      Differential Revision: D6501992
      
      fbshipit-source-id: 611e26b3cfeef01eb8d3a3500ae3ebc26bee6e86
      bca34971
    • Yedidya Feldblum's avatar
      Fix UBSAN failure in RangeTest.cpp with libstdc++-v4.9 · 2d3c3346
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix UBSAN failure in `RangeTest.cpp` with `libstdc++-v4.9`.
      
      The implementation of `std::array` in `libstdc++-v4.9` has undefined behavior in the case of the zero-length array - dereferencing (but immediately taking the address again) of `nullptr`. This is fixed in `libstdc++-v5`.
      
      Reviewed By: ot
      
      Differential Revision: D6528614
      
      fbshipit-source-id: 26be6bdc28d9e6dc6e6293a4d4ecffd769c01413
      2d3c3346
    • Yedidya Feldblum's avatar
      replace std::dequeue with UMPMCQueue in UnboundedBlockingQueue · b92bbedc
      Yedidya Feldblum authored
      Summary: As above. Thanks magedm for giving us this beautiful piece of equipment!
      
      Reviewed By: magedm
      
      Differential Revision: D6488661
      
      fbshipit-source-id: 95aa9646ca1ea937bb1d055e9baa037896c3161e
      b92bbedc
  3. 08 Dec, 2017 4 commits
  4. 07 Dec, 2017 10 commits
    • Maged Michael's avatar
      FlatCombining: Use SaturatingSemaphore instead of multi-poster and non-blocking Baton · a9197170
      Maged Michael authored
      Summary: Use SaturatingSemaphore instead of multi-poster and non-blocking Baton, in preparation for restoring Baton to being single-poster and with blocking wait().
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D6510619
      
      fbshipit-source-id: eed87beabc1b698080b8e41c746d570d30804ce7
      a9197170
    • Yedidya Feldblum's avatar
      Fix crash in exception_wrapper::get_exception<> · 39018ad5
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix crash in `exception_wrapper::get_exception<>`.
      
      When the contained object is unthrown and does not inherit `std::exception`, `get_exception` templated over a type that does not inherit `std::exception` must throw and catch internally and may then return a pointer to the internally thrown object, which has since been deallocated.
      
      Attempting to dereference that pointer is undefined behavior is correctly caught by ASAN as heap-use-after-free.
      
      Fix it by storing objects not inheriting `std::exception` using only the `std::exception_ptr` representation.
      
      As a downside, we no longer get the small-object optimization or the non-throwing optimization for objects which do not inherit `std::exception`. But this is not likely to be terribly concerning in practice.
      
      Reviewed By: ericniebler
      
      Differential Revision: D6504911
      
      fbshipit-source-id: 0065de911733b5cab87be55e7e4e47f0a9c09140
      39018ad5
    • Yedidya Feldblum's avatar
      Use simpler tags for ctor dispatch in exception_wrapper · a335700f
      Yedidya Feldblum authored
      Summary:
      [Folly] Use simpler tags for ctor dispatch in `exception_wrapper`.
      
      The tags do not need to be `std::integral_constant`, but can just be arbitrary empty types.
      
      Also format the usage sites of the tags.
      
      Reviewed By: ericniebler
      
      Differential Revision: D6506417
      
      fbshipit-source-id: 377359086d94fc1a8bf8eebf6f8b058ff544829f
      a335700f
    • Stepan Palamarchuk's avatar
      Fix DCHECKs in IOBufQueue · fd0b3090
      Stepan Palamarchuk authored
      Summary: glog actually tries to pull srtings from these pointers when the checks fail, which obfuscates the error
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6506886
      
      fbshipit-source-id: 0283e02aecaa248b84fca1433d3f29f92c37b2e6
      fd0b3090
    • Mehdi Bouaziz's avatar
      Removed dead IsSomeVector · fe9d8cad
      Mehdi Bouaziz authored
      Summary: deadcode
      
      Reviewed By: ddrcoder
      
      Differential Revision: D6498754
      
      fbshipit-source-id: 9dda0ade6928d648b8938a06b185e430753f2318
      fe9d8cad
    • Andrii Grynenko's avatar
      Fix SignalHandlerTest with ASAN · f19e2b86
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D6503762
      
      fbshipit-source-id: f82b88c401979761053004eadd2e4c6a74f05f9c
      f19e2b86
    • Adam Simpkins's avatar
      logging: allow partial updates to log handler settings · 171c3652
      Adam Simpkins authored
      Summary:
      This updates the LogHandlerConfig code to allow changing the settings on an
      existing log handler without listing all of its existing options from scratch.
      
      This also changes the syntax of the basic log handler configuration string to
      use a colon to separate the log handler name+type from the options list.  In
      other words, rather than specifying `default=stream,stream=stderr,async=true`
      you now say `default=stream:stream=stderr,async=true`.
      
      The primary motivation for this change is to make it easy for users to switch
      the async setting for the default log handler on or off.  Callers can now
      specify `default:async=true` to easily enable async mode on the default log
      handler without having to completely re-list the full settings for the default
      handler.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6494228
      
      fbshipit-source-id: 52a296f800a5456f0c3aa10546298139c8db52fc
      171c3652
    • Adam Simpkins's avatar
      logging: split FileHandlerFactory into two classes · 9e1a1ce1
      Adam Simpkins authored
      Summary:
      Split FileHandlerFactory into separate FileHandlerFactory and
      StreamHandlerFactory classes, where FileHandlerFactory only handles logging to
      files by path name, and StreamHandlerFactory only supports logging to stdout or
      stderr.
      
      The primary motivation for this is to allow logging to stdout or stderr in some
      cases without allowing arbitrary files to be opened by FileHandlerFactory.
      This can be achieved now by registering StreamHandlerFactory but not
      FileHandlerFactory.  This makes it safer to allow controlling logging
      configuration via command line flags even in setuid binaries.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6494226
      
      fbshipit-source-id: a3ec371ca4266424d07dff20be18e6e13c057593
      9e1a1ce1
    • Adam Simpkins's avatar
      logging: add a StandardLogHandlerFactory helper class · f805cad2
      Adam Simpkins authored
      Summary:
      This moves some of the FileHandlerFactory code out into a new
      StandardLogHandlerFactory helper class.  This will make it easier in the future
      to add new LogHandlerFactory implementations that create StandardLogHandler
      objects.
      
      In particular, I plan to use this soon to split FileHandlerFactory into two
      separate classes: one for writing to files on disk and a separate class for
      writing to stdout or stderr.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6494227
      
      fbshipit-source-id: 52e24250d020d21a5395d2a68fa5bd40bb32fbd4
      f805cad2
    • Louis Brandy's avatar
      fix ubsan-detected UMR in TemporaryFile · 989c5112
      Louis Brandy authored
      Summary:
      Move constructors are just like any other constructors. `this` is not in a valid state. You aren't supposed to destroy `this` before move-constructing it.
      
      This was detected by ubsan stress runs.
      
      UBSAN report:
      
      ```
      [ RUN      ] TemporaryFile.moveCtor
      folly/experimental/TestUtil.cpp:91:20: runtime error: load of value 3, which is not a valid value for type 'bool'
       [ failed: 1 ]
       ````
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6501500
      
      fbshipit-source-id: 83bd0525ac2c1f5951f70f5596034bb6cb0ca985
      989c5112
  5. 06 Dec, 2017 4 commits
  6. 05 Dec, 2017 6 commits
    • Pingjia Shan's avatar
      Fix RequestContext held too long issue in EventBase · bda67fde
      Pingjia Shan authored
      Summary:
      Upon debugging for the attached task, it appears to me the problem are in two places:
      . After a callback has been run, context_ wasn't reset
      . After a callback has been canceled, context_ wasn't reset
      
      In this diff:
      . Fix these two places.
      . Updating unit tests to cover these two cases.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6465788
      
      fbshipit-source-id: 85b3b29dc80c9f3971c85f302385d41ded44fa0e
      bda67fde
    • Aaryaman Sagar's avatar
      Split get_default() into two for deferred default construction and added... · 5a07e203
      Aaryaman Sagar authored
      Split get_default() into two for deferred default construction and added forwarding to speed up default element construction with rvalues
      
      Summary:
      As it stood currently folly::get_default() would unnecessarily
      construct a value into the third parameter, which was unnecessary in the code
      path where the element was found in the map.  Also the default value can be
      forwarded to the return type in the code path where the element is not found
      and an rvalue parameter is passed as the default value
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6390315
      
      fbshipit-source-id: ef692b827d5a36751b4eb1e12042869e8fbba2e5
      5a07e203
    • Dave Watson's avatar
      bitreverse · d7629090
      Dave Watson authored
      Summary:
      Adds a bitreverse function to Bits.h
      
      AFAIK there is no great way to do this on x86, takes ~4-5ns.
      arm has a single instruction we can drop in in the future.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6459283
      
      fbshipit-source-id: 129db196b2fac95386f601ae57843aa87523b915
      d7629090
    • Liang Zhu's avatar
      exclude Unix Domain Socket from setErrMessageCB · d389a330
      Liang Zhu authored
      Summary:
      In the latest stable kernel 4.14.3 as of 2017-12-04, unix domain socket does not support MSG_ERRQUEUE. So recvmsg(MSG_ERRQUEUE) will read application data from unix doamin socket as error message, which breaks the message flow in application. This diff disable setErrMessageCB for Unix Domain Socket.
      
      Both [[ https://github.com/torvalds/linux/blob/master/net/ipv4/tcp.c#L1782 | tcp_recvmsg ]] and [[ https://github.com/torvalds/linux/blob/master/net/ipv4/udp.c#L1571 | udp_recvmsg ]] will check flag MSG_ERRQUEUE and read from error queue.  However, there is nothing about MSG_ERRQUEUE in [[ https://github.com/torvalds/linux/blob/master/net/unix/af_unix.c#L2249 | af_unix ]].
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6479465
      
      fbshipit-source-id: eba2c8650e96466f2b361a42ddf90053d65f19bd
      d389a330
    • Yedidya Feldblum's avatar
      Add missing check against SemiFuture in FutureBase ctor · 67867996
      Yedidya Feldblum authored
      Summary: [Folly] Add missing check against `SemiFuture` in `FutureBase` ctor.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D6469021
      
      fbshipit-source-id: 0ca31461afee4bf64725e065a8cb4d5e933d2013
      67867996
    • Nathan Bronson's avatar
      better error handling in MemoryIdler for inside jails · 879a247a
      Nathan Bronson authored
      Summary:
      /proc may be unavailable in restricted environments, which can
      cause pthread_getattr_np to fail.  This diff adds checking to the return
      code from that function.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6473789
      
      fbshipit-source-id: de016d32f29edf8410808dfb491987692f39e768
      879a247a
  7. 04 Dec, 2017 4 commits
    • Stepan Palamarchuk's avatar
      Improve QueueAppender/IOBufQueue performance · 64072ab5
      Stepan Palamarchuk authored
      Summary:
      Currently QueueAppender needs to follow a chain of 4 indirections (QueueAppender->IOBufQueue->IOBuf(head)->IOBuf(tail)->data).
      This diff adds a cache of writable tail range in IOBufQueue and allows it to be placed externally.
      
      Before this diff on hot path QueueAppender::write<signed char> was ~167 bytes of code (with majority being actually executed), after this diff it's down to ~30 bytes:
        0x0000000000419d10 <+0>:     mov    (%rdi),%rax
        0x0000000000419d13 <+3>:     cmp    %rax,0x8(%rdi)
        0x0000000000419d17 <+7>:     je     0x419d28 <folly::io::QueueAppender::write<signed char>(signed char)+24>
        0x0000000000419d19 <+9>:     mov    %sil,(%rax)
        0x0000000000419d1c <+12>:    addq   $0x1,(%rdi)
        0x0000000000419d20 <+16>:    retq
        0x0000000000419d21 <+17>:    nopl   0x0(%rax)
        0x0000000000419d28 <+24>:    movsbl %sil,%esi
        0x0000000000419d2c <+28>:    jmpq   0x419ca0 <folly::io::QueueAppender::writeSlow<signed char>(signed char)>
      
      With this diff, Thrift serialization performance is improved up to 2x with production workloads (2x for compact, 3x for binary).
      
      Thrift benchmark output:
      Before:
        ============================================================================
        thrift/lib/cpp2/test/ProtocolBench.cpp          relative  time/iter  iters/s
        ============================================================================
        BinaryProtocol_write_Empty                                  58.05ns   17.23M
        BinaryProtocol_write_SmallInt                               75.17ns   13.30M
        BinaryProtocol_write_BigInt                                 74.60ns   13.41M
        BinaryProtocol_write_SmallString                            85.12ns   11.75M
        BinaryProtocol_write_BigString                             802.96ns    1.25M
        BinaryProtocol_write_BigBinary                             174.69ns    5.72M
        BinaryProtocol_write_LargeBinary                           171.81ns    5.82M
        BinaryProtocol_write_Mixed                                 130.97ns    7.64M
        BinaryProtocol_write_SmallListInt                          123.99ns    8.06M
        BinaryProtocol_write_BigListInt                             40.72us   24.56K
        BinaryProtocol_write_BigListMixed                          784.78us    1.27K
        BinaryProtocol_write_LargeListMixed                         98.84ms    10.12
        CompactProtocol_write_Empty                                 64.38ns   15.53M
        CompactProtocol_write_SmallInt                              76.74ns   13.03M
        CompactProtocol_write_BigInt                                83.62ns   11.96M
        CompactProtocol_write_SmallString                           86.05ns   11.62M
        CompactProtocol_write_BigString                            786.18ns    1.27M
        CompactProtocol_write_BigBinary                            184.91ns    5.41M
        CompactProtocol_write_LargeBinary                          182.12ns    5.49M
        CompactProtocol_write_Mixed                                120.89ns    8.27M
        CompactProtocol_write_SmallListInt                         119.74ns    8.35M
        CompactProtocol_write_BigListInt                            43.76us   22.85K
        CompactProtocol_write_BigListMixed                         595.90us    1.68K
        CompactProtocol_write_LargeListMixed                        72.80ms    13.74
        ============================================================================
      After:
        ============================================================================
        thrift/lib/cpp2/test/ProtocolBench.cpp          relative  time/iter  iters/s
        ============================================================================
        BinaryProtocol_write_Empty                                  65.97ns   15.16M
        BinaryProtocol_write_SmallInt                               72.31ns   13.83M
        BinaryProtocol_write_BigInt                                 72.67ns   13.76M
        BinaryProtocol_write_SmallString                            77.56ns   12.89M
        BinaryProtocol_write_BigString                             782.07ns    1.28M
        BinaryProtocol_write_BigBinary                             179.69ns    5.57M
        BinaryProtocol_write_LargeBinary                           182.62ns    5.48M
        BinaryProtocol_write_Mixed                                  91.62ns   10.92M
        BinaryProtocol_write_SmallListInt                           96.22ns   10.39M
        BinaryProtocol_write_BigListInt                             19.65us   50.90K
        BinaryProtocol_write_BigListMixed                          245.69us    4.07K
        BinaryProtocol_write_LargeListMixed                         46.56ms    21.48
        CompactProtocol_write_Empty                                 74.44ns   13.43M
        CompactProtocol_write_SmallInt                              80.35ns   12.45M
        CompactProtocol_write_BigInt                                85.30ns   11.72M
        CompactProtocol_write_SmallString                           82.61ns   12.10M
        CompactProtocol_write_BigString                            784.77ns    1.27M
        CompactProtocol_write_BigBinary                            193.20ns    5.18M
        CompactProtocol_write_LargeBinary                          192.53ns    5.19M
        CompactProtocol_write_Mixed                                 99.78ns   10.02M
        CompactProtocol_write_SmallListInt                         104.77ns    9.54M
        CompactProtocol_write_BigListInt                            25.62us   39.03K
        CompactProtocol_write_BigListMixed                         272.42us    3.67K
        CompactProtocol_write_LargeListMixed                        38.32ms    26.09
        ============================================================================
      
      QueueAppender Benchmark output (although not very representative due to a tight loop):
      Before:
        ============================================================================
        folly/io/test/QueueAppenderBenchmark.cpp        relative  time/iter  iters/s
        ============================================================================
        write_uint8                                                 10.50us   95.20K
        write_uint16                                                 5.48us  182.49K
        write_uint32                                                 2.73us  366.22K
        push_64b                                                     9.77us  102.36K
        push_1024b                                                 112.87us    8.86K
        append                                                      64.21us   15.57K
        preallocate_postallocate_1b                                 16.34us   61.19K
        preallocate_postallocate_4b                                 15.56us   64.26K
        preallocate_postallocate_32b                                22.17us   45.11K
        preallocate_postallocate_256b                              149.55us    6.69K
        ============================================================================
      
      After:
        ============================================================================
        folly/io/test/QueueAppenderBenchmark.cpp        relative  time/iter  iters/s
        ============================================================================
        write_uint8                                                  8.86us  112.81K
        write_uint16                                                 3.91us  255.68K
        write_uint32                                                 2.08us  481.78K
        push_64b                                                     8.24us  121.39K
        push_1024b                                                 115.50us    8.66K
        append                                                      67.52us   14.81K
        preallocate_postallocate_1b                                 13.86us   72.17K
        preallocate_postallocate_4b                                 11.67us   85.71K
        preallocate_postallocate_32b                                20.35us   49.14K
        preallocate_postallocate_256b                              148.57us    6.73K
        ============================================================================
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6427749
      
      fbshipit-source-id: 8495cc74b6106b15d201e37533ae4c0a1abc9d74
      64072ab5
    • Dave Watson's avatar
      add AtFork::unregisterHandler · 7acf192d
      Dave Watson authored
      Summary: Adds an AdFork::unregisterHandler command, such that we can register and unregister fork handlers.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6439796
      
      fbshipit-source-id: b710152f8cf98371c330b484cd5fe42de44e74ac
      7acf192d
    • Maged Michael's avatar
      Unbounded queue · 9a8218df
      Maged Michael authored
      Summary:
      UnboundedQueue supports:
      - SPSC, MPSC, SCMP, MPMC
      - Non-waiting, waiting, and timed consumer operations.
      - Producers never wait or fail (unless out-of-memory).
      - Memory usage grows and shrinks dynamically
      
      ```
      /// UnboundedQueue supports a variety of options for unbounded
      /// dynamically expanding an shrinking queues, including variations of:
      /// - Single vs. multiple producers
      /// - Single vs. multiple consumers
      /// - Blocking vs. spin-waiting
      /// - Non-waiting, timed, and waiting consumer operations.
      /// Producer operations never wait or fail (unless out-of-memory).
      ///
      /// Template parameters:
      /// - T: element type
      /// - SingleProducer: true if there can be only one producer at a
      ///   time.
      /// - SingleConsumer: true if there can be only one consumer at a
      ///   time.
      /// - MayBlock: true if consumers may block, false if they only
      ///   spins. A performance tuning parameter.
      /// - LgSegmentSize (default 8): Log base 2 of number of elements per
      ///   segment. A performance tuning parameter. See below.
      ///
      /// When to use UnboundedQueue:
      /// - If a small bound may lead to deadlock or performance degradation
      ///   under bursty patterns.
      /// - If there is no risk of the queue growing too much.
      ///
      /// When not to use UnboundedQueue:
      /// - If there is risk of the queue growing too much and a large bound
      ///   is acceptable, then use DynamicBoundedQueue.
      /// - If the queue must not allocate on enqueue or it must have a
      ///   small bound, then use fixed-size MPMCQueue or (if non-blocking
      ///   SPSC) ProducerConsumerQueue.
      ///
      /// Template Aliases:
      ///   USPSCQueue<T, MayBlock, LgSegmentSize>
      ///   UMPSCQueue<T, MayBlock, LgSegmentSize>
      ///   USPMCQueue<T, MayBlock, LgSegmentSize>
      ///   UMPMCQueue<T, MayBlock, LgSegmentSize>
      ///
      /// Functions:
      ///   Producer operations never wait or fail (unless OOM)
      ///     void enqueue(const T&);
      ///     void enqueue(T&&);
      ///         Adds an element to the end of the queue.
      ///
      ///   Consumer operations:
      ///     void dequeue(T&);
      ///         Extracts an element from the front of the queue. Waits
      ///         until an element is available if needed.
      ///     bool try_dequeue(T&);
      ///         Tries to extracts an element from the front of the queue
      ///         if available. Returns true if successful, false otherwise.
      ///     bool try_dequeue_until(T&, time_point& deadline);
      ///         Tries to extracts an element from the front of the queue
      ///         if available until the specified deadline.  Returns true
      ///         if successful, false otherwise.
      ///     bool try_dequeue_for(T&, duration&);
      ///         Tries to extracts an element from the front of the queue
      ///         if available for for the specified duration.  Returns true
      ///         if successful, false otherwise.
      ///
      ///   Secondary functions:
      ///     size_t size();
      ///         Returns an estimate of the size of the queue.
      ///     bool empty();
      ///         Returns true only if the queue was empty during the call.
      ///     Note: size() and empty() are guaranteed to be accurate only if
      ```
      
      Reviewed By: djwatson
      
      Differential Revision: D6157613
      
      fbshipit-source-id: db423f86d1d0604d22f6b9c71ea0ed08be32e2a1
      9a8218df
    • Anirudh Ramachandran's avatar
      Add wrapper for getting X509_digest from a cert · 192d78d4
      Anirudh Ramachandran authored
      Summary:
      X509_digest, or the "fingerprint" of the cert, is useful to identify
      certificates with the same CN/SANs. This adds an API to get the SHA1 or SHA256
      digest of a cert.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6457917
      
      fbshipit-source-id: 148a5a2270e938b39065e00d7947c2fc57cd7f75
      192d78d4
  8. 03 Dec, 2017 1 commit
    • Alastair Daivis's avatar
      Statically allocate futex array · 0d13183a
      Alastair Daivis authored
      Summary:
      AFAICT this is currently the only thing preventing the non-dynamic version of Folly's MPMCQueue from being allocation-free on enqueue and dequeue operations. Allocating this with a constant expression should move the allocation from runtime to link (possibly compile?) time, which will let us use it in allocation sensitive contexts.
      
      Feel free to suggest other reviewers, I couldn't find an existing folly reviewer group.
      
      Reviewed By: yfeldblum, agola11, nbronson
      
      Differential Revision: D6447848
      
      fbshipit-source-id: 86b84b19d62f1e1bcecdb9e757a6dfa90597b084
      0d13183a
  9. 02 Dec, 2017 4 commits
    • David Goode's avatar
      allow fiber executor to override fiber options · 4bec077b
      David Goode authored
      Summary: As in title, for eg larger stack size
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6466762
      
      fbshipit-source-id: 303e8732c8bfb64fbd8619163779942fe5f8b5a8
      4bec077b
    • Adam Simpkins's avatar
      add makeSystemError*() helper functions · 20272b4e
      Adam Simpkins authored
      Summary:
      Add makeSystemError() helper functions that are similar to the existing
      throwSystemError() functions but just return the exception rather than throwing
      it.  This is helpful for callers using folly::Expected or folly::Future, where
      they need to return an exception type rather than throwing it.
      
      This also includes comments about the fact that this code is using the wrong
      error category.  The C++ standard indicates that std::generic_category() for
      POSIX errno values.  I am not fixing this as part of this diff, since this
      change has the potential to break existing users, and would need a fair amount
      of testing first.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6456771
      
      fbshipit-source-id: 4724b51b8d4a7f513ae70ea1b0c4f0516cfc205f
      20272b4e
    • Adam Simpkins's avatar
      logging: fix compilation error on older C++ compilers · ad993b99
      Adam Simpkins authored
      Summary:
      Add an explicit `std::move()` around the return value of
      `logConfigToDynamic()`.  This explicit move is required pre-C++14,
      but is not required after DR 1579:
      http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579
      
      Newer versions of g++ and clang no longer require the move.  However gcc
      versions earlier than 5.0 do require it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6466447
      
      fbshipit-source-id: 1b15934490d4966e9b3e5612e0e2ecbb43c979ca
      ad993b99
    • Adam Simpkins's avatar
      logging: update initialization code to use the new LogConfig logic · 6072ce3b
      Adam Simpkins authored
      Summary:
      Replace the initLoggingGlogStyle() function with a more generic initLogging()
      function that accepts a log config string to be parsed with parseLogConfig().
      
      Reviewed By: bolinfest, yfeldblum
      
      Differential Revision: D6342086
      
      fbshipit-source-id: fb1bffd11f190b70e03e2ccbf2b30be08d655242
      6072ce3b
  10. 01 Dec, 2017 3 commits
    • Igor Sugak's avatar
      unify FOLLY_SANITIZE existing uses and add a few new · d08cf162
      Igor Sugak authored
      Reviewed By: yfeldblum
      
      Differential Revision: D6453972
      
      fbshipit-source-id: fa083c0b782188f5f45a2a354045aee03e528829
      d08cf162
    • Adam Simpkins's avatar
      implement chrono conversions for unusual duration types · 730db44f
      Adam Simpkins authored
      Summary:
      Implement conversions between std::chrono::duration and POSIX-style time
      structures even when neither the numerator nor the denominator of the duration
      ratio are 1.
      
      Both of these are done by first converting to an intermediate type where the
      numerator is 1, and then using the conversion routines for that case.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6366647
      
      fbshipit-source-id: 8f9495fb4101cac6d8b4cf0353a679107007b298
      730db44f
    • Dave Watson's avatar
      Move threadlocal_detail::Atfork to its own file · f089f1fd
      Dave Watson authored
      Summary: As title
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6440723
      
      fbshipit-source-id: 3168d7bb616ae0ff3fe42f7584c5a255c4953875
      f089f1fd