residuum / PuRestJson

PuREST JSON is a library for connecting Puredata (Pd) to HTTP services and encoding and decoding JSON data.
ix.residuum.org/pd/purest_json.html
Other
74 stars 9 forks source link

try to make library more thread-safe #66

Closed sebshader closed 2 years ago

sebshader commented 2 years ago

try making things more threadsafe, to continue from 2a546f65fb79d29c0fcb30ce36fac9a51188d379.

I believe calls to gensym, pd_error and post should be locked as well, if called from a thread

if the thread is currently working it seems like messages to the pd object shouldn't modify the state of the "common" object either, since that might also make a race condition from my understanding. (through "partial reads", segfaults and such)

I am also wondering, if the object is being freed correctly; if the thread is currently in the middle of a request, will deleting things in ctw_free create a segfault on occasion, if the request thread tries to access those fields? should there be some kind of thread_join beforehand? (I tried cancelling and then joining the thread but I'm somewhat out of my depth and that actually crashed from a segfault in curl, perhaps unrelated tho)