obs-scripting: Make callback "removed" variable atomic
Makes the callback variable "removed" atomic, and on script unload, first sets all callbacks to removed before actually unloading the script out of a safety precaution. (See note at the bottom for further details) This minimizes the possibility of a race condition where the script callback could be called while those callbacks were being removed. Big note for this change, this change should eventually be replaced with a reference counting ownership method where script callbacks can hold a reference and share ownership of the script if it's still alive while the script callback is being called. That way the script callbacks can safely execute. May require a fair amount of reworking of the script object.
This commit is contained in:
parent
fbcb053cfa
commit
6d3b1998ef
6 changed files with 71 additions and 29 deletions
1
deps/obs-scripting/obs-scripting-python.h
vendored
1
deps/obs-scripting/obs-scripting-python.h
vendored
|
|
@ -195,6 +195,7 @@ static inline bool py_error_(const char *func, int line)
|
|||
#define py_error() py_error_(__FUNCTION__, __LINE__)
|
||||
|
||||
#define lock_python() PyGILState_STATE gstate = PyGILState_Ensure()
|
||||
#define relock_python() gstate = PyGILState_Ensure()
|
||||
#define unlock_python() PyGILState_Release(gstate)
|
||||
|
||||
struct py_source;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue