[Openais] token callback

Steven Dake sdake at mvista.com
Thu Sep 23 18:59:10 PDT 2004


Mark,

Here is a token callback patch.  Let me know if it works for you.  It
includes some test code which you can delete if you want.  The test code
is in gmi_init and shows how to create the callback.  It basically
creates a callback and then on each callback, increases a value and
creates a new callback with the increased value as the data parameter.

If the callback returns -1, it remains queued and will be called on the
next token rotation.  If the callback returns 0, it will be deleted and
should be readded if necessary.

This could be used a few ways. 

1. For each retained event, you can create a callback to be called and
return -1 the first time gmi_mcast returns -1.

2. You can create one callback which maintains state in the data
parameter and returns -1 when gmi_mcast returns -1 during sync.

3. you can create one callback which maintains state in some evt global
data structure as in #2.

We want to avoid if we can allocating memory for the data paramter of
the callback or the callback internal data structure.  So this patch may
need to change this slightly to avoid out of memory error possibilities
in gmi_token_callback_create.  One option is to pass in the data
structure of the callback instance data.  I don't like exporting that in
gmi.h though.  So maybe we can have something like

struct gmi_token_callback_handle {
	char data[32]; (max size on 64 bit arch I'd think)
};

then in gmi_init
assert (sizeof (struct gmi_token_callback_handle) >= sizeof (struct
token_callback_instance); 

This solves the out of memory problem during recovery (which couldn't be
recovered from and might leave the recovery in some funked state). 
Instead, the memory is preallocated by the services (or data structures
during creation) which ensure that the callback can be queued until
perhaps some memory becomes available.

Regards
-steve

  




More information about the Openais mailing list