Lifetime of HTTPFilterContext pointer

Use this forum to post questions relating to WinGate, feature requests, technical or configuration problems

Moderator: Qbik Staff

Lifetime of HTTPFilterContext pointer

Postby Ilya » Feb 17 21 1:10 am

Hi

The documentation about HTTPFilterInstantiate says about it's return value the following:

A context pointer that you wish to return for this instantiation. This context becomes the ComponentContext member of the HTTPFilterContext that gets passed to you by the framework in other HTTP filter functions.

This enables you to have a separate object associated with the HTTP Filter instantiation and access it in the other HTTP filter functions.


Does it mean that pointer to HTTPFilterContext remains unchangeable during whole lifetime of corresponding HTTP Filter? For example, is it guaranteed that pointer to HTTPFilterContext passed to HTTPFilterResponse and all subsequent HTTPFilterResponseData callbacks will be the same within one data transfer? Also, can i use that pointer outside framework callbacks (in the separate thread) for sending data?
Ilya
 
Posts: 4
Joined: Sep 02 20 3:23 am

Re: Lifetime of HTTPFilterContext pointer

Postby adrien » Feb 28 21 12:43 pm

Hi

the HTTPFIlterContext is created when the session (connection) is set up, and kept alive and same pointer for as long as the connection is alive.

Any calls into the HTTP filter will be in the context of the thread that is the connection, so it will be valid for that.

If you send etc from another thread (your own), then there can be issues where the connection has been cleaned up. We have another API to handle this, where you request a callback into your filter.

http://docs.qbik.com/display/WINGATESDK ... stCallback

Note the return type of this function is not void, it will tell you if the connection is gone already.

Regards

Adrien
adrien
Qbik Staff
 
Posts: 5412
Joined: Sep 03 03 2:54 pm
Location: Auckland

Re: Lifetime of HTTPFilterContext pointer

Postby Ilya » Apr 06 21 11:38 pm

Thanks for answering
I need additional clarification:

Could you please describe what is "connection clean up" exactly. Will HTTPFilterDestroy be called when connection is cleaning up? If yes, can i not use HTTPFilterRequestCallback, provided that my thread will not send any data after the main thread has returned from HTTPFilterDestroy?
Ilya
 
Posts: 4
Joined: Sep 02 20 3:23 am

Re: Lifetime of HTTPFilterContext pointer

Postby adrien » Apr 08 21 12:07 pm

Hi

Are you suggesting blocking in the call to HTTPFilterDestroy?

I think if you do that, your callback probably won't come back.

We do guarantee calling HTTPFilterDestroy.

Since the client can disconnect at any time, you cannot guarantee that you can deliver all data to it anyway. So if you get called into HTTPFilterDestroy and you still have pending work happening in another thread, you need to clean that up rather than trying to deliver any data.

Regards

Adrien
adrien
Qbik Staff
 
Posts: 5412
Joined: Sep 03 03 2:54 pm
Location: Auckland


Return to WinGate

Who is online

Users browsing this forum: Bing [Bot] and 10 guests

cron