Skip to content
This repository was archived by the owner on Dec 16, 2019. It is now read-only.
This repository was archived by the owner on Dec 16, 2019. It is now read-only.

How to get unique php-extension instance for each php thread? #936

@mvnaz

Description

@mvnaz

Hello, this is not an issue or bug. This is the question related to pthreads extension. So I hope I may ask here.

I have a difficult task, creating php extension (I will call it custom-extension) with libssh2. Extension must work with pthreads together. Let's say I have 100 php threads. As I see all threads has the same custom-extension instance. And, as I think, this is why I get a lot problems when I use more then 1 thread. For example global variables in custom-extension C code will be owerwritten by pthreads. Sure, I may use __thread, but it doesn't solve the problem. Libssh2 usage in custom-extension makes things more difficult. I will not provide any code, because I think it doesn't matter.

So the question is: is it possible to make each php pthread use own new custom-extension instance ? I think it will be better for my case, because then I will encapsulate custom-extension for each thread. Also libssh2, used in custom-extension also should be new instance for each thread. This way has to save me for variables overwritting and other segfaults errors.

So maybe I should just compile custom-extension with some flag to get the goal ? I think I have to make own custom-extension instance for each thread to satisfy shared-nothing rule.

Environment

  • Ubuntu 18.04 64bit*
  • PHP CLI 7.2.2 ZTS*

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions