Changeset 652
- Timestamp:
- 04/04/06 14:13:37 (7 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 3 modified
-
mtasker.cc (modified) (5 diffs)
-
mtasker.hh (modified) (2 diffs)
-
pdns_recursor.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/mtasker.cc
r628 r652 190 190 { 191 191 d_runQueue.push(d_tid); 192 if(swapcontext(d_threads[d_tid] .first,&d_kernel) < 0) { // give control to the kernel192 if(swapcontext(d_threads[d_tid] ,&d_kernel) < 0) { // give control to the kernel 193 193 perror("swapcontext in yield"); 194 194 exit(EXIT_FAILURE); … … 230 230 \param val A void pointer that can be used to pass data to the thread 231 231 */ 232 template<class Key, class Val>void MTasker<Key,Val>::makeThread(tfunc_t *start, void* val , const string& name)232 template<class Key, class Val>void MTasker<Key,Val>::makeThread(tfunc_t *start, void* val) 233 233 { 234 234 ucontext_t *uc=new ucontext_t; … … 245 245 makecontext (uc, (void (*)(void))threadWrapper, 4, this, start, d_maxtid, val); 246 246 #endif 247 d_threads[d_maxtid]= make_pair(uc, name);247 d_threads[d_maxtid]=uc; 248 248 d_runQueue.push(d_maxtid++); // will run at next schedule invocation 249 249 } … … 264 264 if(!d_runQueue.empty()) { 265 265 d_tid=d_runQueue.front(); 266 if(swapcontext(&d_kernel, d_threads[d_tid] .first)) {266 if(swapcontext(&d_kernel, d_threads[d_tid])) { 267 267 perror("swapcontext in schedule"); 268 268 exit(EXIT_FAILURE); … … 273 273 } 274 274 if(!d_zombiesQueue.empty()) { 275 delete[] (char *)d_threads[d_zombiesQueue.front()] .first->uc_stack.ss_sp;276 delete d_threads[d_zombiesQueue.front()] .first;275 delete[] (char *)d_threads[d_zombiesQueue.front()]->uc_stack.ss_sp; 276 delete d_threads[d_zombiesQueue.front()]; 277 277 d_threads.erase(d_zombiesQueue.front()); 278 278 d_zombiesQueue.pop(); -
trunk/pdns/pdns/mtasker.hh
r596 r652 71 71 waiters_t d_waiters; 72 72 73 typedef std::map<int, pair<ucontext_t*,string>> mthreads_t;73 typedef std::map<int,ucontext_t* > mthreads_t; 74 74 mthreads_t d_threads; 75 75 int d_tid; … … 96 96 int sendEvent(const EventKey& key, const EventVal* val=0); 97 97 void getEvents(std::vector<EventKey>& events); 98 void makeThread(tfunc_t *start, void* val , const string& name="");98 void makeThread(tfunc_t *start, void* val); 99 99 bool schedule(); 100 100 bool noProcesses(); 101 101 unsigned int numProcesses(); 102 102 int getTid(); 103 void setTitle(const string& name)104 {105 d_threads[d_tid].second=name;106 }107 103 108 104 private: -
trunk/pdns/pdns/pdns_recursor.cc
r647 r652 772 772 773 773 if(!((counter++)%500)) 774 MT->makeThread(houseKeeping,0 ,"housekeeping");774 MT->makeThread(houseKeeping,0); 775 775 if(statsWanted) { 776 776 doStats(); … … 887 887 dc->setSocket(*i); 888 888 dc->d_tcp=false; 889 MT->makeThread(startDoResolve, (void*) dc , "udp");889 MT->makeThread(startDoResolve, (void*) dc); 890 890 } 891 891 } … … 1037 1037 ++g_stats.qcounter; 1038 1038 ++g_stats.tcpqcounter; 1039 MT->makeThread(startDoResolve, dc , "tcp");1039 MT->makeThread(startDoResolve, dc); 1040 1040 } 1041 1041 }