Changeset 2985

Show
Ignore:
Timestamp:
11/07/08 04:18:29 (2 months ago)
Author:
kkaempf
Message:

fix issue #271
- call init() function of plugins
- call dlsym for get_endpoints only once

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openwsman/trunk/src/lib/wsman-plugins.c

    r1842 r2985  
    109109    self->p_name = u_strdup(p_name) ; 
    110110    if (NULL != (self->p_handle = dlopen(p_name, RTLD_LAZY))) { 
    111         if ( ! dlsym(self->p_handle, "get_endpoints") 
    112                 &&  dlsym(self->p_handle, "init")) 
     111        self->init = dlsym(self->p_handle, "init"); 
     112        self->get_endpoints = dlsym(self->p_handle, "get_endpoints"); 
     113        if ( ! self->get_endpoints 
     114                && ! self->init) 
    113115        { 
    114116            self->init                          = 0 ; 
    115             PluginError = PLUGIN_ERROR_SYMBOLSNOTFOUND ; 
     117           PluginError = PLUGIN_ERROR_SYMBOLSNOTFOUND ; 
    116118        } 
    117119    } else { 
  • openwsman/trunk/src/lib/wsman-server.c

    r2326 r2985  
    115115        while (node) { 
    116116                WsManPlugin *p = (WsManPlugin *) node->list_data; 
    117                 p->ifc = 
    118                     (WsDispatchInterfaceInfo *) 
    119                     malloc(sizeof(WsDispatchInterfaceInfo)); 
    120  
     117                if (p->init == NULL 
     118                    || p->init(p->p_handle, &(p->data)) == 0 ) { 
     119                    error ("Plugin fails init()"); 
     120                    error("invalid plugin"); 
     121                    goto next_plugin; 
     122                } 
     123               
     124                p->ifc = (WsDispatchInterfaceInfo *) 
     125                          malloc(sizeof(WsDispatchInterfaceInfo)); 
     126                ifcinfo = p->ifc; 
     127                ifcinfo->extraData = p->data; 
    121128                p->set_config = dlsym(p->p_handle, "set_config"); 
    122                 p->get_endpoints = dlsym(p->p_handle, "get_endpoints"); 
    123  
    124129 
    125130                if (listener->config && p->set_config) { 
     
    132137                        p->get_endpoints(p->p_handle, p->ifc); 
    133138 
    134                 ifcinfo = p->ifc; 
    135139                if (p->ifc && wsman_server_verify_plugin(ifcinfo)) { 
    136140                        lnode_t *i = lnode_create(p->ifc); 
     
    138142                } else { 
    139143                        error ("Plugin is not compatible with version of the software or plugin is invalid"); 
    140                         error("invalid plugins"); 
    141                 } 
     144                        error("invalid plugin"); 
     145                } 
     146next_plugin: 
    142147                node = list_next(listener->plugins, node); 
    143148        }