Changeset 1383:0daaccf3bca7


Ignore:
Timestamp:
10/21/09 23:19:54 (2 years ago)
Author:
niam
Branch:
default
Message:

{issue #67[resolved]} deinitModule function receives cookie obtained from initModule

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/libdodo/exceptionBasic.h

    r1379 r1383  
    152152                char discription[256];                      ///< discription of the library 
    153153                char hook[64];                              ///< name of the function in module that will be as a hook 
     154                char cookie[32];                            ///< cookie that would be passed to deinitModule 
    154155                bool modules[MODULE_ENUMSIZE];              ///< for what modules handler should be set, @see exception::moduleEnum 
    155156            }; 
     
    166167             * @typedef deinitModule 
    167168             * @brief defines type of deinit function for library 
     169             * @param cookie defines cookie data returned from initModule 
    168170             * @note name in the library must be deinitExceptionBasicModule 
    169171             */ 
    170             typedef void (*deinitModule)(); 
     172            typedef void (*deinitModule)(char cookie[32]); 
    171173#endif 
    172174 
     
    292294#ifdef DL_EXT 
    293295            static void *handles[MODULE_ENUMSIZE];          ///< handles to the libraries 
     296            static char cookies[MODULE_ENUMSIZE][32];          ///< handles to the libraries 
    294297 
    295298            static bool handlesOpened[MODULE_ENUMSIZE];     ///< map of the opened libraries 
  • trunk/include/libdodo/pcExecutionProcess.h

    r1379 r1383  
    111111                    char  discription[256]; ///< discription of module 
    112112                    char  hook[64];         ///< name of function in module that will be a hook 
     113                    char  cookie[32];        ///< cookie that would be passed to deinitModule 
    113114                    short action;           ///< action on object destruction, @see onDestructionEnum 
    114115                }; 
     
    126127                 * @brief defines type of deinit function for library 
    127128                 * @note name in the library must be deinitPcExecutionProcessModule 
     129                 * @param cookie defines cookie data returned from initModule 
    128130                 */ 
    129                 typedef void (*deinitModule)(); 
     131                typedef void (*deinitModule)(char cookie[32]); 
    130132 
    131133                /** 
  • trunk/include/libdodo/pcExecutionThread.h

    r1379 r1383  
    114114                    char  discription[256]; ///< discription of module 
    115115                    char  hook[64];         ///< name of function in module that will be a hook 
     116                    char  cookie[32];       ///< cookie that would be passed to deinitModule 
    116117                    bool  detached;         ///< true if thread is detached 
    117118                    int   stackSize;        ///< size of stack for thread in bytes 
     
    130131                 * @typedef deinitModule 
    131132                 * @brief defines type of deinit function for library 
     133                 * @param cookie defines cookie data returned from initModule 
    132134                 * @note name in the library must be deinitPcExecutionThreadModule 
    133135                 */ 
    134                 typedef void (*deinitModule)(); 
     136                typedef void (*deinitModule)(char cookie[32]); 
    135137 
    136138                /** 
  • trunk/include/libdodo/toolsOs.h

    r1379 r1383  
    9898                char discription[256];      ///< discription of the library 
    9999                char hook[64];              ///< name of function in module that will be as a hook 
     100                char cookie[32];            ///< cookie that would be passed to deinitModule 
    100101                long signal;                ///< signal to set handler 
    101102                int  blockSignals;          ///< signals to block during signal handling; -1 to ignore 
     
    113114             * @typedef deinitSignalModule 
    114115             * @brief defines type of deinit function for library 
     116             * @param cookie defines cookie data returned from initModule 
    115117             * @note name in the library must be deinitToolOsSignalModule 
    116118             */ 
    117             typedef void (*deinitSignalModule)(); 
     119            typedef void (*deinitSignalModule)(char cookie[32]); 
    118120#endif 
    119121 
     
    517519            static void *handlesSig[SIGNAL_ENUMSIZE];           ///< handles to modules 
    518520            static bool handlesOpenedSig[SIGNAL_ENUMSIZE];      ///< map of opened modules 
     521            static char handlesCookiesSig[SIGNAL_ENUMSIZE][32]; ///< module cookies 
    519522#endif 
    520523 
  • trunk/include/libdodo/xexec.h

    r1382 r1383  
    7272            char  discription[256]; ///< discription of the library 
    7373            char  hook[64];         ///< name of function in the library that will be used as hook 
     74            char  cookie[32];       ///< cookie that would be passed to deinitModule 
    7475            short type;             ///< type of hook, @see xexec::actionEnum, could me grouped with OR 
    7576        }; 
     
    8687         * @typedef deinitModule 
    8788         * @brief defines type of deinit function for library 
     89         * @param cookie defines cookie data returned from initModule 
    8890         * @note name in the library must be deinitXexecModule 
    8991         */ 
    90         typedef void (*deinitModule)(); 
     92        typedef void (*deinitModule)(char cookie[32]); 
    9193#endif 
    9294 
     
    246248#ifdef DL_EXT 
    247249            void *handle;                               ///< handle to library 
     250            char cookie[32];                            ///< cookie that would be passed to deinitModule 
    248251#endif 
    249252        }; 
  • trunk/src/exceptionBasic.cc

    r1382 r1383  
    3232#ifdef DL_EXT 
    3333#include <dlfcn.h> 
     34#include <string.h> 
    3435#endif 
    3536#ifdef __GNUC__ 
     
    303304    NULL, 
    304305    NULL 
     306}; 
     307 
     308//------------------------------------------------------------------- 
     309 
     310char basic::cookies[][32] = { 
     311    {'\0', }, 
     312    {'\0', }, 
     313    {'\0', }, 
     314    {'\0', }, 
     315    {'\0', }, 
     316    {'\0', }, 
     317    {'\0', }, 
     318    {'\0', }, 
     319    {'\0', }, 
     320    {'\0', }, 
     321    {'\0', }, 
     322    {'\0', }, 
     323    {'\0', }, 
     324    {'\0', }, 
     325    {'\0', }, 
     326    {'\0', }, 
     327    {'\0', }, 
     328    {'\0', }, 
     329    {'\0', }, 
     330    {'\0', }, 
     331    {'\0', }, 
     332    {'\0', }, 
     333    {'\0', }, 
     334    {'\0', }, 
     335    {'\0', }, 
     336    {'\0', }, 
     337    {'\0', }, 
     338    {'\0', }, 
     339    {'\0', }, 
     340    {'\0', }, 
     341    {'\0', }, 
     342    {'\0', }, 
     343    {'\0', }, 
     344    {'\0', }, 
     345    {'\0', }, 
     346    {'\0', }, 
     347    {'\0', }, 
     348    {'\0', }, 
     349    {'\0', }, 
     350    {'\0', }, 
     351    {'\0', }, 
     352    {'\0', }, 
     353    {'\0', }, 
     354    {'\0', }, 
     355    {'\0', }, 
     356    {'\0', }, 
     357    {'\0', }, 
     358    {'\0', }, 
     359    {'\0', } 
    305360}; 
    306361#endif 
     
    814869            deinit = (deinitModule)dlsym(handles[i], "deinitExceptionBasicModule"); 
    815870            if (deinit != NULL) 
    816                 deinit(); 
     871                deinit(cookies[i]); 
    817872 
    818873            handlesOpened[i] = false; 
     
    881936        deinit = (deinitModule)dlsym(handles[module], "deinitExceptionBasicModule"); 
    882937        if (deinit != NULL) 
    883             deinit(); 
     938            deinit(cookies[module]); 
    884939 
    885940#ifndef DL_FAST 
     
    916971            deinit = (deinitModule)dlsym(handles[i], "deinitExceptionBasicModule"); 
    917972            if (deinit != NULL) 
    918                 deinit(); 
     973                deinit(cookies[i]); 
    919974 
    920975#ifndef DL_FAST 
     
    9461001        deinit = (deinitModule)dlsym(handles[module], "deinitExceptionBasicModule"); 
    9471002        if (deinit != NULL) 
    948             deinit(); 
     1003            deinit(cookies[module]); 
    9491004 
    9501005#ifndef DL_FAST 
     
    9781033            deinit = (deinitModule)dlsym(handles[i], "deinitExceptionBasicModule"); 
    9791034            if (deinit != NULL) 
    980                 deinit(); 
     1035                deinit(cookies[i]); 
    9811036 
    9821037#ifndef DL_FAST 
     
    10301085            deinit = (deinitModule)dlsym(handles[i], "deinitExceptionBasicModule"); 
    10311086            if (deinit != NULL) 
    1032                 deinit(); 
     1087                deinit(cookies[i]); 
    10331088 
    10341089#ifndef DL_FAST 
     
    10481103 
    10491104        handlesOpened[i] = true; 
     1105        memcpy(cookies[i], mod.cookie, 32); 
    10501106 
    10511107        handlers[i] = in; 
     
    10791135        deinitModule deinit = (deinitModule)dlsym(handle, "deinitExceptionBasicModule"); 
    10801136        if (deinit != NULL) 
    1081                 deinit(); 
     1137                deinit(mod.cookie); 
    10821138 
    10831139#ifndef DL_FAST 
  • trunk/src/pcExecutionProcess.cc

    r1379 r1383  
    5555                                joined(false), 
    5656                                status(0) 
     57#ifdef DL_EXT 
     58                              , 
     59                                handle(NULL) 
     60#endif 
    5761                { 
     62#ifdef DL_EXT 
     63                    memset(cookie, 0x0, 32); 
     64#endif 
    5865                } 
    5966 
     
    6774#ifdef DL_EXT 
    6875                void            *handle;            ///< handle to library 
     76                char            cookie[32];         ///< cookie that would be passed to deinitModule 
    6977#endif 
    7078            }; 
     
    135143        handle->action = m.action; 
    136144        handle->func = f; 
     145        memcpy(handle->cookie, m.cookie, 32); 
    137146    } catch (...) { 
    138147        if (handle) { 
     
    179188            deinit = (deinitModule)dlsym(handle->handle, "deinitPcExecutionProcessModule"); 
    180189            if (deinit != NULL) 
    181                 deinit(); 
     190                deinit(handle->cookie); 
    182191 
    183192#ifndef DL_FAST 
     
    292301    deinitModule deinit = (deinitModule)dlsym(handle, "deinitPcExecutionProcessModule"); 
    293302    if (deinit != NULL) 
    294         deinit(); 
     303        deinit(mod.cookie); 
    295304 
    296305#ifndef DL_FAST 
  • trunk/src/pcExecutionThread.cc

    r1379 r1383  
    5555                    thread(0), 
    5656#endif 
    57                                executed(false), 
    58                                joined(false), 
    59                                status(0) 
     57                    executed(false), 
     58                    joined(false), 
     59                    status(0) 
     60#ifdef DL_EXT 
     61                    , 
     62                    handle(NULL) 
     63#endif 
    6064                { 
     65#ifdef DL_EXT 
     66                    memset(cookie, 0x0, 32); 
     67#endif 
    6168                } 
    6269 
     
    8188#ifdef DL_EXT 
    8289                void           *handle;             ///< handle to library 
     90                char            cookie[32];         ///< cookie that would be passed to deinitModule 
    8391#endif 
    8492            }; 
     
    204212        handle->action = m.action; 
    205213        handle->func = f; 
     214        memcpy(handle->cookie, m.cookie, 32); 
    206215    } catch (...) { 
    207216        if (handle) { 
     
    265274            deinit = (deinitModule)dlsym(handle->handle, "deinitPcExecutionThreadModule"); 
    266275            if (deinit != NULL) 
    267                 deinit(); 
     276                deinit(handle->cookie); 
    268277 
    269278#ifndef DL_FAST 
     
    386395    deinitModule deinit = (deinitModule)dlsym(handle, "deinitPcExecutionThreadModule"); 
    387396    if (deinit != NULL) 
    388         deinit(); 
     397        deinit(mod.cookie); 
    389398 
    390399#ifndef DL_FAST 
  • trunk/src/toolsOs.cc

    r1379 r1383  
    104104    false 
    105105}; 
     106//------------------------------------------------------------------- 
     107 
     108char os::handlesCookiesSig[][32] = { 
     109    {'\0', }, 
     110    {'\0', }, 
     111    {'\0', }, 
     112    {'\0', }, 
     113    {'\0', }, 
     114    {'\0', }, 
     115    {'\0', }, 
     116    {'\0', }, 
     117    {'\0', }, 
     118    {'\0', }, 
     119    {'\0', }, 
     120    {'\0', }, 
     121    {'\0', }, 
     122    {'\0', }, 
     123    {'\0', }, 
     124    {'\0', }, 
     125    {'\0', }, 
     126    {'\0', }, 
     127    {'\0', } 
     128}; 
    106129#endif 
    107130 
     
    744767        deinit = (deinitSignalModule)dlsym(handlesSig[handleSignal], "deinitToolsOsSignalModule"); 
    745768        if (deinit != NULL) 
    746             deinit(); 
     769            deinit(handlesCookiesSig[handleSignal]); 
    747770 
    748771#ifndef DL_FAST 
     
    784807        deinit = (deinitSignalModule)dlsym(handlesSig[handleSignal], "deinitToolsOsSignalModule"); 
    785808        if (deinit != NULL) 
    786             deinit(); 
     809            deinit(handlesCookiesSig[handleSignal]); 
    787810 
    788811#ifndef DL_FAST 
     
    840863        deinit = (deinitSignalModule)dlsym(handlesSig[handleSignal], "deinitToolsOsSignalModule"); 
    841864        if (deinit != NULL) 
    842             deinit(); 
     865            deinit(handlesCookiesSig[handleSignal]); 
    843866 
    844867#ifndef DL_FAST 
     
    912935        deinit = (deinitSignalModule)dlsym(handlesSig[handleSignal], "deinitToolsOsSignalModule"); 
    913936        if (deinit != NULL) 
    914             deinit(); 
     937            deinit(handlesCookiesSig[handleSignal]); 
    915938 
    916939#ifndef DL_FAST 
     
    951974    __signal_module__ mod = init(toInit); 
    952975 
     976    deinitSignalModule deinit = (deinitSignalModule)dlsym(handle, "deinitToolsOsSignalModule"); 
     977    if (init != NULL) 
     978        deinit(mod.cookie); 
     979 
     980 
    953981#ifndef DL_FAST 
    954982    if (dlclose(handle) != 0) 
    955983        throw exception::basic(exception::MODULE_TOOLSOS, OSEX_MODULE, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
    956  
    957984#endif 
    958985 
     
    9881015        deinit = (deinitSignalModule)dlsym(handlesSig[handleSignal], "deinitToolsOsSignalModule"); 
    9891016        if (deinit != NULL) 
    990             deinit(); 
     1017            deinit(handlesCookiesSig[handleSignal]); 
    9911018 
    9921019#ifndef DL_FAST 
  • trunk/src/xexec.cc

    r1382 r1383  
    3232#ifdef DL_EXT 
    3333#include <dlfcn.h> 
     34#include <string.h> 
    3435#endif 
    3536 
     
    8384        deinit = (deinitModule)dlsym(i->handle, "deinitXexecModule"); 
    8485        if (deinit != NULL) 
    85             deinit(); 
     86            deinit(i->cookie); 
    8687 
    8788#ifndef DL_FAST 
     
    9899        deinit = (deinitModule)dlsym(i->handle, "deinitXexecModule"); 
    99100        if (deinit != NULL) 
    100             deinit(); 
     101            deinit(i->cookie); 
    101102 
    102103#ifndef DL_FAST 
     
    147148        deinit = (deinitModule)dlsym(current->handle, "deinitXexecModule"); 
    148149        if (deinit != NULL) 
    149             deinit(); 
     150            deinit(current->cookie); 
    150151 
    151152#ifndef DL_FAST 
     
    231232    __module__ mod = init(initData); 
    232233 
     234    deinitModule deinit = (deinitModule)dlsym(handle, "deinitXexecModule"); 
     235    if (deinit != NULL) 
     236        deinit(mod.cookie); 
     237 
    233238#ifndef DL_FAST 
    234239    if (dlclose(handle) != 0) 
     
    265270        throw exception::basic(exception::MODULE_XEXEC, XEXECEX_ADDXEXEC, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
    266271 
    267     __module__ info = init(initData); 
    268  
    269     hook in = (hook)dlsym(e.handle, info.hook); 
     272    __module__ mod = init(initData); 
     273 
     274    hook in = (hook)dlsym(e.handle, mod.hook); 
    270275    if (in == NULL) 
    271276        throw exception::basic(exception::MODULE_XEXEC, XEXECEX_ADDXEXEC, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
    272277 
    273278    e.func = in; 
    274  
    275     if (info.type & ACTION_PREEXEC) { 
     279    memcpy(e.cookie, mod.cookie, 32); 
     280 
     281    if (mod.type & ACTION_PREEXEC) { 
    276282        e.id = ++execs; 
    277283        preExec.push_back(e); 
     
    279285    } 
    280286 
    281     if (info.type & ACTION_POSTEXEC) { 
     287    if (mod.type & ACTION_POSTEXEC) { 
    282288        e.id = ++execs; 
    283289        postExec.push_back(e); 
    284290        postExecId = e.id; 
    285291    } 
    286  
    287     deinitModule deinit = (deinitModule)dlsym(e.handle, "deinitXexecModule"); 
    288     if (deinit == NULL) 
    289         throw exception::basic(exception::MODULE_XEXEC, XEXECEX_ADDXEXEC, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 
    290  
    291     deinit(); 
    292292} 
    293293 
  • trunk/tests/toolsmisc_test/module.cc

    r1379 r1383  
    3131        "test module", 
    3232        "handler", 
     33        "cookie", 
    3334        { false, } 
    3435    }; 
     
    4041 
    4142void 
    42 deinitExceptionBasicModule() 
     43deinitExceptionBasicModule(char cookie[32]) 
    4344{ 
    44     std::cout << "deactivation."; 
     45    std::cout << "deactivation(cookie = " << cookie << ")\n"; 
    4546} 
    4647}; 
  • trunk/tests/xexec_test/module.cc

    r1379 r1383  
    4545initXexecModule(void *data) 
    4646{ 
    47     xexec::__module__ module; 
     47    xexec::__module__ module = { 
     48        {'\0', }, 
     49        {'\0', }, 
     50        {'\0', }, 
     51        {'\0', }, 
     52        0 
     53    }; 
    4854 
    4955    std::cout << "activation\n"; 
     
    5157    strcpy(module.name, "test"); 
    5258    strcpy(module.discription, "test module"); 
     59    strcpy(module.cookie, "test cookie"); 
    5360    module.type = xexec::ACTION_PREEXEC; 
    5461 
     
    6269 
    6370void 
    64 deinitXexecModule() 
     71deinitXexecModule(char cookie[32]) 
    6572{ 
    66     std::cout << "deactivation\n"; 
     73    std::cout << "deactivation(cookie = " << cookie << ")\n"; 
    6774} 
    6875}; 
Note: See TracChangeset for help on using the changeset viewer.