Introducing app joint to accurate app release.
For accurate app descriptor release, it is required to count the number of use counts. Use count increased when: - app linked to configuration app queue; - socket conf stores pointer to app; - request for start app process posted to router service thread; Application port has pointer to app, but it does not increase use count to avoid use count loop. Timer needs a pointer to nxt_timer_t which is stored in engine timers tree. nxt_timer_t now resides in nxt_app_joint_t and does not lock the application. Start process port RPC handlers is also linked to nxt_app_joint_t. App joint (nxt_app_joint_t) is a 'weak pointer': - single threaded; - use countable; - store pointer to nxt_app_t (which can be NULL); nxt_app_t has pointer to nxt_app_joint_t and update its pointer to app.
This commit is contained in:
@@ -81,13 +81,20 @@ typedef struct {
|
||||
} nxt_joint_job_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t use_count;
|
||||
nxt_app_t *app;
|
||||
nxt_timer_t idle_timer;
|
||||
nxt_work_t free_app_work;
|
||||
} nxt_app_joint_t;
|
||||
|
||||
|
||||
struct nxt_app_s {
|
||||
nxt_thread_mutex_t mutex; /* Protects ports queue. */
|
||||
nxt_queue_t ports; /* of nxt_port_t.app_link */
|
||||
|
||||
nxt_queue_t spare_ports; /* of nxt_port_t.idle_link */
|
||||
nxt_queue_t idle_ports; /* of nxt_port_t.idle_link */
|
||||
nxt_timer_t idle_timer;
|
||||
nxt_work_t adjust_idle_work;
|
||||
nxt_event_engine_t *engine;
|
||||
|
||||
@@ -110,13 +117,14 @@ struct nxt_app_s {
|
||||
nxt_msec_t idle_timeout;
|
||||
|
||||
nxt_app_type_t type:8;
|
||||
uint8_t live; /* 1 bit */
|
||||
|
||||
nxt_queue_link_t link;
|
||||
|
||||
nxt_str_t conf;
|
||||
|
||||
nxt_atomic_t use_count;
|
||||
|
||||
nxt_app_joint_t *joint;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user