Fix CFLAGS order.

(cherry picked from commit 6cbd061d92c1dc13357d0cb87b668de9cae80798)
Fix detected flags from ACX_PTHREAD being reset.

(cherry picked from commit a131311e4f19c807a58561c37cdac99be5418fe8)
Include path should be CPPFLAGS, not CFLAGS.

(cherry picked from commit 19a5d6ac640e1e75e262cc1e575a8b3470bacf7b)
Revert "Retrying SSL_accept and SSL_connect if error.", again.

This reverts commit 39375e1bb04f165d8fe996734fe17eaccc78ca81.

All our code uses *blocking* sockets. We shouldn't have to deal with
fragile polling loops and secondary time-outs with no real reason.

There *is* one case that we get the SSL_ERROR_WANT_READ error even
though our socket is blocking, but I'll comment and cover that one case
with a separate pull request.

Conflicts:
	cf-serverd/tls_server.c
	libcfnet/tls_client.c

(cherry picked from commit 098b7a4787fe24b5b92ca4d42bc502ba2b1e617b)
Make sure there are no lingering threads when we clean up.

(cherry picked from commit 7ec31723d053f3affb5e2356245dbe707c701dbf)

Conflicts:
	cf-serverd/cf-serverd-functions.c
Merge pull request #1771 from jimis/3.6.x

Cherry-picks from master to 3.6.x.