Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into webui.mod
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelortmann committed Dec 2, 2024
2 parents 8260788 + 0f5599e commit a3f044c
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ eggdrop
EGGMOD.stamp
mod.xlibs
__pycache__
.clangd
2 changes: 1 addition & 1 deletion doc/sphinx_source/using/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ Modules

After the core settings, you should start loading modules. Modules are
loaded by the command "loadmodule <module>". Eggdrop looks for modules
in the directory you specified by the module-path setting in the files
in the directory you specified by the mod-path setting in the files
and directories section.

Please note that for different configurations, different modules are needed.
Expand Down
3 changes: 2 additions & 1 deletion src/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ void *thread_dns_ipbyhost(void *arg)
else if (error == EAI_NONAME)
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): not known");
else if (error == EAI_SYSTEM) {
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s: %s", gai_strerror(error), strerror(errno));
/* print raw errno, dont use strerror() in thread and dont use strerror_r() due to GNU / POSIX portability complexity */
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s: errno %i", gai_strerror(error), errno);
} else
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s", gai_strerror(error));
close(dtn->fildes[1]);
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ static void mainloop(int toplevel)
if (strcmp(p->name, "eggdrop") && strcmp(p->name, "encryption") &&
strcmp(p->name, "encryption2") && strcmp(p->name, "uptime")) {
f++;
debug1("stagnant module %s", p->name);
putlog(LOG_MISC, "*", "stagnant module %s", p->name);
}
}
if (f != 0) {
Expand Down
12 changes: 9 additions & 3 deletions src/mod/irc.mod/chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2240,7 +2240,7 @@ static int gotjoin(char *from, char *channame)
*/
static int gotpart(char *from, char *msg)
{
char *nick, *chname, *key;
char *nick, *chname, uhost[UHOSTLEN], *key;
struct chanset_t *chan;
struct userrec *u;
memberlist *m;
Expand All @@ -2255,9 +2255,14 @@ static int gotpart(char *from, char *msg)
return 0;
}
if (chan && !channel_pending(chan)) {
strlcpy(uhost, from, sizeof uhost);
nick = splitnick(&from);
m = ismember(chan, nick);
u = get_user_from_member(m);
// TODO: check account from rawt account-tags
if (m)
u = get_user_from_member(m);
else
u = get_user_by_host(uhost);
if (!channel_active(chan)) {
/* whoa! */
putlog(LOG_MISC, chan->dname,
Expand All @@ -2276,7 +2281,8 @@ static int gotpart(char *from, char *msg)
if (!chan)
return 0;

killmember(chan, nick);
if (m)
killmember(chan, nick);
if (msg[0])
putlog(LOG_JOIN, chan->dname, "%s (%s) left %s (%s).", nick, from,
chan->dname, msg);
Expand Down
5 changes: 2 additions & 3 deletions src/mod/python.mod/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ distclean: clean
../../../src/compat/inet_aton.h ../../../src/compat/snprintf.h \
../../../src/compat/explicit_bzero.h ../../../src/compat/strlcpy.h \
../../../src/mod/modvals.h ../../../src/tandem.h \
../../../src/mod/irc.mod/irc.h ../../../src/mod/server.mod/server.h \
.././python.mod/python.h .././python.mod/pycmds.c \
.././python.mod/tclpython.c
../../../src/mod/server.mod/server.h .././python.mod/python.h \
.././python.mod/pycmds.c .././python.mod/tclpython.c
33 changes: 13 additions & 20 deletions src/mod/python.mod/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@
#undef days
#include <Python.h>
#include <datetime.h>
#include "src/mod/irc.mod/irc.h"
#include "src/mod/server.mod/server.h"
#include "python.h"

//static PyObject *pymodobj;
static PyObject *pirp, *pglobals;

#undef global
static Function *global = NULL, *irc_funcs = NULL;
static Function *global = NULL;
static PyThreadState *_pythreadsave;
#include "pycmds.c"
#include "tclpython.c"
Expand Down Expand Up @@ -141,33 +140,27 @@ static Function python_table[] = {
char *python_start(Function *global_funcs)
{
char *s;

/* Assign the core function table. After this point you use all normal
* functions defined in src/mod/modules.h
*/
global = global_funcs;

/* Register the module. */
module_register(MODULE_NAME, python_table, 0, 1);

if (!module_depend(MODULE_NAME, "eggdrop", 109, 0)) {
module_undepend(MODULE_NAME);
return "This module requires Eggdrop 1.9.0 or later.";
}
// TODO: Is this dependency necessary? It auto-loads irc.mod, that might be undesired
if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 5))) {
module_undepend(MODULE_NAME);
return "This module requires irc module 1.5 or later.";
if (global_funcs) {
global = global_funcs;

/* Register the module. */
module_register(MODULE_NAME, python_table, 0, 1);
if (!module_depend(MODULE_NAME, "eggdrop", 109, 0)) {
module_undepend(MODULE_NAME);
return "This module requires Eggdrop 1.9.0 or later.";
}
if ((s = init_python()))
return s;
}
// irc.mod depends on server.mod and channels.mod, so those were implicitly loaded

if ((s = init_python()))
return s;

/* Add command table to bind list */
add_builtins(H_dcc, mydcc);
add_tcl_commands(my_tcl_cmds);
add_hook(HOOK_PRE_SELECT, (Function)python_gil_unlock);
add_hook(HOOK_POST_SELECT, (Function)python_gil_lock);

return NULL;
}
2 changes: 1 addition & 1 deletion src/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ int module_register(char *name, Function *funcs, int major, int minor)

const char *module_load(char *name)
{
size_t len;
module_entry *p;
char *e;
Function f;
Expand All @@ -709,6 +708,7 @@ const char *module_load(char *name)
#endif

#ifndef STATIC
size_t len;
char workbuf[PATH_MAX];
# ifdef MOD_USE_SHL
shl_t hand;
Expand Down
6 changes: 6 additions & 0 deletions src/tcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,14 @@ int tclthreadmainloop(int zero)
return (i == -5);
}

struct threaddata *td_main = 0;

struct threaddata *threaddata()
{
static Tcl_ThreadDataKey tdkey;
struct threaddata *td = Tcl_GetThreadData(&tdkey, sizeof(struct threaddata));
if (!(td->mainloopfunc) && td_main) /* python thread */
return td_main;
return td;
}

Expand All @@ -638,6 +642,8 @@ void init_threaddata(int mainthread)
td->blocktime.tv_usec = 0;
td->MAXSOCKS = 0;
increase_socks_max();
if (mainthread)
td_main = td;
}

/* workaround for Tcl that does not support unicode outside BMP (3 byte utf-8 characters) */
Expand Down
6 changes: 6 additions & 0 deletions src/tclhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1240,13 +1240,19 @@ void check_tcl_die(char *reason)
void check_tcl_log(int lv, char *chan, char *msg)
{
char mask[512];
Tcl_Obj* prev_result;

/* We have to store the old result, as check_tcl_bind may override it */
prev_result = Tcl_GetObjResult(interp);
Tcl_IncrRefCount(prev_result);
egg_snprintf(mask, sizeof mask, "%s %s", chan, msg);
Tcl_SetVar(interp, "_log1", masktype(lv), TCL_GLOBAL_ONLY);
Tcl_SetVar(interp, "_log2", chan, TCL_GLOBAL_ONLY);
Tcl_SetVar(interp, "_log3", msg, TCL_GLOBAL_ONLY);
check_tcl_bind(H_log, mask, 0, " $::_log1 $::_log2 $::_log3",
MATCH_MASK | BIND_STACKABLE);
Tcl_SetObjResult(interp, prev_result);
Tcl_DecrRefCount(prev_result);
}

#ifdef TLS
Expand Down
3 changes: 2 additions & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
*/

#define EGG_STRINGVER "1.10.0"
#define EGG_NUMVER 1100003
#define EGG_NUMVER 1100005
#define EGG_PATCH "pythonfixes"

0 comments on commit a3f044c

Please sign in to comment.