icicleio / concurrent

Concurrency component for Icicle
https://icicle.io
MIT License
172 stars 6 forks source link

`Channel` causes leaked pointers when closed inside a thread #4

Closed sagebind closed 9 years ago

sagebind commented 9 years ago

Not sure if this is intended behavior in pthreads or not, but we should refactor channels to not require resources to be transferred across threads to avoid zend_mm_heap corrupted errors.

trowski commented 9 years ago

It wasn't that resources were being transferred, it was that fclose() was being called in the thread on a resource owned by the parent.

I modified the socket component to not call fclose() on destruct so the user can decide if the socket should be closed or not in the current context. Socket::close() still calls fclose(). Generally Socket::close() needs to be explicitly called anyway because otherwise the loop will hold a reference to the Socket object and __destruct() will won't be called until script termination. This should be made clear in the socket documentation.

sagebind commented 9 years ago

Noice. :facepunch: