开发者

fastCGI application code structure

开发者 https://www.devze.com 2023-02-03 04:49 出处:网络
I am writing a fastCGI application using the fastCGI development kit on Linux (Ubuntu), using Apache 2.2 + mod_fcgid.

I am writing a fastCGI application using the fastCGI development kit on Linux (Ubuntu), using Apache 2.2 + mod_fcgid.

According to the document, the correct code structure for an fastCGI app is:

  • Initialization section, which is executed only once.
  • Response loop section, whi开发者_如何学Goch gets executed every time the FastCGI script gets called.

This seems to be wrong to me, surely, if there is an initialization section, then there must be a 'Cleanup' section?

If so, where would the cleanup section be, and how can I be sure that the cleanup section ever gets called - I mean is there something in the fastCGI protocol that tells the app to terminate?

Common sense tells me to place the cleanup section after the response loop - BUT is this the correct way to clean up?


This question looks related, and might help you.


Normally when you are in the loop you will call "FCGX_Accept" function. If parent (apache) wishes to terminate FCGI child it will probably return "failure" for the accept function, in which case you should probably break the loop and cleanup on the way to exit.

0

精彩评论

暂无评论...
验证码 换一张
取 消