Menu

#18 Calling a function only once when the module get loaded

open
nobody
None
1
2004-10-12
2004-03-03
Anonymous
No

I want to call my function when the module gets loaded.
I called that fuction from mod_gzip_init, but it is getting
called twice.
Please let me know how can I accomplish this?

Discussion

  • Michael Schröpl

    Logged In: YES
    user_id=211909

    I don't think you can do that so easily.

    mod_gzip is being called twice by the Apache request
    handlng, first during the request analysis phase and second
    after the content to be sent has already been created.
    Therefore mod_gzip does its item_rule checking twice (which
    is the reason why you have to configure it as to fire an
    "include" rule in each of these two passes).

    So if you call a function from the mod_gzip source then your
    function will be called twice because mod_gzip itself will
    be calle twice. To prevent this you would have to store
    information about whether you are in the first or second
    invocation; perhaps you might use the "notes" concept in
    Apache (which mod_gzip uses to store information about the
    compression result). In this case you might check the
    existance of the note before your function's invocation and
    create the nore afterwards, thus enforcing your function to
    be called in "phase 1" only - if that's what you want. Or if
    you want to be called in phase 2 only you just complement
    the check, so that your function will be invoked only when
    the note has already been set.

     
  • Michael Schröpl

    • priority: 5 --> 1
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.