1. 19 Nov, 2014 18 commits
    • Nicholas Ormrod's avatar
      Fix build break · 832ecb9f
      Nicholas Ormrod authored
      Summary:
      Change counting index to unsigned to avoid unsigned-signed
      comparison errors.
      
      @build-break
      
      Test Plan:
      fbconfig -r folly && fbmake dbg
      fbmake runtests wangle
      
      Reviewed By: robbert@fb.com, davejwatson@fb.com
      
      Subscribers: sdwilsh, fugalh, njormrod, folly-diffs@
      
      FB internal diff: D1686315
      
      Signature: t1:1686315:1416267974:d8f6075550b9d611790263338dd4f49e7ef451cc
      
      Blame Revision: D1595200
      832ecb9f
    • James Sedgwick's avatar
      Indefinite observers and inline observers · 55ee7359
      James Sedgwick authored
      Summary:
      provides new APIs observe(ObserverPtr<T>) and observe(Observer<T>*) that
      are not associated with a subscription. The latter method avoids allocations at the cost of disowning responsiblity for object lifetimes.
      
      It could be used for batch-allocating filter chains, for instance. I hacked up some recursive templates that would make that easy to do, but
      haven't included them. I'd rather see the first use case and then decide whether to let users set them up themselves or to provide an
      abstraction that makes it easier.
      
      Test Plan: unit
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: folly-diffs@, fugalh, njormrod
      
      FB internal diff: D1595200
      
      Tasks: 5002278
      
      Signature: t1:1595200:1416266578:95c0532af42443fd83e2f94d30790c3c0831ce65
      55ee7359
    • James Sedgwick's avatar
      OutputBufferingHandler · c3ee57ef
      James Sedgwick authored
      Summary:
      see D1618704 and D1604575
      Really need to make a decision about making a push for EventBaseManager everywhere. Getting/setting EBs when there's only ever one seems so silly, but in (e.g.) tests where one-off EBs are used without using the EBM, stuff like this will break.
      
      Test Plan: definitely compiles and sorta works, will write unit tests if the dust settles
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: folly-diffs@, trunkagent, fugalh, njormrod
      
      FB internal diff: D1618727
      c3ee57ef
    • Alex Landau's avatar
      CompactProtocol: readVarint optimizations · 923576ab
      Alex Landau authored
      Summary:
      * Unroll readVarint() - no loops in the fast path
      * Split Cursor::skip() into fast and slow paths
      
      Test Plan:
      ```
      ------ old ------   ------ new ------
      Benchmark                               time/iter  iters/s  time/iter  iters/s        win
      =========================================================================================
      CompactProtocol_read_Empty                13.21ns   75.69M    13.21ns   75.71M      0.03%
      CompactProtocol_read_SmallInt             29.95ns   33.39M    28.96ns   34.53M      3.41%
      CompactProtocol_read_BigInt               67.83ns   14.74M    36.77ns   27.19M     84.46%
      CompactProtocol_read_SmallString          55.72ns   17.95M    54.04ns   18.50M      3.06%
      CompactProtocol_read_BigString           342.93ns    2.92M   332.18ns    3.01M      3.08%
      CompactProtocol_read_BigBinary           186.18ns    5.37M   181.45ns    5.51M      2.61%
      CompactProtocol_read_LargeBinary         190.65ns    5.25M   184.85ns    5.41M      3.05%
      CompactProtocol_read_Mixed               101.97ns    9.81M    97.06ns   10.30M      4.99%
      CompactProtocol_read_SmallListInt        148.09ns    6.75M   139.52ns    7.17M      6.22%
      CompactProtocol_read_BigListInt           71.69us   13.95K    63.34us   15.79K     13.19%
      CompactProtocol_read_BigListMixed          1.26ms   790.67     1.18ms   845.66      6.95%
      CompactProtocol_read_LargeListMixed      139.80ms     7.15   134.68ms     7.42      3.78%
      ```
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent, alandau, bmatheny, njormrod, mshneer, folly-diffs@
      
      FB internal diff: D1681244
      
      Signature: t1:1681244:1416265579:f630c53f9c31788f847d0af72198bbd9e5ea43f1
      923576ab
    • James Sedgwick's avatar
      implicit constructor exception_wrapper(std::exception) · a575384b
      James Sedgwick authored
      Summary: this should address some of the wordiness issues with exception_wrapper, i.e. always having to use make_exception_wrapper
      
      Test Plan: wrote a little test to make sure everything compiles (or doesn't) as expected, not worth committing
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: njormrod, folly-diffs@
      
      FB internal diff: D1679460
      
      Signature: t1:1679460:1416265170:5cd72d95dd855cd4e594dbbc49d0c53d012fbc99
      a575384b
    • James Sedgwick's avatar
      fix potential race/memory corruption in IOThreadPoolExecutor · 0a14b4cc
      James Sedgwick authored
      Summary:
      In unusual but possible circumstances, the EventBase and thus pending tasks will outlive the pool, so we shouldn't keep references of any kind to the pool in the task.
      The only reference we were keeping was used to access the task stats rx subject. Store the subject as a shared ptr and give a copy of the ptr to the Thread object, which is itself
      owned by a shared ptr and captured by every task. I thought this had to do with the thread local leak in mentioned in the test plan of D1682860 but this patch doesn't actually fix that :(
      Thankfully, while task surfing I saw @phillip's awesome D1682698. Patching that in fixes the leak! Woo. Either way, this is more correct.
      
      Test Plan: unit under clang/asan
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent, fugalh, njormrod, folly-diffs@, philipp
      
      FB internal diff: D1683221
      
      Tasks: 5336655
      
      Signature: t1:1683221:1416264933:946d29b5a3eb22ed08812f2adefb7284b1899e4e
      0a14b4cc
    • James Sedgwick's avatar
      priority CPU thread pool · fe22c76c
      James Sedgwick authored
      Summary:
      just extend CPUThreadPoolExecutor to use a queue that is itself composed of N mpmc queues, one per priority
      
      the verbosity is starting to kill me, i had thought before of truncating Executor of all these pool types and now I'm definitely going to do that unless someone fights me.
      
      Test Plan: added unit; maybe i'm not being clever enough as i couldn't think of many ways to test this reliably so there's just a basic preemption test
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent, fugalh, njormrod, folly-diffs@, bmatheny
      
      FB internal diff: D1676452
      
      Tasks: 5002392
      
      Signature: t1:1676452:1416263990:cdf5d44e4a50a6180ba547a3ed4c0c24d4ffdd8f
      fe22c76c
    • Dave Watson's avatar
      Fix format bug · 146fda29
      Dave Watson authored
      Summary: Fix addition bug instead of string concat
      
      Test Plan: ?? It compiles?  The only call paths are when syscalls fail, it would be a lot of work to stub them out
      
      Reviewed By: mshneer@fb.com
      
      Subscribers: trunkagent, doug, njormrod, folly-diffs@
      
      FB internal diff: D1679713
      
      Tasks: 5604354
      
      Signature: t1:1679713:1415925209:ed05d3d1ce3e7e8db32c4afc86c5f24748d9c65b
      146fda29
    • Dave Watson's avatar
      Move Acceptor to wangle · dd280141
      Dave Watson authored
      Summary:
      Initial pass at moving acceptor to wangle.  Involves moving most of the config stuff from proxygen/lib/services, and *all* of the ssl stuff from proxygen/lib/ssl.
      
      Only minor changes:
      * Acceptor can be overriden to use thrift socket types, so I don't have to change TTransportException everywhere just yet
      * proxygen::Exception to std::runtime_exception in a few spots - looks like it is entirely bad config exceptions, so it should be okay
      * Just used std::chrono directly instead of stuff in Time.h (which is just typedefs and simple helpers)
      
      Test Plan:
      used in D1539327
      
      fbconfig -r proxygen/httpserver; fbmake runtests
      
      Probably other projects are broken, will iterate to fix
      
      None of the failling tests look related
      
      Reviewed By: dcsommer@fb.com
      
      Subscribers: oleksandr, netego-diffs@, hphp-diffs@, ps, trunkagent, doug, fugalh, alandau, bmatheny, njormrod, mshneer, folly-diffs@
      
      FB internal diff: D1638358
      
      Tasks: 5002353
      
      Signature: t1:1638358:1414526683:87a405e3c24711078707c00b62a50b0e960bf126
      dd280141
    • Philip Pronin's avatar
      fix potential memory leak in ThreadLocal · 81fa7fd7
      Philip Pronin authored
      Summary:
      See this LSan abort: https://phabricator.fb.com/P17233565.
      
      Destructor of the object stored in `folly::ThreadLocal` itself may be using
      `folly::ThreadLocal` with the same tag, with the current implementation these
      objects may escape cleanup happening on thread exit.
      
      Test Plan:
      _build/opt/folly/test/thread_local_test --gtest_filter=ThreadLocalPtr.CreateOnThreadExit
      
      Reviewed By: lucian@fb.com
      
      Subscribers: njormrod, folly-diffs@
      
      FB internal diff: D1682698
      
      Tasks: 5596043
      
      Signature: t1:1682698:1416006810:100aaa5c17cecceeea568165d552d9d7907f38d0
      81fa7fd7
    • Alex Landau's avatar
      CompactProtocol: more improvements · 22b02d5f
      Alex Landau authored
      Summary:
      Add a specialized Cursor method that reads exactly 1 byte, in
      addition to the existing one that reads into a buffer. Use it when
      reading varints and standalone bytes in a CompactProtocol struct.
      
      Test Plan:
      ```
      ------ old ------   ------ new ------
      Benchmark                               time/iter  iters/s  time/iter  iters/s        win
      =========================================================================================
      CompactProtocol_read_Empty                18.68ns   53.54M    13.21ns   75.69M     41.37%
      CompactProtocol_read_SmallInt             42.60ns   23.47M    29.95ns   33.39M     42.27%
      CompactProtocol_read_BigInt               83.62ns   11.96M    68.40ns   14.62M     22.24%
      CompactProtocol_read_SmallString          67.33ns   14.85M    55.62ns   17.98M     21.08%
      CompactProtocol_read_BigString           353.83ns    2.83M   330.19ns    3.03M      7.07%
      CompactProtocol_read_BigBinary           190.82ns    5.24M   182.90ns    5.47M      4.39%
      CompactProtocol_read_LargeBinary         200.95ns    4.98M   187.00ns    5.35M      7.43%
      CompactProtocol_read_Mixed               137.42ns    7.28M   102.98ns    9.71M     33.38%
      CompactProtocol_read_SmallListInt        203.98ns    4.90M   146.68ns    6.82M     39.18%
      CompactProtocol_read_BigListInt          120.50us    8.30K    71.56us   13.97K     68.31%
      CompactProtocol_read_BigListMixed          1.62ms   617.07     1.26ms   795.60     28.93%
      CompactProtocol_read_LargeListMixed      177.50ms     5.63   140.73ms     7.11     26.29%
      ```
      
      Reviewed By: haijunz@fb.com
      
      Subscribers: trunkagent, alandau, bmatheny, njormrod, mshneer, folly-diffs@
      
      FB internal diff: D1678077
      
      Signature: t1:1678077:1415923409:22accee6b62b6e2bf471f3758a290f71978a8c4e
      22b02d5f
    • Andrii Grynenko's avatar
      folly::Singleton-based McrouterManager · 096bde27
      Andrii Grynenko authored
      Summary: Introduces a Singleton which keeps a map persistence_id => mcrouter_t*. Makes mcrouter instance not know if it's managed by McrouterManager.
      
      Test Plan: unit tests
      
      Reviewed By: pavlo@fb.com
      
      Subscribers: trunkagent, alikhtarov, njormrod, folly-diffs@
      
      FB internal diff: D1673274
      
      Signature: t1:1673274:1415735863:c990a6a526f9525c68cc23892d690a9b3cb94ace
      096bde27
    • Hans Fugal's avatar
      Have EventBase implement wangle::Executor · f22220e5
      Hans Fugal authored
      Summary:
      It already does the work (`runInEventBaseThread`) but it will now be convenient to pass an `EventBase` where wangle wants an `Executor`.
      
      Had to rip off the `boost::noncopyable` from `wangle::Executor` which is an interface and does not require non-copyability so that didn't really belong there in the first place I think. (Without this change, you get an obscure compiler error because of the double-inheritance from `boost::noncopyable`).
      
      Test Plan: Things build, tests pass
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: jsedgwick, trunkagent, fugalh, exa, njormrod, folly-diffs@, andrii
      
      FB internal diff: D1671500
      
      Signature: t1:1671500:1415727572:a7dba33c669ca122aecaee3c700f9e53e54838d1
      f22220e5
    • Nick Burrett's avatar
      folly::EventBase: wrap libevent calls to prevent race-condition · 3c34f066
      Nick Burrett authored
      Summary:
      Patch D1585087 exposes two flaws in EventBase().  It introduces IO
      worker threads to the ThriftServer which are constructed/destructed in
      parallel.
      
      Within the construction phase, a new EventBase() is instantiated for
      each thread and unwound in destruction.
      
      When using the BaseControllerTask (in Python), the following sequence
      is observed:
      
      a = event_init() [ThriftServer]
      b = event_init() [IO worker 1]
      c = event_init() [IO worker 2]
      ...
      event_base_free(c)
      event_base_free(b)
      event_base_free(a)  -> segfault
      
      1. event_init() should only ever be called once.  It internally
      modifies a global variable in libevent, current_base to match the
      return value.  event_base_free() will set current_base back to NULL if
      the passed in arg matches current_base.   Therefore subsequent calls
      must use event_base_new().
      
      2. Since current_base is a global and EventBase() is called by multiple
      threads, it is important to guard with a mutex.  The guard itself also
      exposed the bug because:
      
      a = event_init()  [current_base = a]
      b = event_init()  [current_base = b]
      ...
      event_base_free(b) [b == current_base -> current_base = NULL]
      
      So current_base ends up prematurely set to NULL.
      
      Test Plan:
      Run dba/core/daemons/dbstatus/dbstatus_tests.lpar, which no longer
      segfaults
      
      Reviewed By: jsedgwick@fb.com, davejwatson@fb.com
      
      Subscribers: dihde, evanelias, trunkagent, njormrod, ncoffield, lachlan, folly-diffs@
      
      FB internal diff: D1663654
      
      Tasks: 5545819
      
      Signature: t1:1663654:1415732265:d51c4c4cae99c1ac371460bf18d26d4f917a3c52
      
      Blame Revision: D1585087
      3c34f066
    • Alecs King's avatar
      Use folly::IPAddress::hash instead of gethostid · 05e80bad
      Alecs King authored
      Summary: find a non-loopback ipv4 or ipv6 address and feed it to folly::IPAddress::hash
      
      Test Plan:
      1)
      fbconfig -r mcrouter
      fbmake runtests
      
      2)
      compare hostids on different hosts
      
      Reviewed By: pavlo@fb.com
      
      Subscribers: njormrod, folly-diffs@, trunkagent, ps, bmatheny, alikhtarov
      
      FB internal diff: D1668944
      
      Tasks: 5557721
      
      Signature: t1:1668944:1415736928:fb4b042a575c0b00f52780f3abf54bf7630b3a97
      05e80bad
    • Dave Watson's avatar
      Clean up RequestContext · 84e83ecc
      Dave Watson authored
      Summary: Using a ThreadLocal cleans up the code quite a bit.  Also reuse the shared_ptr in create instead of creating a new one saves an allocation
      
      Test Plan:
      fbconfig thrift/lib/cpp/test:RequestContextTest; fbmake runtests
      
      fbconfig common/services/cpp/test:trace_test; fbmake runtests
      
      Reviewed By: hans@fb.com
      
      Subscribers: trunkagent, doug, alandau, bmatheny, njormrod, mshneer, folly-diffs@, vloh
      
      FB internal diff: D1663960
      
      Signature: t1:1663960:1415390250:36d9b772016d2a12d804e98edbc1725af882e507
      84e83ecc
    • Dave Watson's avatar
      OS merges · fc7801ad
      Dave Watson authored
      Summary:
      All pretty trivial:
      
      https://github.com/facebook/folly/issues/99
      https://github.com/facebook/folly/issues/98
      https://github.com/facebook/folly/issues/45
      
      Test Plan: Will watch jenkins fbthrift build
      
      Reviewed By: dcsommer@fb.com
      
      Subscribers: doug, njormrod, folly-diffs@
      
      FB internal diff: D1669952
      
      Signature: t1:1669952:1415643677:906234f0a89f38645b0072d3c88762d8fa2729dc
      fc7801ad
    • Dmitry Panin's avatar
      Add optional parameter pruneHook to EvictingCacheMap::set(..) · 0318bad6
      Dmitry Panin authored
      Summary:
      Inside `set()` we can do pruning, but it will happen
      with default pruneHook.
      Adding it as an optional param makes API more convenient.
      (Instead, the users of API could just call `setPruneHook(pruneHook)` before `set`,
      and then `setPruneHook(nullptr)` afterwards -- but it looks too ugly)
      
      Test Plan:
      ```
      fbconfig -r folly/ && fbmake runtests
      ```
      passes:
      ```
      Summary (total time 60.11s):
      PASS: 1758
      FAIL: 0
      SKIP: 0
      FATAL: 0
      TIMEOUT: 0
      ```
      
      Reviewed By: njormrod@fb.com
      
      Subscribers: trunkagent, agartrell, njormrod, folly-diffs@
      
      FB internal diff: D1665690
      
      Tasks: 5551091
      
      Signature: t1:1665690:1415391406:e4d2a956f9212aed70ab518159dbb19553764ce4
      0318bad6
  2. 08 Nov, 2014 22 commits
    • Pavlo Kushnir's avatar
      Bump version to 15:0 · 81e0e450
      Pavlo Kushnir authored
      81e0e450
    • Nicholas Ormrod's avatar
      Fix folly lint errors · d9b08663
      Nicholas Ormrod authored
      Summary:
      Fix EOF whitespace
      for file in `find folly -type f` ; do if [ -z "`tail -n1 $file`" ] ; then sed -i '$d' $file ; fi ; done
      
      Test Plan: unit tests
      
      Reviewed By: robbert@fb.com
      
      Subscribers: trunkagent, sdwilsh, njormrod, folly-diffs@
      
      FB internal diff: D1644130
      
      Tasks: 5486739
      
      Signature: t1:1644130:1414715392:b6c783851aa030ad1148f84a98139a5dca207da0
      d9b08663
    • Misha Shneerson's avatar
      isDetachable for HHWheelTimer · a082ba98
      Misha Shneerson authored
      Summary: title
      
      Test Plan: unit tests
      
      Reviewed By: andrei.bajenov@fb.com
      
      Subscribers: trunkagent, mcduff, hitesh, alandau, bmatheny, njormrod, mshneer, folly-diffs@, andreib, davejwatson
      
      FB internal diff: D1666499
      
      Tasks: 5563183
      
      Signature: t1:1666499:1415347256:d58c8bbe952385c1c96f7f8cc6ae7f02216c56bb
      a082ba98
    • Dave Watson's avatar
      Move SSL socket to folly · ff9b70f3
      Dave Watson authored
      Summary: One of the last thrift -> folly moves.  The only change was the exception types - there are small wrapper classes in thrift/lib/cpp/async left to convert from AsyncSocketException to TTransportException.
      
      Test Plan: run unit tests
      
      Reviewed By: dcsommer@fb.com
      
      Subscribers: jdperlow, trunkagent, doug, bmatheny, ssl-diffs@, njormrod, mshneer, folly-diffs@, fugalh, jsedgwick, andrewcox, alandau
      
      FB internal diff: D1632425
      
      Signature: t1:1632425:1414526483:339ae107bacb073bdd8cf0942fd0f6b70990feb4
      ff9b70f3
    • Tom Jackson's avatar
      Remove volatile from MemoryMappingTest · a91ed7e3
      Tom Jackson authored
      Summary: Not needed, I don't know why I put them there before.
      
      Test Plan: Run the unit test
      
      Reviewed By: njormrod@fb.com
      
      Subscribers: njormrod, folly-diffs@
      
      FB internal diff: D1665689
      
      Tasks: 5487902
      
      Signature: t1:1665689:1415323144:0998e7f700a3b40652615a36c3b9c9f661fbdadf
      a91ed7e3
    • Daniel Sommermann's avatar
      Add some SocketAddress tests · 27d533e5
      Daniel Sommermann authored
      Summary: There was a bit of gap in test coverage for bracketed ipv6
      
      Test Plan: unit tests
      
      Reviewed By: viswanath@fb.com
      
      Subscribers: doug, ps, bmatheny, njormrod, folly-diffs@
      
      FB internal diff: D1664783
      
      Signature: t1:1664783:1415316694:b17e0dc1fcfece06c6e04e5f65e2095c66d28cc4
      27d533e5
    • Dmitry Panin's avatar
      Fix integer overflow in folly/Benchmark.cpp · 53c9c964
      Dmitry Panin authored
      Summary:
      `bm_max_secs` has type int32
      So when this value is more than 2, expression
      ```
      FLAGS_bm_max_secs * 1000000000;
      ```
      overflows
      
      Test Plan:
      I did put a
      ```
      LOG(INFO) << timeBudgetInNs;
      ```
      and observed correct values (before fix they were overflowed)
      
      Reviewed By: antonl@fb.com
      
      Subscribers: njormrod, folly-diffs@
      
      FB internal diff: D1663247
      
      Signature: t1:1663247:1415261814:c9154ffde183b2a4f5403e534e47e52e8276c61b
      53c9c964
    • Philip Pronin's avatar
      BMI1 support in EliasFanoCoding · 3c1306e1
      Philip Pronin authored
      Summary:
      This diff updates `folly::CpuId` with support of extended features (EAX =
      7, ECX = 0) to provide detection logic for BMI1 introduced in Haswell, and
      provides support for `BLSR` instruction in `EliasFanoReader`.
      
      Test Plan:
      I used clang to compile the logic and run unittests
      
      Reviewed By: lucian@fb.com
      
      Subscribers: fbcode-common-diffs@, trunkagent, chaoyc, search-fbcode-diffs@, unicorn-diffs@, njormrod, folly-diffs@
      
      FB internal diff: D1658100
      
      Signature: t1:1658100:1415126635:d1820b8eb41c9e9786b5c8062b801cf1e2049a97
      3c1306e1
    • Hans Fugal's avatar
      (wangle) fix a race condition in Core::maybeCallback · c4035d06
      Hans Fugal authored
      Summary:
      `calledBack_` could be seen as true by both threads in this conditional. Classic rookie mistake. :-/
      
      Test Plan: run unit tests
      
      Reviewed By: darshan@fb.com
      
      Subscribers: trunkagent, hannesr, net-systems@, fugalh, exa, njormrod, folly-diffs@
      
      FB internal diff: D1661199
      
      Tasks: 5542938, 5506504
      
      Signature: t1:1661199:1415215840:fb69f56c8cf6f59beeca809724ce015b5260d9ad
      
      Blame Revision: D1636487
      c4035d06
    • Brian Watling's avatar
      Remove memory leak from readRandomDevice by using a raw fd · 35654c7b
      Brian Watling authored
      Summary: Switch from dynamically allocating a File to using a raw fd for readRandomDevice. This prevents races at shutdown while also eliminating the memory leak
      
      Test Plan: run unit tests
      
      Reviewed By: meyering@fb.com
      
      Subscribers: njormrod, folly-diffs@, tao-eng@
      
      FB internal diff: D1662151
      
      Signature: t1:1662151:1415229242:525b6294b27bb68b5dda70aadb8d3ba1cc61b815
      35654c7b
    • Brian Watling's avatar
      Fix crashes in readRandomDevice() · 100ebad7
      Brian Watling authored
      Summary: The comment in readRandomDevice() lies - the PCHECK fails with "Bad file descriptor" in some tests. This is most likely due to a race where a background thread is calling readRandomDevice() while the main thread shuts down. Another possibility is bad destruction order, where rnadomDevice is destroyed before some other static object whose destructor calls readRandomDevice(). Either way, this fixes it without having to chace down every instance.
      
      Test Plan: run unit tests
      
      Reviewed By: meyering@fb.com
      
      Subscribers: antonl, trunkagent, meyering, simpkins, njormrod, folly-diffs@, tao-eng@
      
      FB internal diff: D1660903
      
      Signature: t1:1660903:1415215895:7f1f96ab7416b45c4dc18e78173fb59eb27bd03b
      100ebad7
    • Hans Fugal's avatar
      (wangle) fix a race in whenAll · 20dfb55a
      Hans Fugal authored
      Summary:
      Race in `++ctx->count == ctx->total`. This ordering, while not very obvious or likely, is possible:
      
      T1            T2
      --            --
      ++ctx->count
      ++ctx->count
      ctx->total
      ==
      setValue
      delete ctx
      ctx->total
      ==
      setValue
      delete ctx
      
      Test Plan:
      That's the idea, anyway. I need some sleep, and it takes 20 minutes to build and test. I had a more convoluted fix (using `shared_ptr`) and it did seem to fix the error we were seeing, but I was seeing another error.
      
      Reviewed By: darshan@fb.com
      
      Subscribers: trunkagent, net-systems@, fugalh, exa, njormrod, folly-diffs@
      
      FB internal diff: D1660663
      
      Tasks: 5506504
      
      Signature: t1:1660663:1415207632:49dc224363cec27736fc71fb211fa846be9e170f
      
      Blame Revision: D1636487
      20dfb55a
    • Lucian Grijincu's avatar
      folly: wangle: NamedThreadFactory: store of the thread prefix locally, don't... · 773fa87a
      Lucian Grijincu authored
      folly: wangle: NamedThreadFactory: store of the thread prefix locally, don't assume they'll live forever
      
      Summary: There's no real reason to store this as a StringPiece, is there?
      
      Test Plan: n/a
      
      Reviewed By: sdoroshenko@fb.com, robot9@fb.com
      
      Subscribers: fugalh, njormrod, folly-diffs@
      
      FB internal diff: D1659558
      
      Tasks: 5538418
      
      Signature: t1:1659558:1415147560:2c5b0c996893854c3ea9d0ad02b006bcc5960ffa
      773fa87a
    • Nicholas Ormrod's avatar
      Fix licenses · 1bd2c005
      Nicholas Ormrod authored
      Summary:
      There are two types of licenses used in folly, only one of
      which is accepted by the linter.
      
      This diff changes the license notices in pre-existing folly files!
      Many folly/io/async/* files have the second type of license, but
      without a Copyright notice. I have added copyright notices to these
      files.
      
      I have also added a compliant notice to
      folly/test/function_benchmark/benchmark_impl.h, which was the sole file
      in folly/test/function_benchmark/ that didn't have a standard license.
      
      Test Plan:
      The changes to folly are comment only.
      
      Run all of folly against the linter, see no more license errors.
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent, sdwilsh, njormrod, folly-diffs@, sjenkins
      
      FB internal diff: D1648489
      
      Tasks: 5486739
      
      Signature: t1:1648489:1415035522:3d8bd9611eb7c7117b70d5e7f68de5768639a727
      1bd2c005
    • Nicholas Ormrod's avatar
      Fix global statics · 8cbc14de
      Nicholas Ormrod authored
      Summary:
      Statics in headers are bad.
      
      Test Plan: run unit tests
      
      Reviewed By: robbert@fb.com
      
      Subscribers: trunkagent, sdwilsh, njormrod, folly-diffs@
      
      FB internal diff: D1646906
      
      Tasks: 5486739
      
      Signature: t1:1646906:1415042805:dc4d1cec54e9320f1e609808a73622c731a4cdc9
      8cbc14de
    • Nicholas Ormrod's avatar
      rm protected inheritance · 4de78cbf
      Nicholas Ormrod authored
      Summary:
      Remove the protected inheritance from folly.
      
      The code looks like the protected might be appropriate: there are some
      derived classes which might want access to the AsyncTimeout.
      
      Test Plan: run unit tests
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent, sdwilsh, njormrod, folly-diffs@
      
      FB internal diff: D1649686
      
      Tasks: 5486739
      
      Signature: t1:1649686:1415035288:18efd2cf9aae8caab66d8303c22cdc26c6b54ae5
      4de78cbf
    • James Sedgwick's avatar
      netty-like channels · d3a23ad3
      James Sedgwick authored
      Summary:
      I wanted some foundational abstractions to start building out codecs on top of.
      I also know that Blake gets very amused when I shamelessly copy Java/Netty abstractions, and I live to amuse Blake so I did it again.
      So here's an implementation of something very similar to Netty's ChannelAdapters/ChannelPipelines
      Only read() and write() for now, everything/anything else can easily be bolted on once the design is settled (if this is at all the direction we want to go)
      I have a lot of thoughts about this design but I'm going to save my fingers and leave that to ad hoc discussions once folks take a look at this
      A couple of things, though:
      - It should be possible to dynamically add handlers to the chain. How I envision this working is that each original adapters keeps two lists of shared/unique ptrs to adapters of the correct type to sit next to them on either side, and dispatch to them appropriately when they're there.
      - I was trying to do without separate ChannelHandlerContext objects altogether (keep the interface, but have ChannelPipeline act as the context itself) but ran into issues with virtual multiple inheritance. I might have another go at this.
      - Only movable types are permitted. I hope this won't be too restrictive, because it would be a PITA to support both move-only and copy-only types.
      - Why no Rx? Seems to me that any handlers that actually needs Rx (e.g. stats fanout or something) can deal with it themselves.
      - If it turned out to be useful to nest these (for more flexible composition) that would also be doable. i.e. ChannelPipeline<ChannelPipeline<Handler1, Handler2>, ChannelPipeline<Handler3, Handler4>>
      
      Test Plan: super basic test compiles and runs as expected
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: ajitb, folly-diffs@, ldbrandy, trunkagent, fugalh, njormrod
      
      FB internal diff: D1604575
      
      Tasks: 5002299
      
      Signature: t1:1604575:1415034767:bc3b12fae726890aa6a55ed391286917ae23e56e
      d3a23ad3
    • Daniel Sommermann's avatar
      Fix -Wsign-compare · 7ffe7766
      Daniel Sommermann authored
      Summary: Folly should be able to compile with strict flags.
      
      Test Plan: unit tests, review
      
      Reviewed By: meyering@fb.com
      
      Subscribers: meyering, trunkagent, doug, fugalh, njormrod, folly-diffs@
      
      FB internal diff: D1627280
      
      Signature: t1:1627280:1414792755:004f5a737ece1e93bcf4331718a98afc57e4f80c
      7ffe7766
    • James Sedgwick's avatar
      Name prefix setter for NamedThreadFactory · c16a74ff
      James Sedgwick authored
      Summary: it's useful to update the prefix after the construction.
      
      Test Plan:
      unit, that's it :/
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: mshneer, folly-diffs@, wch, atlas2-eng@, everstore-dev@, wormhole-diffs@, ads-dsp-eng@, bwester, trunkagent, fugalh, alandau, njormrod, bmatheny
      
      FB internal diff: D1585087
      c16a74ff
    • Dave Watson's avatar
      Fix bad rebase for SSLContext · 4f204c1f
      Dave Watson authored
      Summary: Put back previous liger diffs
      
      Test Plan: It builds
      
      Reviewed By: seanc@fb.com
      
      Subscribers: doug, ssl-diffs@, njormrod, folly-diffs@
      
      FB internal diff: D1652754
      
      Signature: t1:1652754:1414785984:df0fc7bf59dc2e89defd2c1a4ffe3b288238ba58
      4f204c1f
    • Nicholas Ormrod's avatar
      Fix line too long lint errors · 8160f2fb
      Nicholas Ormrod authored
      Summary:
      Many lines that are too long contain URLs. This diff adds
      url-like lines to the list of exceptions to 80-char limits. It also
      fixed the locations in folly with line-too-long errors.
      
      Test Plan: arc lint on folly, see no line-too-long errors.
      
      Reviewed By: robbert@fb.com
      
      Subscribers: sdwilsh, njormrod, folly-diffs@
      
      FB internal diff: D1644151
      
      Tasks: 5486739
      
      Signature: t1:1644151:1414779408:76bcec1d14daaa8ed071c715bf26b108c8fe4b87
      8160f2fb
    • Mark Drayton's avatar
      Increase size of demangled symbol buffer · e5ce811f
      Mark Drayton authored
      Summary:
      Symbols which demangle to a string longer than 1024 bytes are
      quite common in our code. This diff increases the size of the output
      buffer to accommodate them.
      
      Test Plan: run it
      
      Reviewed By: lucian@fb.com
      
      Subscribers: trunkagent, njormrod, folly-diffs@
      
      FB internal diff: D1639801
      
      Tasks: 5464222
      
      Signature: t1:1639801:1414784601:2f59d5a58e434f4cf9df5b25b917c5094c8b133f
      e5ce811f