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