folly.git
9 years agoMake sure there are no outstanding timers in the destructor
Chad Parry [Mon, 9 Nov 2015 18:39:22 +0000 (10:39 -0800)]
Make sure there are no outstanding timers in the destructor

Summary: This is the solution for our `HHWheelTimer` crashes, as suggested in D2617966#25.

djwatson also mentioned that maybe there should be some logging in the destructor if there are outstanding callbacks. I couldn't think of anything that would add to the `assert` that already exists in `destroy`. I'm open to suggestions though.

Reviewed By: djwatson

Differential Revision: D2628154

fb-gh-sync-id: f3db6e9384517c9bf3cbb60af8c1e711703a07fa

9 years agofolly/portability: add clang version check
Igor Sugak [Sun, 8 Nov 2015 08:32:52 +0000 (00:32 -0800)]
folly/portability: add clang version check

Summary: Define `__CLANG_PREREQ` macro to check version of clang.

Reviewed By: yfeldblum

Differential Revision: D2630325

fb-gh-sync-id: 3d666e554e8ddfc2c1fecd439aaf93f015829025

9 years agoCallbacks should ref the HHWheelTimer
Chad Parry [Fri, 6 Nov 2015 19:52:10 +0000 (11:52 -0800)]
Callbacks should ref the HHWheelTimer

Summary: Callbacks sometimes outlive the `HHWheelTimer` that they reference. Then the `Callback` tries to reference the dead `HHWheelTimer` and it could either misbehave or crash. This was caught reliably by ASAN tests.

Since `HHWheelTimer` already supports intrusive ref counting, the solution is to acquire a reference within the `Callback`.

Reviewed By: djwatson

Differential Revision: D2617966

fb-gh-sync-id: 02be9ffc5851c269d5933288a17ad394b33ac2dd

9 years agoCancel timeout only if not run
Jon Maltiel Swenson [Fri, 6 Nov 2015 02:54:38 +0000 (18:54 -0800)]
Cancel timeout only if not run

Summary: Do not cancel TimeoutHandler timeout if the timeout has already run.

Reviewed By: spalamarchuk

Differential Revision: D2622280

fb-gh-sync-id: 27d83b44ab225e2859695f4e5f21cef934824a35

9 years agocodemod setMaxNumMessagesInQueue to setMaxNumPendingConnectionsPerWorker
Haijun Zhu [Thu, 5 Nov 2015 18:36:46 +0000 (10:36 -0800)]
codemod setMaxNumMessagesInQueue to setMaxNumPendingConnectionsPerWorker

Summary: This name's meaning is very obscure, this method actually sets the
queue size of each acceptor and if all acceptor's queues are full the
connection will be dropped. Change it to a more meaningful name.

Reviewed By: alandau

Differential Revision: D2613681

fb-gh-sync-id: baa374cdf0a87c460df3dd5687e3d755b55f4b4f

9 years agoActivate server timeout after write success
Jon Maltiel Swenson [Thu, 5 Nov 2015 15:24:16 +0000 (07:24 -0800)]
Activate server timeout after write success

Summary: Start server timeout after socket write succeeds in mcrouter.  Add neceessary Fibers logic to enable this behavior.

Reviewed By: pavlo-fb

Differential Revision: D2613344

fb-gh-sync-id: 1bc0fbe8b325a3e91cd010f89104b83ebf183679

9 years agoSet interrupt handler correctly on SharedPromise
Viswanath Sivakumar [Thu, 5 Nov 2015 11:48:26 +0000 (03:48 -0800)]
Set interrupt handler correctly on SharedPromise

Summary: If SharedPromise::getFuture() is invoked after a call to setInterruptHandler,
then the interrupt handler isn't set on the newly created promise. This diff
fixes that.

Reviewed By: yfeldblum

Differential Revision: D2610289

fb-gh-sync-id: bf8fce9e881b83ccac17d13c6788ec2afd0b0153

9 years agoAdd ability to get application protocol from AsyncTransportWrapper
Subodh Iyengar [Wed, 4 Nov 2015 05:38:07 +0000 (21:38 -0800)]
Add ability to get application protocol from AsyncTransportWrapper

Summary: Allows AsyncTransportWrapper's to supply the underlying application
protocol being used, for example using NPN for SSL or some other
generic protocol indication mechanism.

Reviewed By: ranjeeth

Differential Revision: D2614179

fb-gh-sync-id: 2079782bb7d44f898fb14c7df15077209b022424

9 years agoswitch the IndexType and Allocator in AtomicUnorderedInsertMap template
Zhen (Growth) Li [Wed, 4 Nov 2015 01:31:55 +0000 (17:31 -0800)]
switch the IndexType and Allocator in AtomicUnorderedInsertMap template

Summary: Our use case need to have the IndexType Configurable, but in this diff D2583752, lint error shows
  Code from folly::detail is logically private, please avoid use outside of folly.
In order to fix this lint error, I switch the IndexType and Allocator in the AtomicUnorderedInsertMap template.

Reviewed By: nbronson

Differential Revision: D2610921

fb-gh-sync-id: ae81b41e7c8c971f26c61b8c67dabeadff379584

9 years agoAllow underlying transport to be accessible from AsyncTransportWrapper
Subodh Iyengar [Wed, 4 Nov 2015 01:19:40 +0000 (17:19 -0800)]
Allow underlying transport to be accessible from AsyncTransportWrapper

Summary: Allow underlying transport to be accessible from AsyncTransportWrapper.
There are some code paths where we need access to the real transport from
the AsyncTransportWrapper. This allows us to retrieve the underlying transport
and have clients like HTTPSession use it.

Reviewed By: afrind

Differential Revision: D2609200

fb-gh-sync-id: 2b317d1825a005bb64468f83c64bc3f1c9bdfe2c

9 years agomake folly slightly more c++-modules friendly
Louis Brandy [Wed, 4 Nov 2015 01:13:54 +0000 (17:13 -0800)]
make folly slightly more c++-modules friendly

Summary: .. by including what you use.

These are a handful of headers that are depended on via viral inclusion. Include them directly.

Reviewed By: yfeldblum

Differential Revision: D2601172

fb-gh-sync-id: 215e87263325d085fbcb651f83f429f47d14fc1b

9 years agoqualify std::move in StringKeyedTest
Louis Brandy [Tue, 3 Nov 2015 20:30:27 +0000 (12:30 -0800)]
qualify std::move in StringKeyedTest

Summary: Prefer `std::move` to `move` for clarity's sake.

Reviewed By: yfeldblum

Differential Revision: D2601138

fb-gh-sync-id: 64a9e58a83da9c8416a0be5c45a292c6b1342664

9 years agoDisallow nullptr literal in StringPiece constructor
Anton Likhtarov [Tue, 3 Nov 2015 18:45:21 +0000 (10:45 -0800)]
Disallow nullptr literal in StringPiece constructor

Summary: This disallows implicitly constructing a StringPiece from a literal nullptr at compile time
(without this change, nullptr would cause a segfault in strlen()).

Reviewed By: meyering, andriigrynenko

Differential Revision: D2603597

fb-gh-sync-id: cafbc45945bacc72a7c89310b99aa62d19a3ff9f

9 years agoFix multi-line comment warnings
Andrew Gallagher [Sat, 31 Oct 2015 21:42:53 +0000 (14:42 -0700)]
Fix multi-line comment warnings

Summary: Fix warnings triggered by `-Wcomment`.

Reviewed By: ajtulloch

Differential Revision: D2603992

fb-gh-sync-id: aae721f7c236d7d8b8bff2c077a481fc2affcf71

9 years agoAdd writeAndGetCursor to LockFreeRingBuffer
Delyan Kratunov [Fri, 30 Oct 2015 21:59:54 +0000 (14:59 -0700)]
Add writeAndGetCursor to LockFreeRingBuffer

Summary: New API - write an entry and advance a cursor to the just-written slot.

Reviewed By: ritzau, yfeldblum

Differential Revision: D2599388

fb-gh-sync-id: f3ebfae97de0341f01ffc80ab10221313d02087c

9 years agoPeriodically reclaim unnecessary fibers from free pool
Jon Maltiel Swenson [Fri, 30 Oct 2015 00:16:08 +0000 (17:16 -0700)]
Periodically reclaim unnecessary fibers from free pool

Summary: Reclaim unnecessary fibers from the free pool periodically.  Turn this behavior
on in mcrouter/proxy.cpp

Reviewed By: pavlo-fb

Differential Revision: D2584825

fb-gh-sync-id: eabc58eefe6fd38972c9e23ca3cbe79eb8316a3e

9 years agoPrefer template aliases to classes in IntrusiveList
Justin Gibbs [Thu, 29 Oct 2015 21:35:22 +0000 (14:35 -0700)]
Prefer template aliases to classes in IntrusiveList

Summary: Convert helper classes to using statements now that GCC has caught up
with c++11.

Reviewed By: simpkins

Differential Revision: D2561364

fb-gh-sync-id: 712591549aba9450d159468dc3b26a987ffe9b82

9 years agoRemove DFATAL from folly::Singleton::try_get()
Andrii Grynenko [Thu, 29 Oct 2015 21:33:02 +0000 (14:33 -0700)]
Remove DFATAL from folly::Singleton::try_get()

Summary: try_get() API is confusing right now, because it returns nullptr in release, but crashes in debug build. Users end up handling nullptr returns, yet their code crashes in debug builds for no reason. See https://www.facebook.com/groups/fbthrift/permalink/1222120054481561/ for an example.

If we want to keep the crashing API we should probably name it differently and make it crash both in debug and release.

Reviewed By: dhruvbird

Differential Revision: D2587818

fb-gh-sync-id: 5834bfa08eb5d9bc6db1c5edf4a048a5b1d3212c

9 years agoadd config to allow using quadratic probing
Xiaofan Yang [Thu, 29 Oct 2015 19:27:58 +0000 (12:27 -0700)]
add config to allow using quadratic probing

Summary: In my use case, 1.5 billion keys with loadFactor 0.8, the linear probing performs really bad.

Reviewed By: nbronson

Differential Revision: D2579243

fb-gh-sync-id: 5081356de55f770823a4afad55bf7e2114b4e313

9 years agoDo not set startWork_ in EventBase if time measurement is disabled
Pavlo Kushnir [Thu, 29 Oct 2015 00:15:19 +0000 (17:15 -0700)]
Do not set startWork_ in EventBase if time measurement is disabled

Summary: startWork_ is used only if enableTimeMeasurement is set. It gives ~0.5% performance win for mcrouter.

Reviewed By: yfeldblum

Differential Revision: D2590176

fb-gh-sync-id: 07f2189ebdec751cd0d91d191d8f595780d2808a

9 years agoSuppress -Wshadow for SYNCHRONIZED
Blake Matheny [Wed, 28 Oct 2015 18:07:40 +0000 (11:07 -0700)]
Suppress -Wshadow for SYNCHRONIZED

Summary: SYNCHRONIZED warns with -Wshadow due to `for (auto&
FB_ARG_1(__VA_ARGS__) =`. This diff just suppresses that warning.

Reviewed By: djwatson

Differential Revision: D2587348

fb-gh-sync-id: 3a2e39fb6ce28da014950ca94e4b62ea80deb65f

9 years agoFix clang issue on NotificationQueue::size
Beny Luo [Wed, 28 Oct 2015 00:41:18 +0000 (17:41 -0700)]
Fix clang issue on NotificationQueue::size

Summary: The implicit conversion loses integer precision: 'size_type' (aka 'unsigned
long') to 'int'.

Reviewed By: mzlee

Differential Revision: D2585883

fb-gh-sync-id: 1fc7c84b66c8f19cc36b798dd198730764e19b28

9 years agoTrack callback life cycle for HHWheelTimer and EventBase
Shaft Wu [Tue, 27 Oct 2015 04:14:10 +0000 (21:14 -0700)]
Track callback life cycle for HHWheelTimer and EventBase

Summary: Further race is presented in HHWheelTimer and EventBase, since changing them to track callback life cycle is more involving, I am hacking around it to prove the concept. With the *fix*, no reproduce of the segmentation fault anymore.

This is for proving the concept, code will be cleaned up if we agree this is reasonable direction to pursue.

Reviewed By: fugalh

Differential Revision: D2577715

fb-gh-sync-id: e0bb0317268e6f02a54fc70454e63959fba70c10

9 years agoExpose pending messages in queue stats in AsyncServerSocket
Jun Li [Tue, 27 Oct 2015 00:40:17 +0000 (17:40 -0700)]
Expose pending messages in queue stats in AsyncServerSocket

Summary: Expose pending messages in accept queue in AsyncServerSocket.

Set default accept message queue size to 1024.

Reviewed By: djwatson

Differential Revision: D2525161

fb-gh-sync-id: a69ea0ee77729e4a8300bde3e3c07840f2d5d3cb

9 years agofolly: hash: specialize hash_combine_generic by size_t size
Lucian Grijincu [Mon, 26 Oct 2015 22:50:26 +0000 (15:50 -0700)]
folly: hash: specialize hash_combine_generic by size_t size

Reviewed By: yangliu

Differential Revision: D2578043

fb-gh-sync-id: cec8f21219655a495b99d0b6b99f0925615bc068

9 years agoAdd new toBinary() function to IPAddress.
Florent Thoumie [Mon, 26 Oct 2015 21:53:03 +0000 (14:53 -0700)]
Add new toBinary() function to IPAddress.

Summary: This is pretty much the reverse operation from the fromBinary() constructor.

Reviewed By: yfeldblum

Differential Revision: D2578680

fb-gh-sync-id: d8c4e53fe8bc0f5373ebb0b4f7ee498659c1b003

9 years agoStyle nits for folly/test/FingerprintBenchmark.cpp
Yedidya Feldblum [Mon, 26 Oct 2015 19:09:38 +0000 (12:09 -0700)]
Style nits for folly/test/FingerprintBenchmark.cpp

Summary: [Folly] Style nits for `folly/test/FingerprintBenchmark.cpp`.

Reviewed By: Gownta

Differential Revision: D2579463

fb-gh-sync-id: 135bc3ef43708cb024f78c59672811159d2163e0

9 years agoRename two callback function names of ConnectionEventCallback
Mohammad Husain [Mon, 26 Oct 2015 18:56:02 +0000 (11:56 -0700)]
Rename two callback function names of ConnectionEventCallback

Summary: Renaming `EnqueuedForAccept` and `DequeuedByAccept` to
`EnqueuedForAcceptor` and `DequeuedByAcceptor` respectively to make it clear
that the connection is queued for the Acceptor not to call `accept` on.

Reviewed By: yfeldblum

Differential Revision: D2554578

fb-gh-sync-id: 072a9ff122658827d1e89f2bef79ad565dad7974

9 years agoreturn read error on non EAGAIN errno
Shijin Kong [Mon, 26 Oct 2015 17:15:45 +0000 (10:15 -0700)]
return read error on non EAGAIN errno

Summary: Tested over weekend with D2571554. There was no EXC_RESOURCE/CPU crash when read errrors were returned on ENOTCONN. EAGAIN seems innocent as the spin detector was disabled on testing group.

Patch folly. I can add #ifdef __APPLE__ around the errno checking code but this should be good practice for non apple code as well.

I will remove debugging code in fbios master in another diff.

Reviewed By: djwatson

Differential Revision: D2580819

fb-gh-sync-id: 9162a3deba01af8b07cd2b336d7da3da040c67a9

9 years agofix AtomicUnorderedInsertMap load factor computation
Nathan Bronson [Sat, 24 Oct 2015 02:48:25 +0000 (19:48 -0700)]
fix AtomicUnorderedInsertMap load factor computation

Summary: AtomicUnorderedInsertMap's constructor takes a maxLoadFactor argument,
which is given its default argument of 0.8f in all of our code.
The clipping function that was supposed to prevent load factors
greater than one was inverted, resulting in all of our code using a
maxLoadFactor of 1 instead of 0.8.  This diff fixes the computation,
as well as changing all of the use sites so that the actual memory
allocated by existing clients does not change.

Reviewed By: yfeldblum

Differential Revision: D2575238

fb-gh-sync-id: bb9dd8de53114236b259631d175d62af098391cf

9 years agoFibers allocation/deallocation benchmarks
Jon Maltiel Swenson [Fri, 23 Oct 2015 21:44:22 +0000 (14:44 -0700)]
Fibers allocation/deallocation benchmarks

Summary: Add a couple benchmarks measuring allocation/deallocation latency.  One benchmark measures an allocate-deallocate repeated pattern, the other measures the allocation of a large chunk of fibers.

We'll use these benchmarks later on after we modify the allocation/deallocation behavior of fibers.

Reviewed By: pavlo-fb

Differential Revision: D2573064

fb-gh-sync-id: 414eb93d6223e42c187c03214a47dfb533491bab

9 years agoOption to fallback to double when int precision is not enough.
Bartosz Nitka [Fri, 23 Oct 2015 18:42:05 +0000 (11:42 -0700)]
Option to fallback to double when int precision is not enough.

Summary: Some libraries like Haskell's `Data.Aeson` can produce arbitrarily
big numbers with arbitrary precision.
The json standard doesn't specify the ranges for numeric types.
For interoperability, we should allow the user to parse the numbers with
some loss of precision.

Reviewed By: luciang

Differential Revision: D2565140

fb-gh-sync-id: b1a9a46e298bf13cc89d7e79ce28705e9e251a7f

9 years agotemplatize AtomicUnorderedInsertMap's internals to allow big maps
Nathan Bronson [Fri, 23 Oct 2015 14:23:37 +0000 (07:23 -0700)]
templatize AtomicUnorderedInsertMap's internals to allow big maps

Summary: AtomicUnorderedInsertMap used 32 bit index values internally.  2 bits
were stolen, limiting the capacity to 2^30.  This diff makes the internal
index type a template parameter, so you can make really big maps if you
want (at the expense of bigger map overhead).  The easiest way is to
substitute AtomicUnorderedInsertMap64.

Reviewed By: yfeldblum

Differential Revision: D2574338

fb-gh-sync-id: a74994b6da1046a149c2e7763c3dc19e35d9840b

9 years agoFix infinite loop in Cursor::readTerminatedString
Alan Frindell [Thu, 22 Oct 2015 20:12:58 +0000 (13:12 -0700)]
Fix infinite loop in Cursor::readTerminatedString

Summary: readTerminatedString could infinite loop if the terminator does not appear in the contained IOBuf chain and maxLength > chain.computeChainLength.  I'm throwing out_of_range here because that more closely mirrors what the other read() functions do.

Reviewed By: siyengar

Differential Revision: D2571039

fb-gh-sync-id: 1db22089562d8767920d66a0a1b091b02de6571f

9 years agoClang support for constexpr StringPiece constructor
Giuseppe Ottaviano [Thu, 22 Oct 2015 19:11:59 +0000 (12:11 -0700)]
Clang support for constexpr StringPiece constructor

Summary: Clang's `strlen` is not `constexpr`, but `__builtin_strlen` is, so we can have an unconditional `constexpr` `StringPiece` constructor.

Reviewed By: luciang, yfeldblum

Differential Revision: D2561782

fb-gh-sync-id: 51e76a0d50355cc5ead1148ba2389b640a6888de

9 years agoFix gcc 5.2 compilation when _GLIBCXX_USE_CXX11_ABI is not 0
Yaacov Akiba Slama [Thu, 22 Oct 2015 05:30:22 +0000 (22:30 -0700)]
Fix gcc 5.2 compilation when _GLIBCXX_USE_CXX11_ABI is not 0

Summary: Tested in debian stretch when used in hhvm which can now run drupal 7.
The compilation error is also fixed by #214 but this fix maintains
 forward declarations of basic_string and list.
Closes https://github.com/facebook/folly/pull/329

Reviewed By: yfeldblum

Differential Revision: D2533880

fb-gh-sync-id: 85e18eeeba9efa1b4150217ba526b32b5573e15e

9 years agofix "iocb" reporting in AsyncIO
Philip Pronin [Wed, 21 Oct 2015 19:02:38 +0000 (12:02 -0700)]
fix "iocb" reporting in AsyncIO

Summary: A few fields were swapped, and we had unintentionall fallthrough in
switch.

Reviewed By: luciang

Differential Revision: D2565884

fb-gh-sync-id: 8ad71c090c5120e99c672f785aaefdef03469ee2

9 years agoMove FingerprintBenchmark to Folly
Rameshkumar Shihora [Wed, 21 Oct 2015 18:31:52 +0000 (11:31 -0700)]
Move FingerprintBenchmark to Folly

Summary: FingerprintBenchmark was in an internal directory before, but it belongs alongside the Fingerprint code.

Reviewed By: yfeldblum

Differential Revision: D2534646

fb-gh-sync-id: d8ded3a5a9d33f60e9674ea71dc87a2d8d19a51b

9 years agoImprove folly::Singleton try_get perf and bring back raw get benchmark
Andrii Grynenko [Wed, 21 Oct 2015 02:34:57 +0000 (19:34 -0700)]
Improve folly::Singleton try_get perf and bring back raw get benchmark

Reviewed By: elsteveogrande

Differential Revision: D2517522

fb-gh-sync-id: eab11d17ce5db94e09aa733b6067e44d36be6345

9 years agoAdd support for in-place creation of NotificationQueue::Consumer
Petr Lapukhov [Tue, 20 Oct 2015 22:30:55 +0000 (15:30 -0700)]
Add support for in-place creation of NotificationQueue::Consumer

Summary: as title, this comes handy when multiple consumers are needed
within the same class.

Reviewed By: has

Differential Revision: D2530249

fb-gh-sync-id: 942761782a100b2d3fe54d94a7c1b0e03b95a847

9 years agoAdd getIPv6For6To4 to IPAddressV4
Emil Hesslow [Tue, 20 Oct 2015 21:52:07 +0000 (14:52 -0700)]
Add getIPv6For6To4 to IPAddressV4

Summary: - I added this in PHP ( D2534138 ) so add it here too
- This is my first folly diff so I probably done something wrong :)

Reviewed By: yfeldblum

Differential Revision: D2549168

fb-gh-sync-id: 5e6a80097be01fb54342e0c9da5b69465f695f80

9 years agoBring zstd support into folly/io/Compression.h
Jon Maltiel Swenson [Tue, 20 Oct 2015 03:18:30 +0000 (20:18 -0700)]
Bring zstd support into folly/io/Compression.h

Summary: Bring zstd support into folly/io/Compression.h

Reviewed By: chipturner

Differential Revision: D2551026

fb-gh-sync-id: 7c13338d45efb0fc19f0b44015c7e62d945a483b

9 years agoRemove boost dependency from folly/ProducerConsumerQueue.h
Bruno Goncalves [Sat, 17 Oct 2015 02:03:22 +0000 (19:03 -0700)]
Remove boost dependency from folly/ProducerConsumerQueue.h

Summary: Boost is great, but c++11 incorporate some of their stuffs, and classes like ProducerConsumerQueue don't need it anymore.
Closes https://github.com/facebook/folly/pull/321

Reviewed By: fredemmott, yfeldblum

Differential Revision: D2519081

fb-gh-sync-id: b138a5af4662d1e7ef5e0823cf4001880ee02456

9 years agoChange NotificationQueue assert -> CHECK
Ranjeeth Dasineni [Sat, 17 Oct 2015 00:22:49 +0000 (17:22 -0700)]
Change NotificationQueue assert -> CHECK

Summary: If the eventFd goes bad, NotificationQueue consumers can cause their event loop to spin indefinitely.  If libevent gets POLLERR on the fd, it calls handlerReady, which triggers a read.  The read will fail, but the callback is never uninstalled.  I'm not sure it would be easy to recover gracefully from this, so crash hard instead.

Reviewed By: yfeldblum, pgriess

Differential Revision: D2550270

fb-gh-sync-id: c9575fbda778b3625da6d9db6b0542b8263f230a

9 years agoCommiting missing header file change from D2408773
Kyle Nekritz [Fri, 16 Oct 2015 22:57:07 +0000 (15:57 -0700)]
Commiting missing header file change from D2408773

Summary: AsyncSSLSocket.h change was not synced from D2408773 /
f7176051f816980a985beeb9b8a907dddd0dc0e3.

Test Plan: file matches D2408773

Reviewers:

CC:

Task ID: #

Blame Rev:

9 years agofix initializer order bug in MemoryIdler
Nathan Bronson [Fri, 16 Oct 2015 21:27:11 +0000 (14:27 -0700)]
fix initializer order bug in MemoryIdler

Summary: Make sure page size has been fetched from the operating system
before it is used in asserts.

Reviewed By: meyering

Differential Revision: D2551368

fb-gh-sync-id: d3735571e2a45f613bbbd7e0f158a755d36b376c

9 years agoAvoid the ODR issue with ThreadLocalDetail's kInvalid
Yedidya Feldblum [Fri, 16 Oct 2015 19:46:00 +0000 (12:46 -0700)]
Avoid the ODR issue with ThreadLocalDetail's kInvalid

Summary: [Folly] Avoid the ODR issue with `ThreadLocalDetail`'s `kInvalid`.

The problem is that it is a `static constexpr` class member, so pull it out of the class.

Reviewed By: bmaurer

Differential Revision: D2549272

fb-gh-sync-id: 28a73e73b9cf9f21bee2bba2125513c02ef56ce2

9 years agoReverting D2503151 to unbreak buck build
Madhu Ramanathan [Fri, 16 Oct 2015 18:07:24 +0000 (11:07 -0700)]
Reverting D2503151 to unbreak buck build

Summary: This breaks buck build. Reverting till the fix is in to unblock build pipeline.

Reviewed By: jmswen

Differential Revision: D2550685

fb-gh-sync-id: 7623e6c7fcaad70d7d207ec10a59f7381c72cebc

9 years agoBring ZSTD support into folly/io/Compression.h
Jon Maltiel Swenson [Fri, 16 Oct 2015 16:42:43 +0000 (09:42 -0700)]
Bring ZSTD support into folly/io/Compression.h

Summary: Bring ZSTD support into folly/io/Compression.h

Reviewed By: chipturner

Differential Revision: D2503151

fb-gh-sync-id: c1450cecc8197db654b7a080a63753caa666f686

9 years agoMissed some derivation from boost::noncopyable after deleting the .hpp header.
Aaron Roth [Fri, 16 Oct 2015 14:54:02 +0000 (07:54 -0700)]
Missed some derivation from boost::noncopyable after deleting the .hpp header.

Summary: There remained some derivations from boost::noncopyable in inner classes after boost/noncopyable.hpp was deleted in D2459355. Get rid of these two.

Reviewed By: meyering

Differential Revision: D2485930

fb-gh-sync-id: 89546490b15fa4279debf4b9cabcf48d3dc336bb

9 years agoAdd connection event callback to AsyncServerSocket
Mohammad Husain [Fri, 16 Oct 2015 04:13:25 +0000 (21:13 -0700)]
Add connection event callback to AsyncServerSocket

Summary: Adding a callback to AsyncServerSocket to get notified of client connection events. This can be used for example to record stats about these events.

Reviewed By: @afrind

Differential Revision: D2544776

fb-gh-sync-id: 20d22cfc939c5b937abec2b600c10b7228923ff3

9 years agofolly: Symbolizer: don't colorize TERM="dumb" or TERM="" or TERM-undefined TTYs
Lucian Grijincu [Fri, 16 Oct 2015 03:04:34 +0000 (20:04 -0700)]
folly: Symbolizer: don't colorize TERM="dumb" or TERM="" or TERM-undefined TTYs

Reviewed By: @dcolascione

Differential Revision: D2548486

fb-gh-sync-id: 6e2d7e84598eb5b05aba7a262b7c53532337dbe3

9 years agofolly: Symbolizer: don't allocate from function which is supposed to be signal safe
Lucian Grijincu [Fri, 16 Oct 2015 02:17:30 +0000 (19:17 -0700)]
folly: Symbolizer: don't allocate from function which is supposed to be signal safe

Reviewed By: @philippv, @dcolascione

Differential Revision: D2548023

fb-gh-sync-id: d2b0571d5db03e38ed17a5de6a13d2194a05b2b9

9 years agoSpecialize and implement setThreadName only on some platforms
Yedidya Feldblum [Fri, 16 Oct 2015 01:55:27 +0000 (18:55 -0700)]
Specialize and implement setThreadName only on some platforms

Summary: [Folly] Specialize and implement `setThreadName` only on some platforms.

With this technique, we can compile setThreadName and programs that call it on MSVC/Windows and on other platforms that don't have the underlying pthread call.

This is an alternative to: https://reviews.facebook.net/D46317.

Reviewed By: @nbronson

Differential Revision: D2535593

fb-gh-sync-id: 09d26f53e3fe69b49326b5b6492a7d59f86db2e8

9 years agoundefined reference to 'folly::threadlocal_detail::StaticMeta<void>::EntryID::kInvalid'
Jody Ho [Fri, 16 Oct 2015 01:51:01 +0000 (18:51 -0700)]
undefined reference to 'folly::threadlocal_detail::StaticMeta<void>::EntryID::kInvalid'

Summary: In some cases, folly::threadlocal_detail::StaticMeta<void>::EntryID::kInvalid
is odr-used, a definition at the namespace scope is required even though it has
been initialized with a brace-or-equal initializer.

See http://en.cppreference.com/w/cpp/language/static

Reviewed By: @yfeldblum

Differential Revision: D2548668

fb-gh-sync-id: 9cd6d7b2f37d1481d1adbf4f0a2d9e66631efd15

9 years agoAdd framework for switching certs based on signature_algorithms TLS extension.
Kyle Nekritz [Thu, 15 Oct 2015 15:19:48 +0000 (08:19 -0700)]
Add framework for switching certs based on signature_algorithms TLS extension.

Summary: Added support for switching SSLContexts based on the signature_algorithms
extension.
This diff does not currently include any logic for determining which certs use
SHA1 or not.

Some thoughts:
- This is a little scary since it defaults to SHA1 (assuming the client can't support
SHA256 if we don't see SHA256 specifically in the hello extension). We need to
be 100% sure that all clients that are going to reject SHA1 are sending this,
and that we identify it correctly.
- We should add logging to see when we think a client needs SHA1, when we
actually give SHA1, etc. I'm not sure what the best way to do this is with our
logging infrastructure.
- This is not setup to serve any SHA1 certs to SHA256 supporting clients.

Reviewed By: @siyengar

Differential Revision: D2408773

fb-gh-sync-id: 48ad9cdfaae25e144c0964b9bfb1c342b137ffca

9 years agoFix Build: under GCC 4.9 + ASAN, RangeSse42.cpp fails to build
Yedidya Feldblum [Thu, 15 Oct 2015 05:39:59 +0000 (22:39 -0700)]
Fix Build: under GCC 4.9 + ASAN, RangeSse42.cpp fails to build

Summary: [Folly] Fix Build: under GCC 4.9 + ASAN, `RangeSse42.cpp` fails to build.

Reviewed By: @ldemailly, @meyering

Differential Revision: D2544284

fb-gh-sync-id: fd50f8b326252291ad3a5d9fe956e7e647ad0133

9 years agoAdd handshake and connect times
Subodh Iyengar [Thu, 15 Oct 2015 05:03:26 +0000 (22:03 -0700)]
Add handshake and connect times

Summary: Add api to get time taken to establish
connections and to complete handshake
for clients using AsyncSocket directly.

Reviewed By: @afrind

Differential Revision: D2435074

fb-gh-sync-id: f44c336e62c426736eb5b3d88dd57a18572382e8

9 years agoEphemeral ciphers in false start list
Subodh Iyengar [Thu, 15 Oct 2015 05:01:55 +0000 (22:01 -0700)]
Ephemeral ciphers in false start list

Summary: Only include ephemeral ciphers in false start list.

Reviewed By: @​mzlee

Differential Revision: D2429447

fb-gh-sync-id: 430d287a93249ff72b9ebe7db3bc283bb0712600

9 years agoFix Build: address some maybe-uninitialized warnings in folly/test/StringTest.cpp
Yedidya Feldblum [Wed, 14 Oct 2015 05:08:20 +0000 (22:08 -0700)]
Fix Build: address some maybe-uninitialized warnings in folly/test/StringTest.cpp

Summary: [Folly] Fix Build: address some `maybe-uninitialized` warnings in `folly/test/StringTest.cpp`.

Reviewed By: @meyering

Differential Revision: D2535743

fb-gh-sync-id: fa6a071436d22169e2be69cec1abae19851657d2

9 years agoFix Build: address some maybe-uninitialized warnings in folly/io/async/EventBase.cpp
Yedidya Feldblum [Wed, 14 Oct 2015 00:28:55 +0000 (17:28 -0700)]
Fix Build: address some maybe-uninitialized warnings in folly/io/async/EventBase.cpp

Summary: [Folly] Fix Build: address some `maybe-uninitialized` warnings in `folly/io/async/EventBase.cpp`.

Reviewed By: @meyering

Differential Revision: D2535753

fb-gh-sync-id: ff32f6957675d3b6d0267b1a59fb0c3aac4fe86e

9 years agoHandle less_than_impl and greater_than_impl under MSVC
Orvid King [Tue, 13 Oct 2015 22:26:52 +0000 (15:26 -0700)]
Handle less_than_impl and greater_than_impl under MSVC

Summary: MSVC chokes on the template constraints of these functions, so use a single implementation that will be const-folded by the optimizer instead.
Closes https://github.com/facebook/folly/pull/281

Reviewed By: @yfeldblum

Differential Revision: D2419069

fb-gh-sync-id: c9ad3d135430f8265bbc90391b45d9295d6de362

9 years ago(folly) have Try::moveFromTry take an lvalue
Hans Fugal [Tue, 13 Oct 2015 21:20:21 +0000 (14:20 -0700)]
(folly) have Try::moveFromTry take an lvalue

Summary: This is a case of having to say what you're doing twice, and it's unnecessary.
This change should not break anything as calling `std::move(lvalue)` where an
lvalue reference is expected will just be superfluous.

Reviewed By: @jsedgwick

Differential Revision: D2534944

fb-gh-sync-id: fdcd168f369d95b0f28abe23b401b4321f51fc36

9 years agonever destroy LifoSem's wait node pool
Nathan Bronson [Tue, 13 Oct 2015 21:07:12 +0000 (14:07 -0700)]
never destroy LifoSem's wait node pool

Summary: Some LifoSem-s survive late into program execution, which means
that destroying the IndexedMemPool that holds LifoSem waiter nodes can
cause crashes during program shutdown.

Reviewed By: @chadparry

Differential Revision: D2536597

fb-gh-sync-id: c9b3b73b61f2b8bdcb00d03f4c6d3daf24b267c3

9 years agoDon't do memory operations in chunks on MSVC
Orvid King [Tue, 13 Oct 2015 18:58:18 +0000 (11:58 -0700)]
Don't do memory operations in chunks on MSVC

Summary: Because, especially with the way that munmap is implemented in my windows port, this is a very bad idea. Plus, it's completely unnecessary on Windows.
Closes https://github.com/facebook/folly/pull/265

Reviewed By: @yfeldblum

Differential Revision: D2283757

fb-gh-sync-id: 831c8aaad9bd5ad0fe091ea1e006814774d8a27c

9 years agoGetter to know if the socket is accepting new connections
Mohammad Husain [Tue, 13 Oct 2015 17:21:40 +0000 (10:21 -0700)]
Getter to know if the socket is accepting new connections

Reviewed By: @yfeldblum

Differential Revision: D2534627

fb-gh-sync-id: 2934911b69542b4befa8dc03ec3cadb4a148496d

9 years agoFix ThreadLocal on android/apple
Ben Maurer [Tue, 13 Oct 2015 16:08:02 +0000 (09:08 -0700)]
Fix ThreadLocal on android/apple

Summary: The thread local destructor was assuming that the singleton object
had been created.

Reviewed By: @​yangchi

Differential Revision: D2536166

fb-gh-sync-id: b0c08e0990f684c0afae054ee17c62a924260f2b

9 years agofolly: NotificationQueue: fix headers
Lucian Grijincu [Tue, 13 Oct 2015 09:49:16 +0000 (02:49 -0700)]
folly: NotificationQueue: fix headers

Summary: Include headers for all std:: stuff used in the header + getpid().

```
       #include <sys/types.h>
       #include <unistd.h>

       pid_t getpid(void);
       pid_t getppid(void);
```

Reviewed By: @yfeldblum

Differential Revision: D2535284

fb-gh-sync-id: b1167e8f382878d27553161b9b569968006355b3

9 years agofolly: fix build with clang 3.6 -Werror
Igor Sugak [Tue, 13 Oct 2015 00:18:50 +0000 (17:18 -0700)]
folly: fix build with clang 3.6 -Werror

Summary: Fix a few `-Wsign-compare` violations

Reviewed By: @meyering

Differential Revision: D2527969

fb-gh-sync-id: 140acbd06eedf2e2a315e1927b331ff5efb20d0f

9 years agofolly: fix clang -Wpessimizing-move
Igor Sugak [Tue, 13 Oct 2015 00:15:20 +0000 (17:15 -0700)]
folly: fix clang -Wpessimizing-move

Summary: Make folly `-Wpessimizing-move` clean:

Common errors:
```lang=bash
folly/io/test/NetworkBenchmark.cpp:71:30: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
    unique_ptr<IOBuf> next = std::move(head->pop());
                             ^
folly/io/IOBufQueue.cpp:153:28: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
      appendToChain(head_, std::move(
                           ^
folly/IPAddressV6.cpp:341:12: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]
    return std::move(ip);
           ^
folly/IPAddressV6.cpp:341:12: note: remove std::move call here
    return std::move(ip);
           ^~~~~~~~~~  ~
1 error generated.
```

Reviewed By: @fugalh, @meyering

Differential Revision: D2526950

fb-gh-sync-id: 49291a8b49905eb9b2042d004830ff2f599dfbd3

9 years agoadd shutdownWrite to wangle for closing socket write only
Woo Xie [Mon, 12 Oct 2015 22:48:56 +0000 (15:48 -0700)]
add shutdownWrite to wangle for closing socket write only

Summary: current wangle has no way to close socket write side. writeFlags is extended so that wangle/AsyncSocketHandler can distinguish closeNow(), closeWithReset() and shutdownWrite()

Reviewed By: @viswanathgs

Differential Revision: D2522056

fb-gh-sync-id: 60616176d78311a4a09f9761a6ccda01dd502a88

9 years agoSIOF-proof thread local
Ben Maurer [Mon, 12 Oct 2015 21:35:54 +0000 (14:35 -0700)]
SIOF-proof thread local

Summary: Right now ThreadLocal & friends don't operate correctly when used as a
static variable (which is the idiomatic way to use them). The TLS id is
allocated in the static constructor so anybody who uses the ID prior to
first use would use an invalid ID. This makes ThreadLocal unusable for core
code such as per-thread reference counting.

This diff allocates the ID on first use. By making the invalid ID maxint we
avoid adding any extra branches in the fast path. We can then make the
constructor a constexpr meaning that initialization will happen prior to
any code running.

Reviewed By: @meyering

Differential Revision: D2457989

fb-gh-sync-id: 21d0c0d00c638fbbd36148d14d4c891f66f83706

9 years agoMove digits_to into .cpp
Ben Maurer [Mon, 12 Oct 2015 18:06:53 +0000 (11:06 -0700)]
Move digits_to into .cpp

Summary: objdump was showing that the shiftXXX tables are being generated each
time this file is included. For example, HHVM has about 200 of each
of the 4 tables. Since each one is 512 bytes this is 400 KB. I'm not
quite sure why this was happening -- I'd think that the linker would
combine a constant table that was identical.

I think the best thing to do here is just to use extern template. This
way you there's only one copy of the table and you don't have to parse
all of this code in every file

Reviewed By: @yfeldblum

Differential Revision: D2506571

fb-gh-sync-id: b01a522c536a2ff4136340245cacaa33897afefb

9 years agoFix Build: GCC 4.9 has std::make_unique but not __cplusplus >= 201402L
Yedidya Feldblum [Sat, 10 Oct 2015 02:09:42 +0000 (19:09 -0700)]
Fix Build: GCC 4.9 has std::make_unique but not __cplusplus >= 201402L

Summary: [Folly] Fix Build: GCC 4.9 has `std::make_unique` but not `__cplusplus >= 201402L`.

Reviewed By: @igorsugak

Differential Revision: D2528584

fb-gh-sync-id: 9ad0567429698fb1320ad4066ee06add31acbd57

9 years agoMerge pull request #331 from vbuslov/config_fix
Hans Fugal [Fri, 9 Oct 2015 20:15:35 +0000 (13:15 -0700)]
Merge pull request #331 from vbuslov/config_fix

Fix configure script bug on Mac OS X

9 years agoaggregator: fix `doEagerInitVia`
Steve O'Brien [Thu, 8 Oct 2015 22:03:22 +0000 (15:03 -0700)]
aggregator: fix `doEagerInitVia`

Summary: Allow notification upon async eager initialization completion.

Reviewed By: @luciang

Differential Revision: D2518925

fb-gh-sync-id: 95f96da2afa6e5953630dd935d74819521716e5f

9 years agoFix incorrect variable in dynamic examples
软件工程师李飛 [Thu, 8 Oct 2015 20:02:35 +0000 (13:02 -0700)]
Fix incorrect variable in dynamic examples

Summary: Fixes facebook/folly#323

Reviewed By: @JoelMarcey

Differential Revision: D2518882

Pulled By: @fredemmott

fb-gh-sync-id: fc0a07d925945f7d7e1cddb7302c8bf18e0130ab

9 years agoChanged AC_LANG from PROGRAM to SOURCE to prevent double definition of main
Vlad Buslov [Fri, 9 Oct 2015 12:50:09 +0000 (15:50 +0300)]
Changed AC_LANG from PROGRAM to SOURCE to prevent double definition of main

9 years agoUse alloca rather than C99 stack allocated arrays
Orvid King [Thu, 8 Oct 2015 16:52:15 +0000 (09:52 -0700)]
Use alloca rather than C99 stack allocated arrays

Summary: Because MSVC doesn't support the latter.
Closes https://github.com/facebook/folly/pull/271

Reviewed By: @meyering, @fredemmott

Differential Revision: D2283975

fb-gh-sync-id: d021f739ceead9998b8fedbbd95f22ec9fe949b2

9 years agoFixed #317 - unresolved reference to __atomic_is_lock_free
Bruno Goncalves [Wed, 7 Oct 2015 22:02:56 +0000 (15:02 -0700)]
Fixed #317 - unresolved reference to __atomic_is_lock_free

Summary: Tested in:
Distro: Fedora 20 - x86_64
kernel: 3.19
compiler: gcc version 4.8.3
Closes https://github.com/facebook/folly/pull/320

Reviewed By: @sgolemon

Differential Revision: D2519083

fb-gh-sync-id: 07b1437326c393c99feeb6e0764d664d3e22faea

9 years agoSingleton: remove dependency on Future
Steve O'Brien [Wed, 7 Oct 2015 20:11:06 +0000 (13:11 -0700)]
Singleton: remove dependency on Future

Summary: Singletons requires Futures, and Futures indirectly (via HHWheelTimeKeeper) require Singletons.  This breaks the dependency.  It removes a Future-using API which will be replaced with a better alternative.

Reviewed By: @luciang

Differential Revision: D2517807

fb-gh-sync-id: 93df371a74d0f80dc8c55fb0eadd0b688b27b525

9 years agoSingleton: un-inline initialization-time-only methods
Steve O'Brien [Wed, 7 Oct 2015 13:23:01 +0000 (06:23 -0700)]
Singleton: un-inline initialization-time-only methods

Summary: Move some methods which are generally only used during initialization time (registration, eager-init functions) from the header to the .cpp file

Reviewed By: @luciang

Differential Revision: D2513043

fb-gh-sync-id: 58d1f6e0d158d805a12b8d267421927b3cfc6118

9 years agoRemove evil using statements from AsyncSSLSocket.h
Yedidya Feldblum [Wed, 7 Oct 2015 05:22:49 +0000 (22:22 -0700)]
Remove evil using statements from AsyncSSLSocket.h

Summary: [Folly] Remove evil `using` statements from `AsyncSSLSocket.h`.

`using` in headers is frowned upon.

Consider this diff a frown.

Reviewed By: @alandau

Differential Revision: D2509810

fb-gh-sync-id: 4a752b9f4a5be6ac4ca7c498c0168ffad5c35d7f

9 years agofolly: Singleton: update doc to match new Strict vs Relaxed types
Lucian Grijincu [Tue, 6 Oct 2015 19:40:23 +0000 (12:40 -0700)]
folly: Singleton: update doc to match new Strict vs Relaxed types

Summary: smallandbroken

Reviewed By: @fugalh

Differential Revision: D2509021

fb-gh-sync-id: 5e379b82615117df89cbc12943fdbe92511c067e

9 years agoUse attribute(no_sanitize) instead of no_sanitize_address to prevent clang-3.7 from ICE
Adrian Zgorzalek [Tue, 6 Oct 2015 18:19:22 +0000 (11:19 -0700)]
Use attribute(no_sanitize) instead of no_sanitize_address to prevent clang-3.7 from ICE

Summary: Stacktraces and more details can be found in the associated task
http://clang.llvm.org/docs/AttributeReference.html#no-sanitize-clang-no-sanitize seems to be the new hotness to disable sanitizers.

Reviewed By: @yfeldblum

Differential Revision: D2510320

fb-gh-sync-id: 01cce68733509a6f5bcf9dbe3a4af6fc2792a43b

9 years agoAdd byLine tests for empty cases
Tom Jackson [Mon, 5 Oct 2015 22:09:57 +0000 (15:09 -0700)]
Add byLine tests for empty cases

Summary: It works fine, this proves it.

Reviewed By: @yfeldblum, @​jkron

Differential Revision: D2509771

fb-gh-sync-id: 28805a1e1db433d3d9a44b9d33f81e30333e44ab

9 years agoCheck if handshake timeout is set in AsyncSSLSocket::isDetachable().
Kyle Nekritz [Mon, 5 Oct 2015 20:28:42 +0000 (13:28 -0700)]
Check if handshake timeout is set in AsyncSSLSocket::isDetachable().

Summary: If it is, return false.

Reviewed By: @siyengar

Differential Revision: D2503765

fb-gh-sync-id: 36b5e2e8cabc2a5157735637be6ca3414005da81

9 years agoImprove performance of fbstring copy and move ctors on small strings
Giuseppe Ottaviano [Mon, 5 Oct 2015 04:22:12 +0000 (21:22 -0700)]
Improve performance of fbstring copy and move ctors on small strings

Summary: The move constructor of `fbstring` generates a large amount of code, preventing it to be inlined, and it is inefficient for small strings. This diff fixes both problems.

Reviewed By: @yfeldblum

Differential Revision: D2505762

9 years agoFix build
Pavlo Kushnir [Sun, 4 Oct 2015 02:40:46 +0000 (19:40 -0700)]
Fix build

Summary: title

Reviewed By: @yfeldblum

Differential Revision: D2506703

9 years agoFix async readme
Andre Pinto [Sat, 3 Oct 2015 19:47:55 +0000 (12:47 -0700)]
Fix async readme

Summary: AsyncPipe is already open source

Reviewed By: @yfeldblum

Differential Revision: D2506476

9 years agoFix Build: folly/Range.h for build platforms missing SSE42 headers
Yedidya Feldblum [Sat, 3 Oct 2015 06:08:39 +0000 (23:08 -0700)]
Fix Build: folly/Range.h for build platforms missing SSE42 headers

Summary: [Folly] Fix Build: `folly/Range.h` for build platforms missing SSE42 headers.

We make the assumption that if the compiler defines the appropriate symbols indicating SSE42, that the corresponding intrinsics headers are available.

We also remove `Range.cpp` from `Makefile.am`, which we forgot to do in the blamed diff.

Reviewed By: @nbronson

Differential Revision: D2504934

9 years agoAdd "consume all captured output" callback to CaptureFD
Alexey Spiridonov [Sat, 3 Oct 2015 05:30:41 +0000 (22:30 -0700)]
Add "consume all captured output" callback to CaptureFD

Summary: I noticed myself trying to fake this kind of callback for a log-based test I was writing. It seems much nicer to add the callback to `CaptureFD` than roll ugly wrappers around it to do the same thing.

Reviewed By: @yfeldblum

Differential Revision: D2506106

9 years agoConverge folly::make_unique to C++14's std::make_unique
Yedidya Feldblum [Sat, 3 Oct 2015 04:47:38 +0000 (21:47 -0700)]
Converge folly::make_unique to C++14's std::make_unique

Summary: [Folly] Converge `folly::make_unique` to C++14's `std::make_unique`.

The primary use-case of ther deleter variety of `folly::make_unique` is `DelayedDestruction`. Let the classes matching this use-case define their own factories.

Reviewed By: @fugalh

Differential Revision: D2495718

9 years agoSupport SSE-enabled Range functions under Clang
Yedidya Feldblum [Fri, 2 Oct 2015 08:52:56 +0000 (01:52 -0700)]
Support SSE-enabled Range functions under Clang

Summary: [Folly] Support SSE-enabled `Range` functions under Clang.

Basically, we remove GCC-only -isms. In particular, we use only names from the `<emmintrins.h>` and `<smmintrins.h>` headers, instead of the GCC-specific SSE builtins that the original code uses.

But in order to get this to work, we must split out the SSE-enabled functions into their own sources and compile them with the `-msse4.2` flag. There is a way to get around this in GCC by marking individual functions as SEE-enabled, but that technique is not supported in Clang. This is the new `RangeSse42` module.

And in order to do that, we must split out the code that is called by both the original `Range` and the new SSE-enabled functions into yet a third module, `RangeCommon`.

Ahhhhhh, dependencies.

Note that we always compile the SSE-enabled functions, but we only run them on architectures supporting SSE. The original code tests the CPU's capabilities before running any SSE-enabled functions; this change retains that check.

Reviewed By: @nbronson

Differential Revision: D2428983

9 years agofix compiler warnings from gcc-4.9 + -Wunused-variable
Nathan Bronson [Fri, 2 Oct 2015 01:39:47 +0000 (18:39 -0700)]
fix compiler warnings from gcc-4.9 + -Wunused-variable

Summary: This diff fixes the compiler warnings emitted by gcc-4.9's
stricter -Wsigned-comparison check, as well as those revealed by
-Wunused-variable.

Reviewed By: @meyering, @yfeldblum

Differential Revision: D2494514

9 years agothrift-tls: Expose client common name in connection context
Alex Landau [Thu, 1 Oct 2015 22:35:37 +0000 (15:35 -0700)]
thrift-tls: Expose client common name in connection context

Summary: Server can find out client's common name through
Cpp2ConnContext::getPeerCommonName

Reviewed By: @siyengar

Differential Revision: D2469588

9 years agofix build
Alecs King [Thu, 1 Oct 2015 19:19:18 +0000 (12:19 -0700)]
fix build

Summary: fix typo

jenkins and oss build (e.g. travis) failing.

Reviewed By: @pavlo-fb

Differential Revision: D2499462

9 years agoAPIs to determine which end of the socket has closed it
Mohammad Husain [Wed, 30 Sep 2015 21:32:33 +0000 (14:32 -0700)]
APIs to determine which end of the socket has closed it

Reviewed By: @afrind

Differential Revision: D2466921

9 years agofolly Symbolizer: fix destruction-order fiasco problem
Steve O'Brien [Wed, 30 Sep 2015 21:06:22 +0000 (14:06 -0700)]
folly Symbolizer: fix destruction-order fiasco problem

Summary: On a (broken) unit test there is a bad `CHECK` during destruction time.  This triggers an ABRT, goes through the signal handler, and in the process ends up doing a use-after-free.

Moved some globals inside the functions in which they are used (w/ little duplication, as they are used in one place, mostly).

Reviewed By: @luciang, @meyering

Differential Revision: D2494046

9 years agoUpdateableSharedPtr in folly
Dave Watson [Wed, 30 Sep 2015 14:42:24 +0000 (07:42 -0700)]
UpdateableSharedPtr in folly

Summary: This diff adds UpdateableSharedPtr and FastUpdateableSharedPtr classes to folly. They are efficiet RCU-style holders for a shared_ptr. See the comment at the top of UpdateableSharedPtr.h for a more detailed description and benchmark results.

All the added files are copied from logdevice code with (almost) no changes (`logdevice/common/` on branch `origin/logdevice-latest`). We've been using them in logdevice for a few months. D1821723 introduced it.

Reviewed By: @​bmaurer

Differential Revision: D1919702