MCPcopy Create free account
hub / github.com/apache/httpd / load_module

Function load_module

modules/core/mod_so.c:182–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180 */
181
182static const char *load_module(cmd_parms *cmd, void *dummy,
183 const char *modname, const char *filename)
184{
185 apr_dso_handle_t *modhandle;
186 apr_dso_handle_sym_t modsym;
187 module *modp;
188 const char *module_file;
189 so_server_conf *sconf;
190 ap_module_symbol_t *modi;
191 ap_module_symbol_t *modie;
192 int i;
193 const char *error;
194
195 /* we need to setup this value for dummy to make sure that we don't try
196 * to add a non-existent tree into the build when we return to
197 * execute_now.
198 */
199 *(ap_directive_t **)dummy = NULL;
200
201 /*
202 * check for already existing module
203 * If it already exists, we have nothing to do
204 * Check both dynamically-loaded modules and statically-linked modules.
205 */
206 sconf = (so_server_conf *)ap_get_module_config(cmd->server->module_config,
207 &so_module);
208 modie = (ap_module_symbol_t *)sconf->loaded_modules->elts;
209 for (i = 0; i < sconf->loaded_modules->nelts; i++) {
210 modi = &modie[i];
211 if (modi->name != NULL && strcmp(modi->name, modname) == 0) {
212 ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, cmd->pool, APLOGNO(01574)
213 "module %s is already loaded, skipping",
214 modname);
215 return NULL;
216 }
217 }
218
219 for (i = 0; ap_preloaded_modules[i]; i++) {
220 const char *preload_name;
221 apr_size_t preload_len;
222 apr_size_t thismod_len;
223
224 modp = ap_preloaded_modules[i];
225
226 /* make sure we're comparing apples with apples
227 * make sure name of preloaded module is mod_FOO.c
228 * make sure name of structure being loaded is FOO_module
229 */
230
231 if (memcmp(modp->name, "mod_", 4)) {
232 continue;
233 }
234
235 preload_name = modp->name + strlen("mod_");
236 preload_len = strlen(preload_name) - 2;
237
238 if (strlen(modname) <= strlen("_module")) {
239 continue;

Callers

nothing calls this directly

Calls 4

ap_get_module_configFunction · 0.85
dso_loadFunction · 0.85
ap_add_loaded_moduleFunction · 0.85

Tested by

no test coverage detected