Termination of Xaction

Asked by Christof Gerber on 2017-06-22

I am using squid 3.5 with a custom eCAP adapter. After hostx->noteAbContentDone, how can I tell squid to terminet and destruct the Xaction. Or can I do this on my own? When I work with a workflow where the eCAP adapter does not adapt anything I can simply call hostx->vbStopMaking() and hostx->useVirgin() and then squid calls stop() followed by ~Xaction(), the destructor. The only way I found out to work is to throw an exception like Must(0) after hostx->noteAbContentDone() which results in stop() and ~Xaction() but this doesn't seem like a proper way to handle this.

Question information

Language:
English Edit question
Status:
Solved
For:
eCAP Edit question
Assignee:
No assignee Edit question
Last query:
2017-06-22
Last reply:
2017-07-08

This question was reopened

Alex Rousskov (rousskov) said : #1

Q: After hostx->noteAbContentDone(), how can I tell the host application to terminate and destruct the Xaction?

What are you trying to accomplish, exactly? Here are a few choices that may match your question:

1. Control the lifetime of the adapter transaction object.
2. Control the lifetime of the HTTP transaction that you are (or were) adapting.
3. Fix a memory leak related to the adapter transaction object.

The above list is not exhaustive. The answer will depend on your intent/situation.

Christof Gerber (sitschi) said : #2

I want to control the lifetime of the adapter transaction object. The adapted HTTP transaction was finished with my hostx->noteAbConetentDone() call. Now I want to finish the eCAP transaction for this http message. Ideally I want squid to call Xaction:stop followed by ~Xaction() as it is done after hostx->vbStopMaking followed by hostx->useVirgin() in a non-adaptive setup.

Alex Rousskov (rousskov) said : #3

> I want to control the lifetime of the adapter transaction object.

You cannot and you should not.

* Cannot: adapter::Service::makeXaction() gives a shared pointer to the host application code you do not control. The transaction object will be destroyed when the last user of that object is gone. That last user may be in the host application.

* Should not: The HTTP transaction may still need the adapter transaction object even after you are done with it.

> The adapted HTTP transaction was finished with my hostx->noteAbContentDone() call

What makes you think that? noteAbContentDone() does not finish the transaction. It only tells the host application that there will be no new adapted body bytes. A lot of things may happen from that moment until the HTTP transaction is actually finished.

> I want squid to call Xaction:stop followed by ~Xaction()

Does Squid call those methods at all? If not, perhaps it is waiting for you? If it does call them, just not as fast as you want, then perhaps it needs the transaction object for something important, like sending message body to the agent or access logging?

Christof Gerber (sitschi) said : #5

I indeed think Squd is waiting for something. Let's assume Squid is waiting for me. What is it waiting for? It has all the body back and it does also deliver it successflly to the user-agent. But it won't call the destructor. I mean it is actually not a problem so far because the adapter basically does what it should from a feature point of view but I think it is somehow weird and ubdclean that in one case squid terminates the transachtion with stop() and destructor and in the other one not.

Alex Rousskov (rousskov) said : #6

> What is it waiting for?

Was your transaction receiving the virgin body from the host application at some point? If yes, did your transaction tell the host application that the adapter is no longer interested in receiving/using the virgin body?

> I think it is somehow weird and unclean

Agreed. I recommend that you figure out what the host application is waiting for (if it is indeed waiting for something). It could be a bug in your adapter or in the host application.

Launchpad Janitor (janitor) said : #7

This question was expired because it remained in the 'Needs information' state without activity for the last 15 days.

Christof Gerber (sitschi) said : #8

Sorry for the late answer. I solved the problem. Squid was waiting for the adapter to call vbStopMaking. Thanks Alex for your support.

Alex Rousskov (rousskov) said : #9

Thank you for the update. Changing the Question status to Solved.