Merge pull request #480 from jimis/3.3.x

Backport Mikhail's abf7f75 from master
Pre-release version bump.
Post-release version bump.
Partially revert commit 2dc1c437a9b4dc2c4a70fa476f5c556e9244b933

All known non-constant format strings were fixed, so it is now safe
to not escape % in data gathered from the modules (Redmine #1162)
(cherry picked from commit 4fb6bc6f073d749fec84f31bd3751a3446044d69)
Fixed '.' and '-' not being accepted by a commands module.

Fixes issue #2384.
(cherry picked from commit 4df9aa040046a8cab1298ab0c238b393040d183e)

Conflicts:

	libpromises/evalfunction.c
Added test case to issue #2384.
(cherry picked from commit 91a622d8d73a7b5dfe0a75c52154fb6e21c91517)
Temporary workaround for premature connection timeouts during file downloads.

Connections time out while large files are verified, leading to the next
file download failing.

This addresses #2367 while work on protocol level fix is in progress.
(cherry picked from commit 2f866688bd00bda0ed50291dbffde7b01ff6ee9d)
Pre-release version bump.
Post release version bump
Prerelease version bump
Postrelease version bump
Unlock cft_count lock before returning in case of empty list.

'list' should never be NULL, given that the function receives the address of the
list pointer, and the only call passes in &CONNECTIONLIST.

This fixes up commit e302e38e0efdb33fcd53ec7acc41686214dbc6ea
(cherry picked from commit f561f5eceb22881ab8f86119645cc08ccaa3a0ca)
Don't protect malloc call with system mutex in main server loop.

Not required to synchronize malloc calls, it's threadsafe on all supported platforms.

This partially backports f55a6610fbfcd078c1e2a58cd0da94efef35cc2d
(cherry picked from commit 5e0e6bd6575403de7758a019866c490ab2a39e30)

Conflicts:

	src/server.c
Increase the threshold for DDOS detection and apoptosis. We now need 3 x maxthreads connections to be dropped while none of the existing ones actually finish.
Merge pull request #657 from jimis/3.3.x-apoptosis_harder

Increase the threshold for DDOS detection and apoptosis. We now need 3 x...
Do an optimization/issue-correcting step during opening the database

Optimization step detects broken databases, so it lowers chances of agents
hanging forever or segfaulting inside libtokyocabinet.
(cherry picked from commit 85c165bd072a1c5a64c11faa7d1541f555226df5)
Don't provoke database corruption by mixing read/write and cursor operations
(cherry picked from commit 15176584a52ffa09bef437a04c2a07985753aea9)
Silence deprecated warnings when compiling on Mac OSX.

Majority of functions in /usr/include/openssl/crypto.h are marked as
deprecated for Mac OSX 10.7 and later. Silence warnings.
Initialize OpenSSL with callback functions for threadlocking.

This makes OpenSSL threadsafe, and allows us to remove locking around the
calls to the RSA encryption functions in cf-serverd's AuthenticationDialogue.
Implements #2678

Note: the functions used - as well as most other functions used from
OpenSSL - are marked as deprecated on Mac OSX 10.7 and later.
Compiler warnings explicitly disabled. Functions documented in OpenSSL
documentation (http://www.openssl.org/docs/crypto/threads.html) to replace
some of these functions (such as CRYPTO_THREADID_set_callback) are not
available. This implementation follows the example provided on
http://www.opensource.apple.com/source/OpenSSL/OpenSSL-10/openssl/crypto/threads/mttest.c
With OpenSSL initialized to be made thread-safe, we don't have to serialize
access to the OpenSSL functions anymore.

Some other things were protected here by the cft_system locking:

- the ServerConnectionState *conn

This structure is initialized in the main thread, and then passed to the
thread handler, which takes exclusive ownership. No access to this object
from other threads is possible or allowed.

- malloc calls

Those are implicily threadsafe on all supported platforms today