Princy K V
|
Using HA Client Recovery API
|
Princy K V
01/22/2010 4:09 AM
post45743
|
Using HA Client Recovery API
Hi,
I have come across a problem in using resource reclaim mechanism provided by HAM.
Requirement:
I need to reclaim a file descriptor which is become invalid while the program is being run. A program is written using
HAM client library functions (the program is given at the end of this message text).
Problem:
The problem is that, the handler function is not get invoked when the file descriptor become invalid (EBADF). The file
which is being accessed is located on a remote machine and is accessed using samba. To test if the handler function is
invoked upon descriptor become invalid, I did kill the samba client process (to make the descriptor invalid). As
expected, the system call (read/write) would returns EBADF but the handler function is not get invoked!
Also I tried with a Null resource manager. i.e, A program is written using HAM client library function which
continuously execute read and write calls to the file descriptor returned by ha_open( /dev/Null ,…).
To test if the handler function is invoked upon descriptor become invalid, I did kill the Null resource manager (to make
the descriptor invalid). As expected, the system call (read/write) would returns EBADF but the handler function is not
get invoked!
NOTE:
Although the resource reclaim doesn’t work with file descriptors, I was able to reclaim a connection ID using HAM
client library (ha_ConnectAttach () & ha_ReConnectAttach ()).
But I want to reclaim the connection ID returned by name_open() rather than ha_ConnectAttach(). To achieve this, I used
ha_attach() API, i.e,
coid = name_open(SERVER,0);
fd = ha_attach(coid, recover_conn,(void *)&hdl ,0 );
.....................
&
I didn’t find any equivalent API for reclaiming the connection Id returned by name_open , so tried with
ha_ReConnectAttach(..) API. But reclaiming the connection ID using ha_ReConnectAttach(..) from the recovery function
failed , got memory fault. Why is it so?. So instead of calling ha_ReConnectAttach(..) in recovery function, I
explicitly closed the connection using name_close() and reopened the connection using name_open() as following ,
int recover_conn(int oldcd, void *hdl)
{
int newfd = 0;
name_close(oldcd);
delay(100);/*Delay for Server Restart*/
newfd = name_open(SERVER,0);
return(newfd);
}
This successfully reclaimed the connection ID. So Is it there any issue in following above method?
I would also like to know that if there is any HAM client library available for message queues and shared memory. Could
you please provide some sample codes for the same?
Your help would be greatly appreciated.
Please see the attached code
Regards,
Princy
|
|
|