]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/signingpipe.hh
fix up AtomicCounter being used unitialized here and there, plus possibly fix clang...
[thirdparty/pdns.git] / pdns / signingpipe.hh
1 #ifndef PDNS_SIGNINGPIPE
2 #define PDNS_SIGNINGPIPE
3 #include <vector>
4 #include <pthread.h>
5 #include <stdio.h>
6 #include "dnsseckeeper.hh"
7 #include "dns.hh"
8
9 void writeLStringToSocket(int fd, const string& msg);
10 bool readLStringFromSocket(int fd, string& msg);
11
12 /** input: DNSResourceRecords ordered in qname,qtype (we emit a signature chunk on a break)
13 * output: "chunks" of those very same DNSResourceRecords, interleaved with signatures
14 */
15
16 class ChunkedSigningPipe
17 {
18 public:
19 typedef vector<DNSResourceRecord> rrset_t;
20 typedef rrset_t chunk_t; // for now
21
22 ChunkedSigningPipe(const DNSName& signerName, bool mustSign, /* FIXME servers is unused? */ const string& servers=string(), unsigned int numWorkers=3);
23 ~ChunkedSigningPipe();
24 bool submit(const DNSResourceRecord& rr);
25 chunk_t getChunk(bool final=false);
26
27 std::atomic<unsigned long> d_signed;
28 int d_queued;
29 int d_outstanding;
30 unsigned int getReady();
31 private:
32 void flushToSign();
33 void dedupRRSet();
34 void sendRRSetToWorker(); // dispatch RRSET to worker
35 void addSignedToChunks(chunk_t* signedChunk);
36 pair<vector<int>, vector<int> > waitForRW(bool rd, bool wr, int seconds);
37
38 void worker(int n, int fd);
39
40 static void* helperWorker(void* p);
41
42 unsigned int d_numworkers;
43 int d_submitted;
44
45 rrset_t* d_rrsetToSign;
46 std::deque< std::vector<DNSResourceRecord> > d_chunks;
47 DNSName d_signer;
48
49 chunk_t::size_type d_maxchunkrecords;
50
51 std::vector<int> d_sockets;
52 std::set<int> d_eof;
53 vector<pthread_t> d_tids;
54 bool d_mustSign;
55 bool d_final;
56 };
57
58 #endif