fixes PowerDNS/pdns/#661

I was doing some performance testing on our 32-way servers and discovered that in the simple case where the test program returns the data straight away, about 80% of the time was being spent in the kernel in a spinlock. I've been debugging this looking at the coprocess code and discovered that this is due to the following line in coprocess.cc:

setbuf(d_fp,0); // no buffering please, confuses select

If this is removed, performance in my particular test case goes from 2000qps with powerdns running at about 2000% cpu to 10000qps with powerdns using about 300% cpu.

Obviously the comment implies that this is not a permanent solution, I guess if the timeout is specified as 0 then the select code won't be executed and so you can disable the setbuf easily enough. However perhaps if the timeout is wanted you could set an alarm() rather than using select?
fixes PowerDNS/pdns#692

For the second time when writing a backend I forgot that an ANY query needs to return any SOA data as well. This is because we store our SOA's separately from our other DNS data in order to optimize zone lookups. According to Habbie MyDNS backend has the same bug. The attached patch basically forces an SOA to be included which is actually much more optimal than anything I can do in my backends as I don't have easy access to the knowledge of:

* sd data structure;
* is this query also an SOA

meaning that if I answer it in the backend I have to do a number of additional lookups for information that is already available in the PacketHandler. Additionally, I notice that you are basically doing all the SOA setup anyway if there is anything looking like an SOA entry. So, all this patch does is strip out any SOA entries and then insert one if there should be. This seems to me to both potentially simplify backend code and fix up any user errors more accurately than the current code does.
fixes PowerDNS/pdns#693

removes number of static variables and makes them class, also optimizes if query cache is disabled.
Merge pull request #1134 from mzealey/forcesoa

fixes PowerDNS/pdns#692
Merge pull request #1136 from mzealey/backend-cache-optimization

fixes PowerDNS/pdns#693
Merge pull request #1137 from mzealey/pipe-backend-spinlock

fixes PowerDNS/pdns/#661
Align with pipebackend as per #1137 and #661
Remove unnecessary if block
Merge pull request #1160 from cmouse/remotebackend-pipe-connector-1137

Align with pipebackend as per #1137 and #661
add timeout&gracetime flags to gmysql
withhold some exceptions inside gsql
push gmysql connection logic down, to make sure connection failures do not prohibit launch
implement gracetime
add readonly mode for g(my)sql
fix error message in GSQLBackend::isMaster
fix accidental lineswap
add d_readonly check to new gsql methods (post-rebase)
log user in query log
do not error out when we can just say no in a friendly way
clear upstream caches after a successful query right after expiring gracetime