Pthreads in the adapters
Hello Alex,
I am trying to develop an eCAP adapter, which does header enrichment. So in short my adapter will get the client ip address and convert into an encrypted string and add that string as a value to a header (X-Encrypted). And I could do that successfully. But my problem is that - the external process does the conversion of ip address may get blocked (Note: the adapter communicates to it through TCP/IP) and in turn blocks other requests to the squid, which doesn’t requires this conversion. So to solve that issue, I introduced threads and it’s successfully downloading the requested content. But I am unhappy with certain stuffs.
Issues faced:
1. There is an unknown delay of few seconds for every transaction. Is it really valid to introduce threads into the adapters?
2. The Adapter:
Pasting some important part of the code:
void Adapter:
Must(hostx);
SampleLog ("Adapter: Xaction::start. Got a connection\n") ;
if (hostx-
receivingVb = opOn;
} else {
// we are not interested in vb if there is not one
receivingVb = opNever;
}
…..
pthread_t th ;
int ret ;
ret = pthread_create (&th, NULL, (void*(
…
pthread_
}
// The thread function
void* Adapter:
{
<Sanity check comes here>
<The code for the conversion, which MAY get blocked, comes here>
< Header insertion (adaptation) code comes here>
// Final call to inform that the adaptation is completed...
}
Is this code valid? Please look into the same and help me out in solving the above 2 mentioned issues.
Thanks in advance,
Vishnu
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- eCAP Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Alex Rousskov
- Solved:
- Last query:
- Last reply: