Introduced module compatibility vector.
This commit is contained in:
@@ -37,6 +37,11 @@ static nxt_http_fields_hash_t *nxt_app_request_fields_hash;
|
|||||||
static nxt_application_module_t *nxt_app;
|
static nxt_application_module_t *nxt_app;
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t compat[] = {
|
||||||
|
NXT_VERNUM,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
nxt_int_t
|
nxt_int_t
|
||||||
nxt_discovery_start(nxt_task_t *task, void *data)
|
nxt_discovery_start(nxt_task_t *task, void *data)
|
||||||
{
|
{
|
||||||
@@ -195,18 +200,29 @@ nxt_discovery_module(nxt_task_t *task, nxt_mp_t *mp, nxt_array_t *modules,
|
|||||||
app = dlsym(dl, "nxt_app_module");
|
app = dlsym(dl, "nxt_app_module");
|
||||||
|
|
||||||
if (app != NULL) {
|
if (app != NULL) {
|
||||||
nxt_log(task, NXT_LOG_NOTICE, "module: %V \"%s\"",
|
nxt_log(task, NXT_LOG_NOTICE, "module: %V %V \"%s\"",
|
||||||
&app->version, name);
|
&app->type, &app->version, name);
|
||||||
|
|
||||||
|
if (app->compat_length != sizeof(compat)
|
||||||
|
|| nxt_memcmp(app->compat, compat, sizeof(compat)) != 0)
|
||||||
|
{
|
||||||
|
nxt_log(task, NXT_LOG_NOTICE, "incompatible module %s", name);
|
||||||
|
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
module = modules->elts;
|
module = modules->elts;
|
||||||
n = modules->nelts;
|
n = modules->nelts;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
if (nxt_strstr_eq(&app->version, &module[i].version)) {
|
if (nxt_strstr_eq(&app->type, &module[i].type)
|
||||||
|
&& nxt_strstr_eq(&app->version, &module[i].version))
|
||||||
|
{
|
||||||
nxt_log(task, NXT_LOG_NOTICE,
|
nxt_log(task, NXT_LOG_NOTICE,
|
||||||
"ignoring %s module with the same "
|
"ignoring %s module with the same "
|
||||||
"application language version %V as in %s",
|
"application language version %V %V as in %s",
|
||||||
name, &module[i].version, &module[i].file);
|
name, &module[i].type, &module[i].version,
|
||||||
|
&module[i].file);
|
||||||
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,6 +203,9 @@ NXT_EXPORT nxt_int_t nxt_app_msg_read_size(nxt_task_t *task,
|
|||||||
|
|
||||||
|
|
||||||
struct nxt_app_module_s {
|
struct nxt_app_module_s {
|
||||||
|
size_t compat_length;
|
||||||
|
uint32_t *compat;
|
||||||
|
|
||||||
nxt_str_t type;
|
nxt_str_t type;
|
||||||
nxt_str_t version;
|
nxt_str_t version;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ static nxt_int_t nxt_go_run(nxt_task_t *task,
|
|||||||
nxt_app_rmsg_t *rmsg, nxt_app_wmsg_t *msg);
|
nxt_app_rmsg_t *rmsg, nxt_app_wmsg_t *msg);
|
||||||
|
|
||||||
nxt_application_module_t nxt_go_module = {
|
nxt_application_module_t nxt_go_module = {
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
nxt_string("go"),
|
nxt_string("go"),
|
||||||
nxt_string("go"),
|
nxt_string("go"),
|
||||||
nxt_go_init,
|
nxt_go_init,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define NXT_VERSION "0.1"
|
#define NXT_VERSION "0.1"
|
||||||
|
#define NXT_VERNUM 0x00000001
|
||||||
|
|
||||||
|
|
||||||
typedef struct nxt_port_s nxt_port_t;
|
typedef struct nxt_port_s nxt_port_t;
|
||||||
|
|||||||
@@ -1026,6 +1026,16 @@ nxt_app_lang_compare(const void *v1, const void *v2)
|
|||||||
lang1 = v1;
|
lang1 = v1;
|
||||||
lang2 = v2;
|
lang2 = v2;
|
||||||
|
|
||||||
|
if (lang1->type.length != lang2->type.length) {
|
||||||
|
return lang1->type.length - lang2->type.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = nxt_strncmp(lang1->type.start, lang2->type.start, lang1->type.length);
|
||||||
|
|
||||||
|
if (n != 0) {
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
length = nxt_min(lang1->version.length, lang2->version.length);
|
length = nxt_min(lang1->version.length, lang2->version.length);
|
||||||
|
|
||||||
n = nxt_strncmp(lang1->version.start, lang2->version.start, length);
|
n = nxt_strncmp(lang1->version.start, lang2->version.start, length);
|
||||||
|
|||||||
@@ -167,8 +167,14 @@ nxt_php_str_trim_lead(nxt_str_t *str, u_char t)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t compat[] = {
|
||||||
|
NXT_VERNUM,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
NXT_EXPORT nxt_application_module_t nxt_app_module = {
|
NXT_EXPORT nxt_application_module_t nxt_app_module = {
|
||||||
|
sizeof(compat),
|
||||||
|
compat,
|
||||||
nxt_string("php"),
|
nxt_string("php"),
|
||||||
nxt_string(PHP_VERSION),
|
nxt_string(PHP_VERSION),
|
||||||
nxt_php_init,
|
nxt_php_init,
|
||||||
|
|||||||
@@ -91,7 +91,14 @@ nxt_inline nxt_int_t nxt_python_write_py_str(nxt_python_run_ctx_t *ctx,
|
|||||||
PyObject *str, nxt_bool_t flush, nxt_bool_t last);
|
PyObject *str, nxt_bool_t flush, nxt_bool_t last);
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t compat[] = {
|
||||||
|
NXT_VERNUM,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
NXT_EXPORT nxt_application_module_t nxt_app_module = {
|
NXT_EXPORT nxt_application_module_t nxt_app_module = {
|
||||||
|
sizeof(compat),
|
||||||
|
compat,
|
||||||
nxt_string("python"),
|
nxt_string("python"),
|
||||||
nxt_string(PY_VERSION),
|
nxt_string(PY_VERSION),
|
||||||
nxt_python_init,
|
nxt_python_init,
|
||||||
|
|||||||
Reference in New Issue
Block a user