Closed haimomesi closed 4 years ago
ejabberd supports from Erlang/OTP 19.3, and that Erlang version still used the old parts of erl_interface: http://erlang.org/documentation/doc-8.3/lib/erl_interface-3.9.3/doc/html/ei_users_guide.html#id62129
Apparently the new API was introduced in Erlang/OTP 21.3: http://erlang.org/documentation/doc-10.3/lib/erl_interface-3.11/doc/html/ei_users_guide.html#initializing-the-libraries
So, it isn't possible to write one API call that supports all the supported versions. Either code is added to determine which Erlang version is available, or the Erlang requirement is raised to 21.3 in ejabberd when eimp is enabled.
BTW, I wonder if the change is as simple as this, or it would require major changes:
diff --git a/c_src/eimp.c b/c_src/eimp.c
index 22a46b4..ac7cf47 100644
--- a/c_src/eimp.c
+++ b/c_src/eimp.c
@@ -18,7 +18,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <erl_interface.h>
#include <ei.h>
#include <unistd.h>
#include <arpa/inet.h>
@@ -471,7 +470,7 @@ void loop(void)
int main(int argc, char *argv[])
{
- erl_init(NULL, 0);
+ ei_init();
loop();
return 0;
}
I am not even sure if we need ei_init, i think this code doesn't call any function from erlang, looks like it mostly uses just libc.
Aha! In eimp there is no call to functions ei* or erl*, so in theory there's no need to initialize it.
I've applied this in Erlang/OTP 22.3 and mod_avatar converts images correctly. @haimomesi can you try this with 23 and comment your testing?:
diff --git a/c_src/eimp.c b/c_src/eimp.c
index 22a46b4..314a960 100644
--- a/c_src/eimp.c
+++ b/c_src/eimp.c
@@ -18,7 +18,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <erl_interface.h>
#include <ei.h>
#include <unistd.h>
#include <arpa/inet.h>
@@ -471,7 +470,6 @@ void loop(void)
int main(int argc, char *argv[])
{
- erl_init(NULL, 0);
loop();
return 0;
}
BTW, it isn't feasible to remove ei.h too, because eimp uses EINTR.
Fixed in commit 7fe680d25426b1808f3c49e77240f3cfd5ef712b
According to OTP 23 Potential Incompatibilities:
And I do get the error:
/deps/eimp/c_src/eimp.c:21:10: fatal error: 'erl_interface.h' file not found