]> granicus.if.org Git - pdns/commitdiff
fix subtle bug with repeated timeouts on same fd
authorBert Hubert <bert.hubert@netherlabs.nl>
Sat, 29 Dec 2007 14:34:27 +0000 (14:34 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sat, 29 Dec 2007 14:34:27 +0000 (14:34 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1116 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/mtasker.cc

index f690922df147b6ea147bf173f7ba354559242eb5..039969ca68abaafb11fa547cf97a2fcee02c1f72 100644 (file)
@@ -301,12 +301,14 @@ template<class Key, class Val>bool MTasker<Key,Val>::schedule(unsigned int now)
     for(typename waiters_by_ttd_index_t::iterator i=ttdindex.begin(); i != ttdindex.end(); ) {
       if(i->ttd && (unsigned int)i->ttd < now) {
        d_waitstatus=TimeOut;
-       if(swapcontext(&d_kernel,i->context)) { // swaps back to the above point 'A'
+       ucontext_t* uc = i->context;
+       ttdindex.erase(i++);                  // removes the waitpoint 
+
+       if(swapcontext(&d_kernel, uc)) { // swaps back to the above point 'A'
          perror("swapcontext in schedule2");
          exit(EXIT_FAILURE);
        }
-       delete i->context;              
-       ttdindex.erase(i++);                  // removes the waitpoint 
+       delete uc;
       }
       else if(i->ttd)
        break;