summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-06-23 19:19:41 +0300
committerMax Romanov <max.romanov@nginx.com>2017-06-23 19:19:41 +0300
commit58e20da984d395857c3334ce74aa7c99dae84377 (patch)
tree60bb7a6ce8f1ff17b5d10dc543524d171dde51ca
parentfa94dc7782827ab13fcf444eb3949b78d5987d83 (diff)
downloadunit-58e20da984d395857c3334ce74aa7c99dae84377.tar.gz
unit-58e20da984d395857c3334ce74aa7c99dae84377.tar.bz2
Runtime ports fix, add enumeration macros.
-rw-r--r--src/nxt_runtime.c19
-rw-r--r--src/nxt_runtime.h19
2 files changed, 35 insertions, 3 deletions
diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c
index 5ea73a16..8d415ce0 100644
--- a/src/nxt_runtime.c
+++ b/src/nxt_runtime.c
@@ -1499,10 +1499,10 @@ static const nxt_lvlhsh_proto_t lvlhsh_processes_proto nxt_aligned(64) = {
nxt_lvlhsh_free,
};
-
+// Explicitly using 32 bit types to avoid possible alignment.
typedef struct {
- nxt_pid_t pid;
- nxt_port_id_t port_id;
+ int32_t pid;
+ uint32_t port_id;
} nxt_pid_port_id_t;
static nxt_int_t
@@ -1689,6 +1689,17 @@ nxt_runtime_process_first(nxt_runtime_t *rt, nxt_lvlhsh_each_t *lhe)
}
+nxt_port_t *
+nxt_runtime_port_first(nxt_runtime_t *rt, nxt_lvlhsh_each_t *lhe)
+{
+ nxt_memzero(lhe, sizeof(nxt_lvlhsh_each_t));
+
+ lhe->proto = &lvlhsh_ports_proto;
+
+ return nxt_runtime_port_next(rt, lhe);
+}
+
+
void
nxt_runtime_port_add(nxt_runtime_t *rt, nxt_port_t *port)
{
@@ -1714,6 +1725,8 @@ nxt_runtime_port_add(nxt_runtime_t *rt, nxt_port_t *port)
break;
default:
+ nxt_thread_log_error(NXT_LOG_WARN, "port #%d for pid %PI add failed",
+ port->id, port->pid);
break;
}
}
diff --git a/src/nxt_runtime.h b/src/nxt_runtime.h
index d0ed00a1..3ba082f9 100644
--- a/src/nxt_runtime.h
+++ b/src/nxt_runtime.h
@@ -108,6 +108,12 @@ void nxt_runtime_port_remove(nxt_runtime_t *rt, nxt_port_t *port);
nxt_port_t *nxt_runtime_port_find(nxt_runtime_t *rt, nxt_pid_t pid,
nxt_port_id_t port_id);
+nxt_port_t *nxt_runtime_port_first(nxt_runtime_t *rt,
+ nxt_lvlhsh_each_t *lhe);
+
+#define nxt_runtime_port_next(rt, lhe) \
+ nxt_lvlhsh_each(&rt->ports, lhe)
+
/* STUB */
nxt_int_t nxt_runtime_controller_socket(nxt_task_t *task, nxt_runtime_t *rt);
@@ -143,6 +149,19 @@ nxt_int_t nxt_app_start(nxt_task_t *task, nxt_runtime_t *rt);
} while(0)
+#define nxt_runtime_port_each(rt, port) \
+ do { \
+ nxt_lvlhsh_each_t _lhe; \
+ \
+ for (port = nxt_runtime_port_first(rt, &_lhe); \
+ port != NULL; \
+ port = nxt_runtime_port_next(rt, &_lhe)) { \
+
+#define nxt_runtime_port_loop \
+ } \
+ } while(0)
+
+
extern nxt_module_init_t nxt_init_modules[];
extern nxt_uint_t nxt_init_modules_n;