44zl6w
Last Updated: February 25, 2016
·
1.268K
· mremond
A86897320f9fcda11c8ce08b3e3489f4

Adapting an old ejabberd version for Erlang R15

You sometimes need to run an old ejabberd version like 2.0.x with last up to date Erlang VM R15B.

You will then be stuck running Erlang drivers with the following error message:

unable to load driver './sha_drv.so': Driver compiled with incorrect version of erl_driver.h

The solution is straightforward.

You first need to update the driver to the new ErlDrvEntry structure. Make sure your structure is:

static ErlDrvEntry mydriver_entry = {
   NULL,                             /* init */
   start, 
   stop, 
   NULL,                             /* output */
   NULL,                             /* ready_input */
   NULL,                             /* ready_output */ 
   "mydriver_drv",                      /* the name of the driver */
   NULL,                             /* finish */
   NULL,                             /* handle */
   NULL,                             /* control */
   NULL,                             /* timeout */
   process,                          /* outputv */
   NULL,                             /* ready_async */
   NULL,                             /* flush */
   NULL,                             /* call */
   NULL,                             /* event */
   ERL_DRV_EXTENDED_MARKER,          /* ERL_DRV_EXTENDED_MARKER */
   ERL_DRV_EXTENDED_MAJOR_VERSION,   /* ERL_DRV_EXTENDED_MAJOR_VERSION */
   ERL_DRV_EXTENDED_MINOR_VERSION,   /* ERL_DRV_EXTENDED_MINOR_VERSION -> CHECK IF REALLY MINOR */
   ERL_DRV_FLAG_USE_PORT_LOCKING     /* ERL_DRV_FLAGs */

};

Practically, I had to extend the structure in all driver files with the following fields:

NULL,                             /* ready_async */
NULL,                             /* flush */
NULL,                             /* call */
NULL,                             /* event */
ERL_DRV_EXTENDED_MARKER,          /* ERL_DRV_EXTENDED_MARKER */
ERL_DRV_EXTENDED_MAJOR_VERSION,   /* ERL_DRV_EXTENDED_MAJOR_VERSION */
ERL_DRV_EXTENDED_MINOR_VERSION,   /* ERL_DRV_EXTENDED_MINOR_VERSION -> CHECK IF REALLY MINOR */
ERL_DRV_FLAG_USE_PORT_LOCKING     /* ERL_DRV_FLAGs */

Just grep for ErlDrvEntry in source code and update all your structures.

The last problem is even easier to solve. Regexp module is deprecated. You have to update your code to the new re.erl module.

Here is an example from gen_mod.erl:
- element(2, regexp:gsub(Val, "@HOST@", Host)).
+ re:replace(Val, "@HOST@", Host, [global, {return, list}]).

ProcessOne has an example of matching for migration from regexp.erl to re.erl: https://support.process-one.net/browse/EJAB-921

Say Thanks
Respond