register_shutdown_function Problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Derek Battams

    register_shutdown_function Problems

    I want to ensure that I'm releasing a lock on a file after _all_ objects
    have been destroyed. What I'm trying to do is use
    register_shutdo wn_function to call a function that releases the lock on
    the file then closes it. Testing is showing that the registered
    function is being called before all objects are destroyed. Is this
    expected behaviour? Is there a way to get the desired functionality?
    This is a standalone shell script/applicaton that isn't being run via a
    web browser. Using PHP 5.0.1 on Linux 2.6 kernel.

    - Derek
  • Chung Leong

    #2
    Re: register_shutdo wn_function Problems

    "Derek Battams" <derek@stopspam .battams.ca> wrote in message
    news:HXmWc.2489 1$rP2.4506@hydr a.nntpserver.co m...[color=blue]
    > I want to ensure that I'm releasing a lock on a file after _all_ objects
    > have been destroyed. What I'm trying to do is use
    > register_shutdo wn_function to call a function that releases the lock on
    > the file then closes it. Testing is showing that the registered
    > function is being called before all objects are destroyed. Is this
    > expected behaviour? Is there a way to get the desired functionality?
    > This is a standalone shell script/applicaton that isn't being run via a
    > web browser. Using PHP 5.0.1 on Linux 2.6 kernel.
    >
    > - Derek[/color]

    Locks are automatically removed when the script terminates, just as open
    files are automatically closed.


    Comment

    • Derek Battams

      #3
      Re: register_shutdo wn_function Problems

      Chung Leong wrote:[color=blue]
      > "Derek Battams" <derek@stopspam .battams.ca> wrote in message
      > news:HXmWc.2489 1$rP2.4506@hydr a.nntpserver.co m...
      >[color=green]
      >>I want to ensure that I'm releasing a lock on a file after _all_ objects
      >>have been destroyed. What I'm trying to do is use
      >>register_shut down_function to call a function that releases the lock on
      >>the file then closes it. Testing is showing that the registered
      >>function is being called before all objects are destroyed. Is this
      >>expected behaviour? Is there a way to get the desired functionality?
      >>This is a standalone shell script/applicaton that isn't being run via a
      >>web browser. Using PHP 5.0.1 on Linux 2.6 kernel.
      >>
      >> - Derek[/color]
      >
      >
      > Locks are automatically removed when the script terminates, just as open
      > files are automatically closed.[/color]

      True, but then I have to rely on PHP cleaning up resources in exactly
      the same order each and every time. I went looking through the PHP docs
      to see if the order of resource cleanup is guaranteed, but I don't see
      any documentation saying that it is. My testing does show that in PHP
      5.0.1 on Linux that opened files are closed after object destruction,
      but is this always going to be the case? Also, I don't like leaving
      resource cleanup to be implicitly done by the PHP engine, unless I can
      find docs that promise the order in which it will be done.

      - Derek

      Comment

      • Chung Leong

        #4
        Re: register_shutdo wn_function Problems

        "Derek Battams" <derek@stopspam .battams.ca> wrote in message
        news:%pOWc.3403 2$rP2.28316@hyd ra.nntpserver.c om...[color=blue]
        > True, but then I have to rely on PHP cleaning up resources in exactly
        > the same order each and every time. I went looking through the PHP docs
        > to see if the order of resource cleanup is guaranteed, but I don't see
        > any documentation saying that it is. My testing does show that in PHP
        > 5.0.1 on Linux that opened files are closed after object destruction,
        > but is this always going to be the case? Also, I don't like leaving
        > resource cleanup to be implicitly done by the PHP engine, unless I can
        > find docs that promise the order in which it will be done.[/color]

        "Resources are a special kind of data type in PHP. The term resources
        doesn't really refer to any special kind of data, but to an abstraction
        method for maintaining any kind of information. Resources are kept in a
        special resource list within Zend. Each entry in the list has a
        correspondendin g type definition that denotes the kind of resource to which
        it refers. Zend then internally manages all references to this resource.
        Access to a resource is never possible directly - only via a provided API.
        As soon as all references to a specific resource are lost, a corresponding
        shutdown function is called."

        Hence the answer is yes, resources will be destroyed in the correct order.


        Comment

        Working...