mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
use skynet_error for log
This commit is contained in:
@@ -309,7 +309,10 @@ function skynet.call(addr, typename, ...)
|
|||||||
if watching_service[addr] == false then
|
if watching_service[addr] == false then
|
||||||
error("Service is dead")
|
error("Service is dead")
|
||||||
end
|
end
|
||||||
local session = assert(c.send(addr, p.id , nil , p.pack(...)),"call to invalid address")
|
local session = c.send(addr, p.id , nil , p.pack(...))
|
||||||
|
if session == nil then
|
||||||
|
error("call to invalid address " .. tostring(addr))
|
||||||
|
end
|
||||||
return p.unpack(yield_call(addr, session))
|
return p.unpack(yield_call(addr, session))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -319,7 +322,7 @@ function skynet.blockcall(addr, typename , ...)
|
|||||||
local session = c.send(addr, p.id , nil , p.pack(...))
|
local session = c.send(addr, p.id , nil , p.pack(...))
|
||||||
if session == nil then
|
if session == nil then
|
||||||
c.command("UNLOCK")
|
c.command("UNLOCK")
|
||||||
error("call to invalid address")
|
error("call to invalid address " .. tostring(addr))
|
||||||
end
|
end
|
||||||
return p.unpack(yield_call(addr, session))
|
return p.unpack(yield_call(addr, session))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ _cb(struct skynet_context * context, void * ud, int type, int session, uint32_t
|
|||||||
int
|
int
|
||||||
client_init(struct client *c, struct skynet_context *ctx, const char * args) {
|
client_init(struct client *c, struct skynet_context *ctx, const char * args) {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
if (args == NULL)
|
||||||
|
return 1;
|
||||||
sscanf(args, "%d",&id);
|
sscanf(args, "%d",&id);
|
||||||
c->id = id;
|
c->id = id;
|
||||||
skynet_callback(ctx, c, _cb);
|
skynet_callback(ctx, c, _cb);
|
||||||
|
|||||||
@@ -330,6 +330,8 @@ start_listen(struct gate *g, char * listen_addr) {
|
|||||||
|
|
||||||
int
|
int
|
||||||
gate_init(struct gate *g , struct skynet_context * ctx, char * parm) {
|
gate_init(struct gate *g , struct skynet_context * ctx, char * parm) {
|
||||||
|
if (parm == NULL)
|
||||||
|
return 1;
|
||||||
int max = 0;
|
int max = 0;
|
||||||
int buffer = 0;
|
int buffer = 0;
|
||||||
int sz = strlen(parm)+1;
|
int sz = strlen(parm)+1;
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ skynet_harbor_register(struct remote_name *rname) {
|
|||||||
|
|
||||||
int
|
int
|
||||||
skynet_harbor_message_isremote(uint32_t handle) {
|
skynet_harbor_message_isremote(uint32_t handle) {
|
||||||
return (handle & ~HANDLE_MASK) != HARBOR;
|
int h = (handle & ~HANDLE_MASK);
|
||||||
|
return h != HARBOR && h !=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -120,10 +120,11 @@ skynet_context_new(const char * name, const char *param) {
|
|||||||
}
|
}
|
||||||
skynet_mq_force_push(queue);
|
skynet_mq_force_push(queue);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("[:%x] launch %s %s\n",ret->handle, name, param ? param : "");
|
skynet_error(ret, "LAUNCH %s %s", name, param ? param : "");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
|
skynet_error(ctx, "FAILED launch %s", name);
|
||||||
skynet_context_release(ctx);
|
skynet_context_release(ctx);
|
||||||
skynet_handle_retire(ctx->handle);
|
skynet_handle_retire(ctx->handle);
|
||||||
skynet_mq_release(queue);
|
skynet_mq_release(queue);
|
||||||
@@ -358,9 +359,11 @@ static void
|
|||||||
handle_exit(struct skynet_context * context, uint32_t handle) {
|
handle_exit(struct skynet_context * context, uint32_t handle) {
|
||||||
if (handle == 0) {
|
if (handle == 0) {
|
||||||
handle = context->handle;
|
handle = context->handle;
|
||||||
|
skynet_error(context, "KILL self");
|
||||||
}
|
}
|
||||||
if (G_NODE.monitor_exit) {
|
if (G_NODE.monitor_exit) {
|
||||||
skynet_send(context, handle, G_NODE.monitor_exit, PTYPE_CLIENT, 0, NULL, 0);
|
skynet_send(context, handle, G_NODE.monitor_exit, PTYPE_CLIENT, 0, NULL, 0);
|
||||||
|
skynet_error(context, "KILL :%0x", handle);
|
||||||
}
|
}
|
||||||
skynet_handle_retire(handle);
|
skynet_handle_retire(handle);
|
||||||
}
|
}
|
||||||
@@ -476,7 +479,6 @@ skynet_command(struct skynet_context * context, const char * cmd , const char *
|
|||||||
args = strsep(&args, "\r\n");
|
args = strsep(&args, "\r\n");
|
||||||
struct skynet_context * inst = skynet_context_new(mod,args);
|
struct skynet_context * inst = skynet_context_new(mod,args);
|
||||||
if (inst == NULL) {
|
if (inst == NULL) {
|
||||||
fprintf(stderr, "Launch %s %s failed\n",mod,args);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
_id_to_hex(context->result, inst->handle);
|
_id_to_hex(context->result, inst->handle);
|
||||||
|
|||||||
Reference in New Issue
Block a user