summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_unit.h
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2020-08-11 19:19:55 +0300
committerMax Romanov <max.romanov@nginx.com>2020-08-11 19:19:55 +0300
commitec3389b63bd7a9159d2be4a2863140f75095c7d3 (patch)
treef88972c19c713748b56c339dab1bdd60892eaeec /src/nxt_unit.h
parent3a721e1d96720505d4d6638e77d2c296d962519c (diff)
downloadunit-ec3389b63bd7a9159d2be4a2863140f75095c7d3.tar.gz
unit-ec3389b63bd7a9159d2be4a2863140f75095c7d3.tar.bz2
Libunit refactoring: port management.
- Changed the port management callbacks to notifications, which e. g. avoids the need to call the libunit function - Added context and library instance reference counts for a safer resource release - Added the router main port initialization
Diffstat (limited to 'src/nxt_unit.h')
-rw-r--r--src/nxt_unit.h44
1 files changed, 4 insertions, 40 deletions
diff --git a/src/nxt_unit.h b/src/nxt_unit.h
index 596dd8b6..fa1fa843 100644
--- a/src/nxt_unit.h
+++ b/src/nxt_unit.h
@@ -130,15 +130,15 @@ struct nxt_unit_callbacks_s {
int (*add_port)(nxt_unit_ctx_t *, nxt_unit_port_t *port);
/* Remove previously added port. Optional. */
- void (*remove_port)(nxt_unit_ctx_t *, nxt_unit_port_id_t *port_id);
+ void (*remove_port)(nxt_unit_t *, nxt_unit_port_t *port);
/* Remove all data associated with process pid including ports. Optional. */
- void (*remove_pid)(nxt_unit_ctx_t *, pid_t pid);
+ void (*remove_pid)(nxt_unit_t *, pid_t pid);
/* Gracefully quit the application. Optional. */
void (*quit)(nxt_unit_ctx_t *);
- /* Shared memory release acknowledgement. */
+ /* Shared memory release acknowledgement. Optional. */
void (*shm_ack_handler)(nxt_unit_ctx_t *);
/* Send data and control to process pid using port id. Optional. */
@@ -149,7 +149,6 @@ struct nxt_unit_callbacks_s {
/* Receive data on port id. Optional. */
ssize_t (*port_recv)(nxt_unit_ctx_t *, nxt_unit_port_id_t *port_id,
void *buf, size_t buf_size, void *oob, size_t oob_size);
-
};
@@ -165,6 +164,7 @@ struct nxt_unit_init_s {
nxt_unit_port_t ready_port;
uint32_t ready_stream;
+ nxt_unit_port_t router_port;
nxt_unit_port_t read_port;
int log_fd;
};
@@ -222,45 +222,9 @@ void nxt_unit_done(nxt_unit_ctx_t *);
*/
nxt_unit_ctx_t *nxt_unit_ctx_alloc(nxt_unit_ctx_t *, void *);
-/* Free unused context. It is not required to free main context. */
-void nxt_unit_ctx_free(nxt_unit_ctx_t *);
-
/* Initialize port_id, calculate hash. */
void nxt_unit_port_id_init(nxt_unit_port_id_t *port_id, pid_t pid, uint16_t id);
-/*
- * Create extra incoming port, perform all required actions to propogate
- * the port to Unit server. Fills structure referenced by port_id with
- * current pid and new port id.
- */
-int nxt_unit_create_send_port(nxt_unit_ctx_t *, nxt_unit_port_id_t *dst,
- nxt_unit_port_id_t *port_id);
-
-/* Default 'add_port' implementation. */
-int nxt_unit_add_port(nxt_unit_ctx_t *, nxt_unit_port_t *port);
-
-/* Find previously added port. */
-nxt_unit_port_t *nxt_unit_find_port(nxt_unit_ctx_t *,
- nxt_unit_port_id_t *port_id);
-
-/* Find, fill output 'port' and remove port from storage. */
-void nxt_unit_find_remove_port(nxt_unit_ctx_t *, nxt_unit_port_id_t *port_id,
- nxt_unit_port_t *port);
-
-/* Default 'remove_port' implementation. */
-void nxt_unit_remove_port(nxt_unit_ctx_t *, nxt_unit_port_id_t *port_id);
-
-/* Default 'remove_pid' implementation. */
-void nxt_unit_remove_pid(nxt_unit_ctx_t *, pid_t pid);
-
-/* Default 'quit' implementation. */
-void nxt_unit_quit(nxt_unit_ctx_t *);
-
-/* Default 'port_send' implementation. */
-ssize_t nxt_unit_port_send(nxt_unit_ctx_t *, int fd,
- const void *buf, size_t buf_size,
- const void *oob, size_t oob_size);
-
/* Default 'port_recv' implementation. */
ssize_t nxt_unit_port_recv(nxt_unit_ctx_t *, int fd, void *buf, size_t buf_size,
void *oob, size_t oob_size);