author | Tero Marttila <terom@fixme.fi> |
Wed, 27 May 2009 23:57:48 +0300 | |
branch | new-lib-errors |
changeset 217 | 7728d6ec3abf |
parent 134 | src/module.h@978041c1c04d |
child 218 | 5229a5d098b2 |
permissions | -rw-r--r-- |
54 | 1 |
#ifndef MODULE_H |
2 |
#define MODULE_H |
|
3 |
||
4 |
/** |
|
5 |
* @file |
|
6 |
* |
|
55
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
7 |
* Dynamically loadable modules for use with nexus. |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
8 |
* |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
9 |
* The modules are loaded using dlopen(), and hence should be standard dynamic libraries. Modules are then "loaded" by |
87 | 10 |
* resolving a `struct module_funcs` symbol called "<modname>_funcs", and then using the init func to construct a |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
11 |
* "context", which is then further manipulated by various other module functions. |
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
12 |
* |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
13 |
* Modules are also reference counted, mainly for implementing module_unload(). When a module is first loaded, it has |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
14 |
* a reference count of one - the entry in struct modules. Later, modules can be referenced using module_get(), and |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
15 |
* returned with module_put() once done. The module should never be destroyed during its lifetime, until a |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
16 |
* module_unload() occurs. At this point, the module is removed from the modules_list, and the one reference is |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
17 |
* 'passed on' to the module itself. Once it has finished unloading, it can call module_unloaded() on the reference it was |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
18 |
* given by module_desc::unload, which may then result in a deferred module_destroy(). |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
19 |
* |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
20 |
* Module destroying itself is an interesting issue, since modules effectively need to be able to destroy themselves |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
21 |
* (as they must be able to perform cleanup, and then notify completion from inside an event loop callback). This means |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
22 |
* that they cannot directly execute a module_destroy() on themselves - if we call dlclose() with dlopen-mapped code |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
23 |
* pages on the stack, a segfault ensues. Hence, they must call module_unloaded() on themselves, which then executes a |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
24 |
* deferred module_destroy() if there are no references left. Otherwise, the module should be safe from external code, |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
25 |
* as module_put() should never cause a module to be destroyed before module_unloaded() is executed, due to the primary |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
26 |
* reference. |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
27 |
* |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
28 |
* Ugh, it's compliated, I need to write a clearer explenation once it's implemented :) |
54 | 29 |
*/ |
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
30 |
|
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
31 |
struct module; |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
32 |
|
54 | 33 |
#include "nexus.h" |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
34 |
#include "config.h" |
217 | 35 |
#include <lib/error.h> |
54 | 36 |
|
37 |
#include <sys/queue.h> |
|
105
b6b183fbf373
implement a separate nexus_lua module
Tero Marttila <terom@fixme.fi>
parents:
103
diff
changeset
|
38 |
#include <stdbool.h> |
54 | 39 |
|
217 | 40 |
enum module_error_code { |
41 |
ERR_MODULE_NONE, |
|
42 |
ERR_MODULE_NAME, ///< invalid module_info.name |
|
43 |
ERR_MODULE_DUP, ///< module already opened |
|
44 |
ERR_MODULE_PATH, ///< resolving the path failed |
|
45 |
ERR_MODULE_OPEN, ///< dlopen() failed |
|
46 |
ERR_MODULE_SYM, ///< invalid symbol |
|
47 |
ERR_MODULE_INIT_FUNC, ///< invalid module_init_func_t |
|
48 |
ERR_MODULE_CONF, ///< value error in configuration data |
|
49 |
ERR_MODULE_STATE, ///< module in wrong state for operation |
|
50 |
}; |
|
51 |
||
52 |
const struct error_list module_errors; |
|
53 |
||
54 | 54 |
/** |
55 |
* Information required to load/identify a module. |
|
56 |
*/ |
|
57 |
struct module_info { |
|
58 |
/** Human-readable name */ |
|
59 |
const char *name; |
|
60 |
||
61 |
/** Filesystem path to the .so */ |
|
62 |
const char *path; |
|
63 |
}; |
|
64 |
||
65 |
/** |
|
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
66 |
* A table of (function/other) pointers defining a module's behaviour. This is dynamically resolved from the module DSO |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
67 |
* using the "<mod_name>_module" symbol. |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
68 |
*/ |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
69 |
struct module_desc { |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
70 |
/** |
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
71 |
* Initialize the module, returning an opaque context pointer that is stored in the module state, and supplied for |
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
72 |
* subsequent calls. The supplied nexus arg can be used to access the global state. |
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
73 |
* |
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
74 |
* Implementing this is mandatory. |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
75 |
* |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
76 |
* @param nexus a pointer to the nexus struct containing the global state |
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
77 |
* @param ctx_ptr the context pointer should be returned via this |
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
78 |
* @param err returned error info |
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
79 |
*/ |
217 | 80 |
err_t (*init) (struct nexus *nexus, void **ctx_ptr, error_t *err); |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
81 |
|
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
82 |
/** |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
83 |
* A module may define a set of available configuration parameters for use by module_conf, by setting this to an |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
84 |
* array of config_option's. |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
85 |
* |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
86 |
* The handler functions will recieve the module's context pointer as their ctx argument. |
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
87 |
* |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
88 |
* Implementing this is optional, but recommended. |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
89 |
*/ |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
90 |
const struct config_option *config_options; |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
91 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
92 |
/** |
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
93 |
* Unload the module, removing all handlers/callbacks added to the nexus' irc_client. This does not have to act |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
94 |
* immediately, and will still have access to all irc_* resources it had earlier, and may perform I/O to unload |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
95 |
* cleanly. But the unloading should complete reasonably quickly, after which all event handlers added by the |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
96 |
* module to the nexus' ev_base should have been removed, and resources released. |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
97 |
* |
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
98 |
* The module given as an argument is the module itself - which has been removed from the modules_list - the |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
99 |
* primary reference is passed on to the module. Once the module has finished unloading, it may call module_put(), |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
100 |
* which may then call module_destroy(), if no other references were left. |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
101 |
* |
111
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
102 |
* If the unload operation fails (returns an error code), then the module is considered as unloaded (as if |
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
103 |
* module_unloaded() was called - don't call this if you return an error). |
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
104 |
* |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
111
diff
changeset
|
105 |
* Implementing this is optional, if all of this can be implemented in destroy. |
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
106 |
* |
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
107 |
* @param ctx the module's context pointer as returned by init |
111
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
108 |
* @param module the hanging module reference, that must be passed to module_unloaded() |
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
109 |
* @return error code |
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
110 |
*/ |
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
111 |
err_t (*unload) (void *ctx, struct module *module); |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
112 |
|
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
113 |
/** |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
114 |
* Destroy the module now. No later chances, the module's code will be unloaded directly after this, which means |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
115 |
* that attempts to execute the module's code (even on the stack...) after this will segfault. |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
116 |
* |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
117 |
* The module code /should/ garuntee that this is never called from *inside* the module code - calls to |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
118 |
* module_destroy() will be deferred via the event loop if needed. |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
119 |
* |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
120 |
* Implementing this is optional. |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
121 |
*/ |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
122 |
void (*destroy) (void *ctx); |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
123 |
}; |
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
124 |
|
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
125 |
/** |
54 | 126 |
* A loaded module. |
127 |
*/ |
|
128 |
struct module { |
|
129 |
/** The identifying info for the module */ |
|
130 |
struct module_info info; |
|
131 |
||
108
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
132 |
/** Possible dynamically allocated path */ |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
133 |
char *path_buf; |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
134 |
|
55
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
135 |
/** The dlopen handle */ |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
136 |
void *handle; |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
137 |
|
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
138 |
/** The module entry point */ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
139 |
struct module_desc *desc; |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
140 |
|
54 | 141 |
/** The module context object */ |
142 |
void *ctx; |
|
143 |
||
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
144 |
/** Reference back to modules struct used to load this module */ |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
145 |
struct modules *modules; |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
146 |
|
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
147 |
/** Reference count for destroy() */ |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
148 |
size_t refcount; |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
149 |
|
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
150 |
/** Is the module currently being unloaded? */ |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
151 |
bool unloading; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
152 |
|
54 | 153 |
/** Our entry in the list of modules */ |
55
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
154 |
TAILQ_ENTRY(module) modules_list; |
54 | 155 |
}; |
156 |
||
157 |
/** |
|
158 |
* A set of loaded modules, and functionality to load more |
|
159 |
*/ |
|
160 |
struct modules { |
|
161 |
/** The nexus in use */ |
|
162 |
struct nexus *nexus; |
|
163 |
||
108
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
164 |
/** Module search path */ |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
165 |
const char *path; |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
166 |
|
54 | 167 |
/** List of loaded modules */ |
55
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
168 |
TAILQ_HEAD(module_ctx_modules, module) list; |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
169 |
}; |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
170 |
|
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
171 |
|
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
172 |
/** |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
173 |
* Maximum length of a module name |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
174 |
*/ |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
175 |
#define MODULE_NAME_MAX 24 |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
176 |
|
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
177 |
/** |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
178 |
* Maximum length of module symbol suffix |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
179 |
*/ |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
180 |
#define MODULE_SUFFIX_MAX 16 |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
181 |
|
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
182 |
/** |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
183 |
* Maximum length of symbol name name, including terminating NUL |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
184 |
*/ |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
185 |
#define MODULE_SYMBOL_MAX (MODULE_NAME_MAX + 1 + MODULE_SUFFIX_MAX + 1) |
54 | 186 |
|
187 |
/** |
|
188 |
* Create a new modules state |
|
189 |
*/ |
|
190 |
err_t modules_create (struct modules **modules_ptr, struct nexus *nexus); |
|
191 |
||
192 |
/** |
|
108
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
193 |
* Set a search path for finding modules by name. The given string won't be copied. |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
194 |
* |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
195 |
* A module called "<name>" will be searched for at "<path>/mod_<name>.so" |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
196 |
* |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
197 |
* If path is NULL, this doesn't change anything. This returns the old path, which may be NULL. |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
198 |
* |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
199 |
* @param modules the modules state |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
200 |
* @param path the new search path, or NULL to just get the old one |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
201 |
* @return the old search path |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
202 |
*/ |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
203 |
const char* modules_path (struct modules *modules, const char *path); |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
204 |
|
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
205 |
/** |
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
206 |
* Get a reference to the module, which must be returned using module_put |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
207 |
* |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
208 |
* @param modules the modules state |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
209 |
* @param name the module name to get |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
210 |
* @return the module struct, or NULL if not found |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
211 |
*/ |
134
978041c1c04d
update TODO, partially update error.c, rename module_get to modules_get, update config.lua
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
212 |
struct module* modules_get (struct modules *modules, const char *name); |
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
213 |
|
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
214 |
/** |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
215 |
* Unload all modules, this just calls module_unload for each module, logging errors as warnings. |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
216 |
*/ |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
217 |
err_t modules_unload (struct modules *modules); |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
218 |
|
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
219 |
/** |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
220 |
* Destroy all modules immediately. |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
221 |
*/ |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
222 |
void modules_destroy (struct modules *modules); |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
223 |
|
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
224 |
|
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
225 |
|
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
226 |
/*******************************************/ |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
227 |
|
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
228 |
|
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
229 |
/** |
103
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
230 |
* Return a module's name |
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
231 |
*/ |
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
232 |
const char* module_name (struct module *module); |
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
233 |
|
454aea1e4f11
implement nexus_shutdown, lua_modules/lua_module, and lua_nexus
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
234 |
/** |
108
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
235 |
* Load a new module, as named by info. |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
236 |
* |
50ff7ac8a725
implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents:
105
diff
changeset
|
237 |
* If info->path is not given, the module will be searched for using the path set by modules_path(). |
65
d7508879ad01
add --module support, and tweak irc_net docs
Tero Marttila <terom@fixme.fi>
parents:
57
diff
changeset
|
238 |
* |
111
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
239 |
* If module_ptr is given, a reference (that must be module_put'd) is returned, that must be returned using |
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
240 |
* module_put(). |
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
241 |
* |
65
d7508879ad01
add --module support, and tweak irc_net docs
Tero Marttila <terom@fixme.fi>
parents:
57
diff
changeset
|
242 |
* @param modules the module-loading context |
111
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
243 |
* @param module_ptr retuturned new module struct, as a new reference, if not NULL. |
65
d7508879ad01
add --module support, and tweak irc_net docs
Tero Marttila <terom@fixme.fi>
parents:
57
diff
changeset
|
244 |
* @param info the info required to identify and load the module |
111
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
245 |
* @param err returned error info |
54 | 246 |
*/ |
217 | 247 |
err_t module_load (struct modules *modules, struct module **module_ptr, const struct module_info *info, error_t *err); |
55
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
248 |
|
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
249 |
/** |
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
250 |
* Return a module retrieved using module_get |
66
ef8c9d7daf62
all options are now fully implemented
Tero Marttila <terom@fixme.fi>
parents:
65
diff
changeset
|
251 |
*/ |
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
252 |
void module_put (struct module *module); |
66
ef8c9d7daf62
all options are now fully implemented
Tero Marttila <terom@fixme.fi>
parents:
65
diff
changeset
|
253 |
|
ef8c9d7daf62
all options are now fully implemented
Tero Marttila <terom@fixme.fi>
parents:
65
diff
changeset
|
254 |
/** |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
255 |
* Look up a module configuration option by name |
55
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
256 |
*/ |
217 | 257 |
const struct config_option* module_conf_lookup (struct module *module, const char *name, error_t *err); |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
258 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
259 |
/** |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
260 |
* Apply a module configuration option using a structured value |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
261 |
*/ |
217 | 262 |
err_t module_conf (struct module *module, const struct config_option *opt, const struct config_value *value, error_t *err); |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
263 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
264 |
/** |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
265 |
* Set a module configuration option using a raw value |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
266 |
*/ |
217 | 267 |
err_t module_conf_raw (struct module *module, const char *name, char *value, error_t *err); |
54 | 268 |
|
269 |
/** |
|
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
270 |
* Unload a module. This removes the module from the modules_list, marks it as unloading, and then calls the module's |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
271 |
* \p unload function, passing it the primary reference. The module's unload code will then go about shutting down the |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
272 |
* module, and once that is done, it may module_put() the primary reference, which may then lead to module_destroy(). |
111
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
273 |
* |
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
274 |
* This returns ERR_MODULE_STATE if the module is already being unloaded, or other errors from the module's own unload |
5a1ebffca81a
fix refcount semantics for module_load and have module_unload call module_unloaded on module_desc::unload errors
Tero Marttila <terom@fixme.fi>
parents:
110
diff
changeset
|
275 |
* functionality. |
54 | 276 |
*/ |
277 |
err_t module_unload (struct module *module); |
|
278 |
||
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
279 |
/** |
110
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
280 |
* Used by a module itself to indicate that an module_desc::unload() operation has completed. This will execute a |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
281 |
* deferred module_destroy() if there are no more references left on the module. |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
282 |
* |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
283 |
* Note: this is not intended to be called from outside the given module itself... |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
284 |
*/ |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
285 |
void module_unloaded (struct module *module); |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
286 |
|
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
287 |
/** |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
288 |
* Destroy a module, releasing as many resources as possible, but not stopping for errors. |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
289 |
* |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
290 |
* This does not enforce the correct refcount - 'tis the caller's responsibility. Prints out a warning if |
43e9a7984955
fix operation of module_unload/module_destroy so that unloaded modules are now destroyed once they have been unloaded
Tero Marttila <terom@fixme.fi>
parents:
108
diff
changeset
|
291 |
* refcount > 0. |
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
292 |
*/ |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
293 |
void module_destroy (struct module *module); |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
294 |
|
54 | 295 |
#endif |