From 68a9a74c1aec26989ee7b26c99083bcf8dd1216d Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 29 Apr 2022 12:17:35 +0200 Subject: [PATCH] Use better get(); writen2(); release() idiom --- pdns/signingpipe.cc | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/pdns/signingpipe.cc b/pdns/signingpipe.cc index 8f9817e694..30bd41a812 100644 --- a/pdns/signingpipe.cc +++ b/pdns/signingpipe.cc @@ -199,14 +199,9 @@ void ChunkedSigningPipe::sendRRSetToWorker() // it sounds so socialist! if(wantWrite && !rwVect.second.empty()) { shuffle(rwVect.second.begin(), rwVect.second.end(), pdns::dns_random_engine()); // pick random available worker - auto ptr = d_rrsetToSign.release(); - try { - writen2(*rwVect.second.begin(), &ptr, sizeof(ptr)); - } - catch (...) { - delete ptr; - throw; - } + auto ptr = d_rrsetToSign.get(); + writen2(*rwVect.second.begin(), &ptr, sizeof(ptr)); + d_rrsetToSign.release(); d_rrsetToSign = make_unique(); d_outstandings[*rwVect.second.begin()]++; d_outstanding++; @@ -255,14 +250,9 @@ void ChunkedSigningPipe::sendRRSetToWorker() // it sounds so socialist! if(wantWrite) { // our optimization above failed, we now wait synchronously rwVect = waitForRW(false, wantWrite, -1); // wait for something to happen shuffle(rwVect.second.begin(), rwVect.second.end(), pdns::dns_random_engine()); // pick random available worker - auto ptr = d_rrsetToSign.release(); - try { - writen2(*rwVect.second.begin(), &ptr, sizeof(ptr)); - } - catch (...) { - delete ptr; - throw; - } + auto ptr = d_rrsetToSign.get(); + writen2(*rwVect.second.begin(), &ptr, sizeof(ptr)); + d_rrsetToSign.release(); d_rrsetToSign = make_unique(); d_outstandings[*rwVect.second.begin()]++; d_outstanding++; -- 2.47.2