krakjoe / pthreads

Threading for PHP - Share Nothing, Do Everything :)
Other
3.47k stars 501 forks source link

MaxMind extension compability #884

Open acachy opened 6 years ago

acachy commented 6 years ago

PHP 7.2.7 + pthreads master

MaxMind php-lib fails inside threads ("extends Thread").

A little debug showed that the only problem is file handle (result of "fopen"). It is valid only inside the function where it was initialized. I.e. it is impossible to store file handle in a class variable or pass it to another function.

I fixed this problem by simply making all lib-classes "extends Threaded".

However, php-lib is too slow and I need php-extension. Code of extension is very similar to php-lib. And according to error-type the reason for the problem is also same - file handles.

Any suggestions how to rewrite C-code of extension to do the same trick? Or some better way )

sirsnyder commented 5 years ago

Resources/file handles are a know problem. Maybe we get thread-safe streams in the near future, that could be a solution for the php-lib.