mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 04:33:05 +00:00
bugfix: harbor service should not release before others
This commit is contained in:
@@ -31,5 +31,17 @@ skynet_harbor_init(int harbor) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
skynet_harbor_start(void *ctx) {
|
skynet_harbor_start(void *ctx) {
|
||||||
|
// the HARBOR must be reserved to ensure the pointer is valid.
|
||||||
|
// It will be released at last by calling skynet_harbor_exit
|
||||||
|
skynet_context_reserve(ctx);
|
||||||
REMOTE = ctx;
|
REMOTE = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
skynet_harbor_exit() {
|
||||||
|
struct skynet_context * ctx = REMOTE;
|
||||||
|
REMOTE= NULL;
|
||||||
|
if (ctx) {
|
||||||
|
skynet_context_release(ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,5 +26,6 @@ void skynet_harbor_send(struct remote_message *rmsg, uint32_t source, int sessio
|
|||||||
int skynet_harbor_message_isremote(uint32_t handle);
|
int skynet_harbor_message_isremote(uint32_t handle);
|
||||||
void skynet_harbor_init(int harbor);
|
void skynet_harbor_init(int harbor);
|
||||||
void skynet_harbor_start(void * ctx);
|
void skynet_harbor_start(void * ctx);
|
||||||
|
void skynet_harbor_exit();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -178,6 +178,14 @@ skynet_context_grab(struct skynet_context *ctx) {
|
|||||||
__sync_add_and_fetch(&ctx->ref,1);
|
__sync_add_and_fetch(&ctx->ref,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
skynet_context_reserve(struct skynet_context *ctx) {
|
||||||
|
skynet_context_grab(ctx);
|
||||||
|
// don't count the context reserved, because skynet abort (the worker threads terminate) only when the total context is 0 .
|
||||||
|
// the reserved context will be release at last.
|
||||||
|
context_dec();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
delete_context(struct skynet_context *ctx) {
|
delete_context(struct skynet_context *ctx) {
|
||||||
if (ctx->logfile) {
|
if (ctx->logfile) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ struct skynet_monitor;
|
|||||||
|
|
||||||
struct skynet_context * skynet_context_new(const char * name, const char * parm);
|
struct skynet_context * skynet_context_new(const char * name, const char * parm);
|
||||||
void skynet_context_grab(struct skynet_context *);
|
void skynet_context_grab(struct skynet_context *);
|
||||||
|
void skynet_context_reserve(struct skynet_context *ctx);
|
||||||
struct skynet_context * skynet_context_release(struct skynet_context *);
|
struct skynet_context * skynet_context_release(struct skynet_context *);
|
||||||
uint32_t skynet_context_handle(struct skynet_context *);
|
uint32_t skynet_context_handle(struct skynet_context *);
|
||||||
int skynet_context_push(uint32_t handle, struct skynet_message *message);
|
int skynet_context_push(uint32_t handle, struct skynet_message *message);
|
||||||
|
|||||||
@@ -236,4 +236,5 @@ skynet_start(struct skynet_config * config) {
|
|||||||
if (config->daemon) {
|
if (config->daemon) {
|
||||||
daemon_exit(config->daemon);
|
daemon_exit(config->daemon);
|
||||||
}
|
}
|
||||||
|
skynet_harbor_exit();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user