MXS-1985: Add debug assertions to dcb_foreach
The dcb_foreach function is not safe to use from multiple threads at the same time. This should be asserted by checking that the function is called only from the main worker. The addition of this assertion also implies that only administrative operations should use the dcb_foreach function. To accommodate this change, the KILL command iteration needs to be adjusted.
This commit is contained in:
parent
30ac15817f
commit
101dad74a7
@ -356,6 +356,8 @@ static inline void dcb_readq_set(DCB *dcb, GWBUF *buffer)
|
||||
*
|
||||
* @deprecated You should not use this function, use dcb_foreach_parallel instead
|
||||
*
|
||||
* @warning This must only be called from the main thread, otherwise deadlocks occur
|
||||
*
|
||||
* @param func Function to call. The function should return @c true to continue iteration
|
||||
* and @c false to stop iteration earlier. The first parameter is a DCB and the second
|
||||
* is the value of @c data that the user provided.
|
||||
|
@ -2937,6 +2937,7 @@ private:
|
||||
|
||||
bool dcb_foreach(bool(*func)(DCB *dcb, void *data), void *data)
|
||||
{
|
||||
ss_dassert(Worker::get_current() == Worker::get(0));
|
||||
SerialDcbTask task(func, data);
|
||||
Worker::execute_serially(task);
|
||||
return task.more();
|
||||
|
Loading…
x
Reference in New Issue
Block a user