php blocking when calling the same file concurrently

后端 未结 2 1652
日久生厌
日久生厌 2021-01-22 18:10

i\'m having some really strange problem.

i wrote a filemanager in PHP with the ability to download files -- which works fine. the whole script is built as one big file.<

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-22 18:56

    Do you use sessions?

    If yes, then that's probably the problem. The default session handler uses files which have to be locked while session-enabled code is executed. Practically this means that each user executes PHP files sequentially. To solve this you must use a custom session handler that uses a DB. Read this.

    Edit: I want to point out that writing a custom session handler with no locking can be difficult and introduce various subtle bugs. Read more docs on this if you need to do it!

    Edit 2: Sometimes using session_write_close() to close the session when no longer needed is enough (see the comments).

提交回复
热议问题