1. 04 Mar, 2016 1 commit
    • Michael Lee's avatar
      Have internal tests use folly::Random instead of rand_r · a1b77701
      Michael Lee authored
      Summary: rand_r is not provided on all platforms, so use `folly::Random` instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3000351
      
      fb-gh-sync-id: 45df3e1957c4b529ab2d2cb4db13b71d13dcef5d
      shipit-source-id: 45df3e1957c4b529ab2d2cb4db13b71d13dcef5d
      a1b77701
  2. 03 Mar, 2016 5 commits
    • Marcelo Juchem's avatar
      Adding DynamicConverter support for enums · 863a22ad
      Marcelo Juchem authored
      Summary:DynamicConverter doesn't currently support reading enums.
      This diff addresses that by adding an enum specialization that uses integers as its underlying implementation.
      A follow-up is to handle both integers and strings, but that would require a way to parse strings into enums like Thrift static reflection provides (see https://github.com/facebook/fbthrift/blob/d17b072daddbd318f9afaa5562100eaba0f890e3/thrift/lib/cpp2/fatal/folly_dynamic-inl.h#L88,L92.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3002569
      
      fb-gh-sync-id: 27bf4a9d5a7844762f5311e2c777606a0e7753f0
      shipit-source-id: 27bf4a9d5a7844762f5311e2c777606a0e7753f0
      863a22ad
    • Michael Lee's avatar
      Fix printing of uint64_t in ConvTest · 6a7158dc
      Michael Lee authored
      Summary:uint64_t is an unsigned long for 64-bit, but a long long int
      for 32-bit.  `%lu` can cause truncation in certain implementations of
      libc.
      
      Reviewed By: ngoyal
      
      Differential Revision: D3007568
      
      fb-gh-sync-id: bbb1896c9727cbff413ac73ff0caa12bae5d8a6a
      shipit-source-id: bbb1896c9727cbff413ac73ff0caa12bae5d8a6a
      6a7158dc
    • Neel Goyal's avatar
      Add service identity to SSL socket and use in ticket cache · 41e2f6d4
      Neel Goyal authored
      Summary:Allow applications to specify a service identity tied to an SSLSocket
      that can be used as a ticket cache key.
      
      Further, add the cache key to the SSL_SESSION object and serialize it.
      
      Reviewed By: siyengar
      
      Differential Revision: D2991005
      
      fb-gh-sync-id: 25a5ddbb66bd9da2084159136cbe4d55b9e00f28
      shipit-source-id: 25a5ddbb66bd9da2084159136cbe4d55b9e00f28
      41e2f6d4
    • Kyle Nekritz's avatar
      Use false start with ALPN. · c85159a3
      Kyle Nekritz authored
      Summary: All the work we do in SSLContext to check the cipher and NPN usage is actually completely unnecessary since OpenSSL internally checks the cipher and use of ALPN/NPN after you set the SSL_MODE option (see `ssl3_can_cutthrough()` in ssl_lib.c). This just sets the option on the SSLContext instead.
      
      Reviewed By: siyengar
      
      Differential Revision: D3002063
      
      fb-gh-sync-id: 4514faf9ed2eb42a6e41d9e682b2c8aa52c46691
      shipit-source-id: 4514faf9ed2eb42a6e41d9e682b2c8aa52c46691
      c85159a3
    • Kyle Nekritz's avatar
      Fix AsyncSSLSocket handshake error reporting. · 4e0e47bb
      Kyle Nekritz authored
      Summary:https://www.openssl.org/docs/manmaster/ssl/SSL_get_error.html
      OpenSSL errors are a pain to deal with and we were handling several cases
      incorrectly, resulting in a ton of "DH lib" errors when none were likely
      actually DH lib errors.
      
      Reviewed By: siyengar
      
      Differential Revision: D2999084
      
      fb-gh-sync-id: b3182be2c199f79ed341af7dbf7524197a838584
      shipit-source-id: b3182be2c199f79ed341af7dbf7524197a838584
      4e0e47bb
  3. 02 Mar, 2016 5 commits
    • Christopher Dykes's avatar
      Create the strings.h portability header · 4f782bbf
      Christopher Dykes authored
      Summary: Windows doesn't have it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2990219
      
      fb-gh-sync-id: e9fe96905ec415874f0e2732b0685f3e7ad5d018
      shipit-source-id: e9fe96905ec415874f0e2732b0685f3e7ad5d018
      4f782bbf
    • Michael Lee's avatar
      Android does not always provide posix_memalign · b99ed996
      Michael Lee authored
      Summary: We could provide `posix_memalign` instead as part of portability, but I am not sure how to tell whether or not it will be available.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2991432
      
      fb-gh-sync-id: 587314d43779f3b8fead2c41ed05016e6350f2ee
      shipit-source-id: 587314d43779f3b8fead2c41ed05016e6350f2ee
      b99ed996
    • Daniel Colascione's avatar
      Improve RWSpinLock.h cautionary comment · ab442ee8
      Daniel Colascione authored
      Reviewed By: yfeldblum
      
      Differential Revision: D2998122
      
      fb-gh-sync-id: a113ba1a474da8a46052091acadb90c95d3c0c28
      shipit-source-id: a113ba1a474da8a46052091acadb90c95d3c0c28
      ab442ee8
    • Michael Lee's avatar
      i386 -fPIC requires `%ebx` · 3d90e863
      Michael Lee authored
      Summary:On i368 (until, I'm lead to believe i686) `%ebx` is used for the PIC register. Thus, when we use cpuid, we clobber that register and gcc loudly complains:
      
        folly/CpuId.h: In member function 'virtual void CpuId_Simple_Test::TestBody()':
        folly/CpuId.h:67:61: error: PIC register clobbered by 'ebx' in 'asm'
             __asm__("cpuid" : "=a"(n) : "a"(0) : "ebx", "edx", "ecx");
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2991229
      
      fb-gh-sync-id: ee8795e36a4c173147d61e26c9590ec5da1d02b5
      shipit-source-id: ee8795e36a4c173147d61e26c9590ec5da1d02b5
      3d90e863
    • Christopher Dykes's avatar
      Create the portability header for time.h · 76344f7b
      Christopher Dykes authored
      Summary: Although MSVC does have time.h, and does have equivelents of these functions, those have slightly different semantics so we have to wrap them.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2983613
      
      fb-gh-sync-id: 676cd524ffa834a4250a2acc76aa1200eefe62cc
      shipit-source-id: 676cd524ffa834a4250a2acc76aa1200eefe62cc
      76344f7b
  4. 01 Mar, 2016 8 commits
    • Daniel Colascione's avatar
      Stern warning about spinlocks · 602d3f04
      Daniel Colascione authored
      Summary: Spinlocks are a bad idea most of the time.
      
      Reviewed By: rickbrew
      
      Differential Revision: D2996558
      
      fb-gh-sync-id: e86f1f0a084bda0c16759e979201db2e18102555
      shipit-source-id: e86f1f0a084bda0c16759e979201db2e18102555
      602d3f04
    • Michael Lee's avatar
      Enclose global variables in an anonymous namespace. · bba211d3
      Michael Lee authored
      Summary: This causes a symbol collision tests are compiled into a library.
      
      Differential Revision: D2991357
      
      fb-gh-sync-id: 912be0df42216004a07213d62b68ff3f4713beb0
      shipit-source-id: 912be0df42216004a07213d62b68ff3f4713beb0
      bba211d3
    • Christopher Dykes's avatar
      Listen to the Windows docs in portability/SysTime.cpp · ad1f7851
      Christopher Dykes authored
      Summary:As-per the documenation of FILETIME:
      
      "Do not cast a pointer to a FILETIME structure to either a ULARGE_INTEGER* or __int64* value because it can cause alignment faults on 64-bit Windows."
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2989434
      
      fb-gh-sync-id: cf57d569a785e0eb7225b346730bf2ed4c50dc55
      shipit-source-id: cf57d569a785e0eb7225b346730bf2ed4c50dc55
      ad1f7851
    • Christopher Dykes's avatar
      Add timeradd and timersub to the sys/time.h portability header · 3a152643
      Christopher Dykes authored
      Summary: I missed these in my initial diff.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2989977
      
      fb-gh-sync-id: 0efb92286a8aed91ec1d394572cd709e5b6b37ab
      shipit-source-id: 0efb92286a8aed91ec1d394572cd709e5b6b37ab
      3a152643
    • Dave Watson's avatar
      Fix narenas size · d2f85c15
      Dave Watson authored
      Summary:Changed from size_t to unsigned in a recent tp2 update
      https://github.com/jemalloc/jemalloc/blame/3c07f803aa282598451eb0664cc94717b769a5e6/test/unit/mallctl.c
      
      Reviewed By: jasone, mhlakhani
      
      Differential Revision: D2991755
      
      fb-gh-sync-id: 46f2be722a30706333eac6428f4183ca9cb85543
      shipit-source-id: 46f2be722a30706333eac6428f4183ca9cb85543
      d2f85c15
    • Michael Lee's avatar
      to_string is not supported everywhere · aa8dce11
      Michael Lee authored
      Summary: Also remove an extra `#include <strstream>` from JsonTest.cpp as it is no longer necessary.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2991381
      
      fb-gh-sync-id: 386b8281726d034933ebdc26733dd35dc5ace949
      shipit-source-id: 386b8281726d034933ebdc26733dd35dc5ace949
      aa8dce11
    • Michael Lee's avatar
      Remove unecessary int main from MemoryTest · b363d9f7
      Michael Lee authored
      Summary: We do not need this main function, so remove it.
      
      Reviewed By: markisaa
      
      Differential Revision: D2992000
      
      fb-gh-sync-id: 30bc0734af0f61e047276dab9639ae29cc999bbb
      shipit-source-id: 30bc0734af0f61e047276dab9639ae29cc999bbb
      b363d9f7
    • Subodh Iyengar's avatar
      Add conversion constructors for Future · 692cc4b1
      Subodh Iyengar authored
      Summary:previously we were not able to do
      
      Future<Base> f = makeFuture<Derived>();
      
      This is because Future did not declare a conversion
      constructor.
      
      Adding a proper conversion ctor for Future is very
      tricky because of the way Core is managed under the hood.
      Core is not movable, and cannot be moved otherwise we
      would have to retain pointers to the Future and Promises which
      pointed to a particular core. This would be inefficient.
      
      Instead we compromise and allow a very small subset of conversions
      from objects whose templated types are convertible and also the
      sizes of their Cores are also the same. As a result, we can
      convert between types like unique_ptrs however not always between
      full objects.
      
      Reviewed By: jsedgwick
      
      Differential Revision: D2943775
      
      fb-gh-sync-id: 7c2388f2fb49d789c80ae2477814e960a099771b
      shipit-source-id: 7c2388f2fb49d789c80ae2477814e960a099771b
      692cc4b1
  5. 29 Feb, 2016 1 commit
    • Pavlo Kushnir's avatar
      Fix SingletonThreadLocal · 8edf04da
      Pavlo Kushnir authored
      Summary: it's really thread local at this point :)
      
      Reviewed By: jmswen
      
      Differential Revision: D2989668
      
      fb-gh-sync-id: 423b9214922c92318181a62c583f58cd204b52e3
      shipit-source-id: 423b9214922c92318181a62c583f58cd204b52e3
      8edf04da
  6. 27 Feb, 2016 1 commit
  7. 26 Feb, 2016 2 commits
    • Andrii Grynenko's avatar
      Fix folly::ThreadLocal to have unique singleton in dev builds · a7d7c07c
      Andrii Grynenko authored
      Summary:This re-uses StaticSingletonManager which was previously used to fix the same issue in folly::Singleton.
      
      Because of the same issue we can no longer use static thread_local for the ThreadEntry. We now rely on pthread_getspecific/pthread_setspecific instead and use static thread_local ThreadEntry* only as a cache (to improve perf).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2978526
      
      fb-gh-sync-id: cf1d9044afc27b62bd50a1ed931c0c420ae7107e
      shipit-source-id: cf1d9044afc27b62bd50a1ed931c0c420ae7107e
      a7d7c07c
    • Christopher Dykes's avatar
      Create the sys/time.h portability header · 398424e8
      Christopher Dykes authored
      Summary: Windows doesn't have it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2979215
      
      fb-gh-sync-id: 030bdcaa44deb18834903705a26369ce0b13abc6
      shipit-source-id: 030bdcaa44deb18834903705a26369ce0b13abc6
      398424e8
  8. 25 Feb, 2016 7 commits
    • Michael Lee's avatar
      Split tests into test and benchmarks. · 705e7518
      Michael Lee authored
      Summary:Split up
      
        io/test/IOBufCursorTest
        test/BitsTest
        test/CacheLocalityTest
        test/CallOnceTest
        test/ConvTest
        test/LoggingTest
        test/MemoryIdlerTest
        test/RandomTest
        test/ThreadLocalTest
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2973132
      
      fb-gh-sync-id: 9dadbdf49a31e82c3a2e34c2fdb6a2b47aa0928d
      shipit-source-id: 9dadbdf49a31e82c3a2e34c2fdb6a2b47aa0928d
      705e7518
    • Michael Lee's avatar
      Split FileTest to a smaller test and an extended test · 68b1410c
      Michael Lee authored
      Summary: FileTest pulls in subprocess and does a lot more than just directly test File.h
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2971641
      
      fb-gh-sync-id: 16e1096ab3b0f6434a26f84c889ebb082ee3f210
      shipit-source-id: 16e1096ab3b0f6434a26f84c889ebb082ee3f210
      68b1410c
    • Christopher Dykes's avatar
      Create a portability header for working with environment variables · 7bc876aa
      Christopher Dykes authored
      Summary:Because `extern char** environ` is not the correct way to access environ on Windows.
      This also implements setenv and unsetenv for Windows, which means that TestUtils no longer needs to be disabled for the Windows build.
      
      Reviewed By: mzlee
      
      Differential Revision: D2973704
      
      fb-gh-sync-id: 84db7db3494cf183fcbcc25063cb0482ef84ebf4
      shipit-source-id: 84db7db3494cf183fcbcc25063cb0482ef84ebf4
      7bc876aa
    • Nathan Bronson's avatar
      shorten SharedMutex tests that timeout under ASAN · ddb7850c
      Nathan Bronson authored
      Summary:New ASAN options are more thorough but slower, resulting
      in timeouts for some tests.  Decreasing their internal loop count to
      compensate.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2973982
      
      fb-gh-sync-id: 67391936d0b4930f99d00358ebb93a1b3ee87140
      shipit-source-id: 67391936d0b4930f99d00358ebb93a1b3ee87140
      ddb7850c
    • Jonathan Kron's avatar
      Fixing AtomicHashArrayTest ASan Test Failure · 2203c927
      Jonathan Kron authored
      Summary: Both of these tests will unavoidably fail on ASan because of shared library loads, and indestructable objects.  Disabling ASAN testing for these test files.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2968169
      
      fb-gh-sync-id: d2acc71b40541af5e10f15d5087a7c07da05453d
      shipit-source-id: d2acc71b40541af5e10f15d5087a7c07da05453d
      2203c927
    • Christopher Dykes's avatar
      Minor MSVC issues · fd108f7f
      Christopher Dykes authored
      Summary:MSVC doesn't let you have unicode characters in a narrow string without using a utf-8 literal string.
      AsyncTransport needs the definition of IOBuf because of how the standard library implements a few things.
      And longs are only 32-bit under Windows.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2973973
      
      fb-gh-sync-id: c2f3e848e740a65c575598991d43dd79360ec1e3
      shipit-source-id: c2f3e848e740a65c575598991d43dd79360ec1e3
      fd108f7f
    • Orvid King's avatar
      Explicit vtordisp for MSVC · a2962ba8
      Orvid King authored
      Summary:Because sometimes things are just different.
      
      MSVC warns about the `dynamic_cast` done against this class because the class's declaration doesn't show that it would need a vtordisp. While I don't believe the `dynamic_cast` in question is actually called in either the constructor or destructor paths for the class, better to be safe and force the disp to be created.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2887490
      
      Pulled By: Orvid
      
      fb-gh-sync-id: 821a6fc820087ac7120fffd9f8b95a26c2b4e71b
      shipit-source-id: 821a6fc820087ac7120fffd9f8b95a26c2b4e71b
      a2962ba8
  9. 24 Feb, 2016 3 commits
    • Sven Over's avatar
      folly/futures: keep Core alive until callback has returned · 914e877b
      Sven Over authored
      Summary:Callbacks passed to e.g. folly::Future::then (or
      folly::Future::ensure) may delete the promise that keeps the
      Core of the same future alive. The Core must protect itself from
      destruction during callback execution.
      
      This commit also adds a unit test to check for correct behaviour
      in the "self destruction" scenario. The test should usually pass
      even without the fix in Core.h. However, when you run the test
      in Valgrind or ASAN, it will report problems unless the fix in
      Core.h is applied.
      
      Reviewed By: mhx
      
      Differential Revision: D2938094
      
      fb-gh-sync-id: 22796e168e1876ef2e3c7d7619da020be6a22073
      shipit-source-id: 22796e168e1876ef2e3c7d7619da020be6a22073
      914e877b
    • Andrii Grynenko's avatar
      Fix double definition for templated folly::Singletons · 9dd08403
      Andrii Grynenko authored
      Summary: Allow createGlobal() to create dependent objects.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2963111
      
      fb-gh-sync-id: 8e4da48a7a1000934963396b423e8eff98a8aade
      shipit-source-id: 8e4da48a7a1000934963396b423e8eff98a8aade
      9dd08403
    • Yedidya Feldblum's avatar
      Fix Build: folly/test/IndestructibleTest.cpp under LSAN · 2739d937
      Yedidya Feldblum authored
      Summary:[Folly] Fix Build: `folly/test/IndestructibleTest.cpp` under LSAN.
      
      Leaks of Meyers singletons are ignored automatically, while normal locals are not. So we make our instances be Meyers singletons.
      
      Differential Revision: D2968368
      
      fb-gh-sync-id: 385ac4491d9a105885af82d85354af929d69cc80
      shipit-source-id: 385ac4491d9a105885af82d85354af929d69cc80
      2739d937
  10. 23 Feb, 2016 4 commits
    • Andrii Grynenko's avatar
      Fix SIOF in folly/io/async/Request.cpp · 9c3e3be0
      Andrii Grynenko authored
      Summary: Use Meyers singleton instead.
      
      Reviewed By: afrind
      
      Differential Revision: D2963282
      
      fb-gh-sync-id: 7aec36e7cc3b0ab09b2b093202f40d5b0d399f4d
      shipit-source-id: 7aec36e7cc3b0ab09b2b093202f40d5b0d399f4d
      9c3e3be0
    • Beny Luo's avatar
      AsyncSocketException: add detailed information in error message · 787e185c
      Beny Luo authored
      Summary: AsyncSocketException: add detailed information in error message
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2953030
      
      fb-gh-sync-id: a5e26036657ecc6c74ad0369650730a2af13bead
      shipit-source-id: a5e26036657ecc6c74ad0369650730a2af13bead
      787e185c
    • Michael Lee's avatar
      Split benchmarks and tests · d1d243a6
      Michael Lee authored
      Summary:Benchmarks need their own main function, which means they
      aren't really useful in cases we can't use a custom main function.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2962104
      
      fb-gh-sync-id: 25bdc6e5a8bdf8c3aa94d393207a74797b2e1234
      shipit-source-id: 25bdc6e5a8bdf8c3aa94d393207a74797b2e1234
      d1d243a6
    • Lucian Grijincu's avatar
      folly: symbolizer: dwarf: don't fallback to linear scan if address missing from .debug_aranges · efe4f93c
      Lucian Grijincu authored
      Summary:Presence of .debug_aranges implies user expects fast address lookup.
      Some addresses might not be avaialble in .debug_aranges.
      
      Don't do slow lookup in .debug_info, as it can lead to unexpected slowdowns.
      
      override-unit-failures
      
      Reviewed By: philippv
      
      Differential Revision: D2965323
      
      fb-gh-sync-id: 405daefd57cdff4344fd231c5f5b7ff4dcd9df8c
      shipit-source-id: 405daefd57cdff4344fd231c5f5b7ff4dcd9df8c
      efe4f93c
  11. 22 Feb, 2016 3 commits
    • Neel Goyal's avatar
      Fix OSX build · d45626d0
      Neel Goyal authored
      Summary: Fixed the build using the homebrew instructions
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2960409
      
      fb-gh-sync-id: 218b879f26b3baab09676cac51787bf36d0b4bed
      shipit-source-id: 218b879f26b3baab09676cac51787bf36d0b4bed
      d45626d0
    • Nathan Bronson's avatar
      fix SIOF in CacheLocality.h's AccessSpreader · bf385e23
      Nathan Bronson authored
      Summary:This diff moves all data accessed during
      AccessSpreader<>::current(x) into the .data segment, avoiding SIOF
      without adding indirection or dynamic gating as would be the case for
      normal singleton-like constructs.  The diff also trims the AccessSpreader
      API to include only those methods that people actually seem to use.
      
      Reviewed By: djwatson
      
      Differential Revision: D2945205
      
      fb-gh-sync-id: 847e31adc4450217f4ed0575686be261fb504d7c
      shipit-source-id: 847e31adc4450217f4ed0575686be261fb504d7c
      bf385e23
    • Michael Lee's avatar
      Remove extra `int main`s from unit tests. · d31eb712
      Michael Lee authored
      Summary: test/common/TestMain.cpp should provide the necessary initialization.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2947245
      
      fb-gh-sync-id: 75b9d241673667badf4dc8fb81285c60cbb8166a
      shipit-source-id: 75b9d241673667badf4dc8fb81285c60cbb8166a
      d31eb712