]> granicus.if.org Git - pdns/commitdiff
Make sure the DelayPipe thread is the last member initialized
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 5 Jan 2016 18:01:01 +0000 (19:01 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 5 Jan 2016 18:01:01 +0000 (19:01 +0100)
Otherwise the new thread might start running and access
uninitialized members like d_pipe or d_work.
On my host, running dnsdist in gdb without this modification
results in a SIGSEGV at delaypipe.cc:141.

pdns/delaypipe.hh

index 68e6265be2378cda8cc360966e727bb2af2c35fd..7f7e02a38264a25461994fe34ba5ca036f5e3e0b 100644 (file)
@@ -38,7 +38,6 @@ public:
   void submit(T& t, int msec); //!< don't try for more than 4294 msec
 
 private:
-  std::thread d_thread;
   void worker();
   struct Combo
   {
@@ -60,6 +59,7 @@ private:
   };
   std::multimap<struct timespec, T, tscomp> d_work;
   void gettime(struct timespec* ts);
+  std::thread d_thread;
 };
 
 #include "delaypipe.cc"