mirror of https://github.com/schoebel/mars
all: fix race on wakeup
This commit is contained in:
parent
bc0be4fd19
commit
2c19adc550
|
@ -30,26 +30,32 @@
|
|||
#define brick_wait(wq, flag, condition, timeout) \
|
||||
({ \
|
||||
unsigned long __tmout = (timeout); \
|
||||
int __old_flag; \
|
||||
\
|
||||
might_sleep(); \
|
||||
(flag) = false; \
|
||||
smp_wmb(); \
|
||||
smp_rmb(); \
|
||||
__old_flag = (flag); \
|
||||
\
|
||||
while (!(condition)) { \
|
||||
int __new_flag; \
|
||||
\
|
||||
__tmout = wait_event_interruptible_timeout( \
|
||||
wq, \
|
||||
({ smp_rmb(); (flag); }), \
|
||||
({ smp_rmb(); \
|
||||
__new_flag = (flag); \
|
||||
__old_flag != __new_flag; }), \
|
||||
__tmout); \
|
||||
if (__tmout <= 1) \
|
||||
break; \
|
||||
(flag) = false; \
|
||||
smp_wmb(); \
|
||||
__old_flag = __new_flag; \
|
||||
} \
|
||||
__tmout; \
|
||||
})
|
||||
|
||||
#define brick_wake(wq, flag) \
|
||||
({ \
|
||||
(flag) = true; \
|
||||
smp_rmb(); \
|
||||
(flag)++; \
|
||||
smp_wmb(); \
|
||||
wake_up_interruptible_all(wq); \
|
||||
})
|
||||
|
|
|
@ -253,7 +253,7 @@ int log_scan(void *buf, int len, loff_t file_pos, int file_offset, bool sloppy,
|
|||
struct log_status {
|
||||
// interfacing
|
||||
wait_queue_head_t *signal_event;
|
||||
bool *signal_flag;
|
||||
int *signal_flag;
|
||||
// tunables
|
||||
loff_t start_pos;
|
||||
loff_t end_pos;
|
||||
|
|
|
@ -240,9 +240,9 @@ struct trans_logger_brick {
|
|||
// queues
|
||||
struct logger_queue q_phase[LOGGER_QUEUES];
|
||||
struct rank_data rkd[LOGGER_QUEUES];
|
||||
int caller_flag;
|
||||
int worker_flag;
|
||||
bool delay_callers;
|
||||
bool caller_flag;
|
||||
bool worker_flag;
|
||||
/* termination */
|
||||
bool terminate;
|
||||
bool terminated;
|
||||
|
|
Loading…
Reference in New Issue