return evts[fd / (8*sizeof(*evts))] & (1U << (fd & (8*sizeof(*evts) - 1)));
}
-static inline void wake_thread(int tid)
+static inline void wake_thread(int thr)
{
- char c = 'c';
-
- DISGUISE(write(poller_wr_pipe[tid], &c, 1));
+ if (sleeping_thread_mask & (1UL << thr)) {
+ char c = 'c';
+ _HA_ATOMIC_AND(&sleeping_thread_mask, ~(1UL << thr));
+ DISGUISE(write(poller_wr_pipe[thr], &c, 1));
+ }
}
/* we need to wake up one thread to handle it immediately */
int thr = my_ffsl(fdtab[fd].thread_mask & ~tid_bit & all_threads_mask) - 1;
- _HA_ATOMIC_AND(&sleeping_thread_mask, ~(1UL << thr));
wake_thread(thr);
}
}
list_to_mt_list(&((struct tasklet *)t)->list));
_HA_ATOMIC_INC(&ha_thread_ctx[thr].rq_total);
_HA_ATOMIC_INC(&ha_thread_ctx[thr].tasks_in_list);
- if (sleeping_thread_mask & (1UL << thr)) {
- _HA_ATOMIC_AND(&sleeping_thread_mask, ~(1UL << thr));
- wake_thread(thr);
- }
+ wake_thread(thr);
return;
}
}
MT_LIST_APPEND(&ha_thread_ctx[thr].shared_tasklet_list,
list_to_mt_list(&t->list));
_HA_ATOMIC_INC(&ha_thread_ctx[thr].rq_total);
- if (sleeping_thread_mask & (1UL << thr)) {
- _HA_ATOMIC_AND(&sleeping_thread_mask, ~(1UL << thr));
- wake_thread(thr);
- }
+ wake_thread(thr);
return;
}
}
/* this tasklet runs on a specific thread. */
MT_LIST_APPEND(&ha_thread_ctx[thr].shared_tasklet_list, list_to_mt_list(&tl->list));
_HA_ATOMIC_INC(&ha_thread_ctx[thr].rq_total);
- if (sleeping_thread_mask & (1UL << thr)) {
- _HA_ATOMIC_AND(&sleeping_thread_mask, ~(1UL << thr));
- wake_thread(thr);
- }
+ wake_thread(thr);
}
}
/* If all threads that are supposed to handle this task are sleeping,
* wake one.
*/
- if (sleeping_thread_mask & (1UL << thr)) {
- unsigned long m = 1UL << thr;
-
- _HA_ATOMIC_AND(&sleeping_thread_mask, ~m);
- wake_thread(thr);
- }
+ wake_thread(thr);
}
#endif
return;