diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-08-31 00:42:12 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-08-31 00:42:12 +0300 |
commit | 61606835448554a7ee9a4431d732e1f2a9318376 (patch) | |
tree | 171841cea56c4fdbd0fd1bb2473e18d3a96cda3a | |
parent | 3f10b05de995099bf7551b17f5d8d38efe8b4fc5 (diff) | |
download | unit-61606835448554a7ee9a4431d732e1f2a9318376.tar.gz unit-61606835448554a7ee9a4431d732e1f2a9318376.tar.bz2 |
Introduced module compatibility vector.
-rw-r--r-- | src/nxt_application.c | 26 | ||||
-rw-r--r-- | src/nxt_application.h | 3 | ||||
-rw-r--r-- | src/nxt_go.c | 2 | ||||
-rw-r--r-- | src/nxt_main.h | 1 | ||||
-rw-r--r-- | src/nxt_main_process.c | 10 | ||||
-rw-r--r-- | src/nxt_php_sapi.c | 6 | ||||
-rw-r--r-- | src/nxt_python_wsgi.c | 7 |
7 files changed, 50 insertions, 5 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c index d9245688..c1a3bb77 100644 --- a/src/nxt_application.c +++ b/src/nxt_application.c @@ -37,6 +37,11 @@ static nxt_http_fields_hash_t *nxt_app_request_fields_hash; static nxt_application_module_t *nxt_app; +static uint32_t compat[] = { + NXT_VERNUM, +}; + + nxt_int_t 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"); if (app != NULL) { - nxt_log(task, NXT_LOG_NOTICE, "module: %V \"%s\"", - &app->version, name); + nxt_log(task, NXT_LOG_NOTICE, "module: %V %V \"%s\"", + &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; n = modules->nelts; 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, "ignoring %s module with the same " - "application language version %V as in %s", - name, &module[i].version, &module[i].file); + "application language version %V %V as in %s", + name, &module[i].type, &module[i].version, + &module[i].file); goto done; } diff --git a/src/nxt_application.h b/src/nxt_application.h index c8d9998d..7747883b 100644 --- a/src/nxt_application.h +++ b/src/nxt_application.h @@ -203,6 +203,9 @@ NXT_EXPORT nxt_int_t nxt_app_msg_read_size(nxt_task_t *task, struct nxt_app_module_s { + size_t compat_length; + uint32_t *compat; + nxt_str_t type; nxt_str_t version; diff --git a/src/nxt_go.c b/src/nxt_go.c index 1c1961b2..28d681ee 100644 --- a/src/nxt_go.c +++ b/src/nxt_go.c @@ -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_application_module_t nxt_go_module = { + 0, + NULL, nxt_string("go"), nxt_string("go"), nxt_go_init, diff --git a/src/nxt_main.h b/src/nxt_main.h index c7776c8b..15c56727 100644 --- a/src/nxt_main.h +++ b/src/nxt_main.h @@ -12,6 +12,7 @@ #define NXT_VERSION "0.1" +#define NXT_VERNUM 0x00000001 typedef struct nxt_port_s nxt_port_t; diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c index 110867ca..4043d026 100644 --- a/src/nxt_main_process.c +++ b/src/nxt_main_process.c @@ -1026,6 +1026,16 @@ nxt_app_lang_compare(const void *v1, const void *v2) lang1 = v1; 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); n = nxt_strncmp(lang1->version.start, lang2->version.start, length); diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c index 1e1f4087..5655dcbc 100644 --- a/src/nxt_php_sapi.c +++ b/src/nxt_php_sapi.c @@ -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 = { + sizeof(compat), + compat, nxt_string("php"), nxt_string(PHP_VERSION), nxt_php_init, diff --git a/src/nxt_python_wsgi.c b/src/nxt_python_wsgi.c index f5c3ebae..fd718a95 100644 --- a/src/nxt_python_wsgi.c +++ b/src/nxt_python_wsgi.c @@ -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); +static uint32_t compat[] = { + NXT_VERNUM, +}; + + NXT_EXPORT nxt_application_module_t nxt_app_module = { + sizeof(compat), + compat, nxt_string("python"), nxt_string(PY_VERSION), nxt_python_init, |