diff options
| author | mbalmer <mbalmer@NetBSD.org> | 2017-05-20 08:31:13 +0000 |
|---|---|---|
| committer | mbalmer <mbalmer@NetBSD.org> | 2017-05-20 08:31:13 +0000 |
| commit | dd2fb1104b12c6fb46fbcb4f0a2c5478653c9a82 (patch) | |
| tree | 05406bebf25e23abc76b85cf5c309d395724d3b9 /sys/modules/lua | |
| parent | 0d200895dc7fc86bc45f3a80c8301a207a994525 (diff) | |
Only load a module if it is not already loaded in a state (much like userland
Lua handles require).
Fixes PR kern/52226.
Diffstat (limited to 'sys/modules/lua')
| -rw-r--r-- | sys/modules/lua/lua.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/modules/lua/lua.c b/sys/modules/lua/lua.c index 14e90ba7d5b..9ed427ccbd9 100644 --- a/sys/modules/lua/lua.c +++ b/sys/modules/lua/lua.c @@ -1,8 +1,8 @@ -/* $NetBSD: lua.c,v 1.21 2017/05/11 07:34:27 mbalmer Exp $ */ +/* $NetBSD: lua.c,v 1.22 2017/05/20 08:31:13 mbalmer Exp $ */ /* + * Copyright (c) 2011 - 2017 by Marc Balmer <mbalmer@NetBSD.org>. * Copyright (c) 2014 by Lourival Vieira Neto <lneto@NetBSD.org>. - * Copyright (c) 2011 - 2014 by Marc Balmer <mbalmer@NetBSD.org>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -514,6 +514,10 @@ lua_require(lua_State *L) if (md != NULL) LIST_FOREACH(s, &lua_states, lua_next) if (s->K->L == L) { + LIST_FOREACH(m, &s->lua_modules, mod_next) + if (m == md) + return 1; + if (lua_verbose) device_printf(sc_self, "require module %s\n", |
