Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - HAM - ham_action_notify_pulse: (6 Items)
   
HAM - ham_action_notify_pulse  
I have a process that attaches itself to the HAM using ham_attach_self (name, 0, 0,0,0 );

When this process dies I would like a notification to be send to a server process that is capable of  handling pulses. I
 can retrieve the server information like pid and chid using the ConnectServerInfo call. like this

  int coid = name_open (server, 0);

  if ( coid == -1 )
      return;

   /* Retrieve server information - we need the channel id */

  if ( ConnectServerInfo(0, coid, &info) < 0 )
     return;

    name_close(coid);


This work. What I do next is register the condition and action like this:

    hc[0] = ham_condition(he, CONDDEATH, "death-condition", 0);

    if ( hc[0] )
    {
        ha[0] = 0;
      
         ha[0] = ham_action_notify_pulse(hc[0], "death-action-pulse",     
                                                               ND_LOCAL_NODE, info.pid, info.chid, 
                                                                HA_PULSE_DEATH, 0, 
                                                                HREARMAFTERRESTART);

      return(0);
   }

running the process will show all the information under the /proc/ham directory but killing it will not show a 
notification within the specified server. Am i doing something wrong here?

Regards
Wim

Re: HAM - ham_action_notify_pulse  
can you run the ham with additional verbosity (ham -vvvvv) and then look
at the ham logs to see if the action is being triggerred. You should be
able to see the process die, and also the ham action being triggerred.
If the action is being triggered you should verify that the trigger of
the pulse contains the appropriate values as you would expect (pid, chid
etc)

thanks

shiv
Thu Mar  4 10:11:49 EST 2010

 --> According to Wim Hellenthal <--
	I have a process that attaches itself to the HAM using ham_attach_self (name, 0, 0,0,0 );
	
	When this process dies I would like a notification to be send to a server process that is capable of  handling pulses. 
I can retrieve the server information like pid and chid using the ConnectServerInfo call. like this
	
	  int coid = name_open (server, 0);
	
	  if ( coid == -1 )
	      return;
	
	   /* Retrieve server information - we need the channel id */
	
	  if ( ConnectServerInfo(0, coid, &info) < 0 )
	     return;
	
	    name_close(coid);
	
	
	This work. What I do next is register the condition and action like this:
	
	    hc[0] = ham_condition(he, CONDDEATH, "death-condition", 0);
	
	    if ( hc[0] )
	    {
	        ha[0] = 0;
	      
	         ha[0] = ham_action_notify_pulse(hc[0], "death-action-pulse",     
	                                                               ND_LOCAL_NODE, info.pid, info.chid, 
	                                                                HA_PULSE_DEATH, 0, 
	                                                                HREARMAFTERRESTART);
	
	      return(0);
	   }
	
	running the process will show all the information under the /proc/ham directory but killing it will not show a 
notification within the specified server. Am i doing something wrong here?
	
	Regards
	Wim
	
	
	
	
	
	_______________________________________________
	
	OSTech
	http://community.qnx.com/sf/go/post48767

-- 
****
Shiv Nagarajan,
Kernel Developer, QNX Software Systems,
Ottawa, Canada
****
Re: HAM - ham_action_notify_pulse  
Hi Shiv,

I sometimes really doubt  myself. Thiking about the mail just sent I took a look at the code again and realized that I 
clean up in the destructor of the HAMClient class:

       ham_detach (he, 0);
       ham_entity_handle_free (he);

How simple can it be sometimes. The question about temporary disabling heartbeat handling still stands though -:)

Regards,

Wim
Re: HAM - ham_action_notify_pulse  
for the disabling part, check out the documentation of 
ham_action_control, ham_condition_control and ham_entity_control

they allow enabling and disabling, also have an option to recurse into
the sub components also

shiv
Thu Mar  4 16:22:37 EST 2010

 --> According to Wim Hellenthal <--
	Hi Shiv,
	
	I sometimes really doubt  myself. Thiking about the mail just sent I took a look at the code again and realized that I 
clean up in the destructor of the HAMClient class:
	
	       ham_detach (he, 0);
	       ham_entity_handle_free (he);
	
	How simple can it be sometimes. The question about temporary disabling heartbeat handling still stands though -:)
	
	Regards,
	
	Wim
	
	
	
	_______________________________________________
	
	OSTech
	http://community.qnx.com/sf/go/post48838

-- 
****
Shiv Nagarajan,
Kernel Developer, QNX Software Systems,
Ottawa, Canada
****
Re: HAM - ham_action_notify_pulse  
It all works now

Thanks !!!!
Wim
Re: HAM - ham_action_notify_pulse  
Hi Shiv

Thanks for the suggestion. I'm a bit confused I have a small test program making use of the code already posted: The 
code is in the file attached. When I stop the program by entering the return key no pulse is created and send the server
. When I kill the program entering Ctrl-C then a pulse is send. Why is there a difference in behaviour?

Another question is the following:
Is it possible to add heartbeat conditions and actions when a program is already attached to the HAM by the 
ham_attach_self (name, 0, 0,0,0 ); routine. Or use the ham_attach_self routine with the heartbeat parameters but 
temporary disable conditions and action related to heartbeat handling?

Thanks for the help!

Regards Wim
Attachment: Text HAM.txt 1.26 KB