Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - ResMgr: ocb_free() called when device is opened?: (1 Item)
   
ResMgr: ocb_free() called when device is opened?  
Hi,

we are using a thread-pooled resource manager.
We are setting up our Resmgr as follows:

void ocb_free(IOFUNC_OCB_T *ocb) {
  LogDebug("ocb_free() called");
}

iofunc_funcs_t ocb_funcs =
{
    _IOFUNC_NFUNCS,
    (iofunc_ocb_t *(*)(resmgr_context_t *ctp, IOFUNC_ATTR_T *)) ocb_calloc,
    (void (*)(iofunc_ocb_t *))ocb_free
};

iofunc_mount_t extended_mount = { 0, 0, 0, 0, &ocb_funcs };

later:
    /* Initialize device attributes */
    iofunc_attr_init(&ioattr, S_IFCHR | 0666, NULL, NULL);
    ioattr.mount = &extended_mount;

then doing resmgr_attach() and thread_pool_create(), the usual stuff.



Now we noticed the following:
When a client opens the device, in addition to ocb_calloc(), ocb_free() is called. When the client closes the device, 
ocb_free() is called again.

We noticed because we use the ocb to store a handle whose init is triggered by the client some time after the device has
 been opened. ocb_calloc() has been set up to set the handle to "invalid" (NULL), ocb_free() de-initializes the handle 
(but only when it is not NULL, otherwise a warning/notice is logged). Now it seems that this warning is printed every 
time a client opens (!) the device, i.e. ocb_free() is already called at open, which of course means that the handle 
hasn't been set yet by the client.

I don't have any explanation for this.
Any ideas?

Greetings,
 Marc