Re: future proofing GConf for backend vtable changes



Hi Mark,

Two comments. One for the concept, one on the patch.

Mark McLoughlin wrote:
	Since the backend API is completely private to GConf right now, we
don't really need to worry about this but I thought it might be nice to
add some future proofing before extending the vtable any further.

	The attached patch takes the following approach:

  + The backends are compiled with the vtable's size as the first member
    of the structure.

+ When initializing a backend, we create a new vtable instance according to our knowledge of its size and fill it with whatever the
    backend provided us.

  + This means that if the backend was compiled with an older version of
    the vtable, the new members are guaranteed to be initialized to NULL
and if it was compiled with a new version of the vtable than the library, then we just ignore any new methods.


Even with this patch, extending the vtable needs to be coordinated very carefully. Things get dangerous, if a backend supporting one extension meets a gconfd supporting another. Probably their extension function slots will collide and with your patch the backend will merrily call functions that don't do what the backend expects. The size check may convey a false sense of security against such incompatibilities.

It might be somewhat safer to add a 'magic' token field instead, to identify the exact vtable version/semantics. In case of a mismatch, gconf would fall back onto the lowest universally supported denominator (i.e. the present backend vtable). But this approach also has its set of problems.

AFAICT Cyrille's approach avoids this kind of problem. OTOH if we really get an increasing number of extensions (this is the case you're trying to prepare for, isn't it?), it becomes unwieldy.


	There's some other stuff in the patch too - this part is the only
really relevant bit:

  retval = g_new0(GConfBackendVTable, 1);

  retval = memcpy(retval, vtable, MIN(vtable->vtable_size, sizeof(GConfBackendVTable)));


To maintain the proper state, you'd need to add

+ retval->vtable_size = sizeof *retval;

after the memcpy.

Ciao, Joerg

--
Joerg Barfurth Sun Microsystems - Star Office - Hamburg
>>>>>>>>>>>>>>>>>> using std::disclaimer <<<<<<<<<<<<<<<<<<<<<<<
Software Engineer                         joerg barfurth sun com
OpenOffice.org Configuration          http://util.openoffice.org






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]