mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
bugfix: connection forward
This commit is contained in:
@@ -114,7 +114,6 @@ _poll(struct connection_server * server) {
|
||||
continue;
|
||||
}
|
||||
if (size == 0) {
|
||||
printf("disconnect\n");
|
||||
free(buffer);
|
||||
skynet_send(server->ctx, NULL, c->addr, 0x7fffffff, NULL, 0, DONTCOPY);
|
||||
} else {
|
||||
@@ -140,7 +139,7 @@ _main(struct skynet_context * ctx, void * ud, int session, const char * uid, con
|
||||
int addr_sz = sz - (endptr - (char *)msg);
|
||||
char * addr = malloc(addr_sz);
|
||||
memcpy(addr, endptr+1, addr_sz-1);
|
||||
addr[addr_sz] = '\0';
|
||||
addr[addr_sz-1] = '\0';
|
||||
_add(ud, fd, addr);
|
||||
} else if (memcmp(msg, "DEL ", 4)==0) {
|
||||
char * endptr;
|
||||
|
||||
@@ -16,7 +16,7 @@ skynet.start(function()
|
||||
print("simpledb",db)
|
||||
local connection = skynet.launch("connection","256")
|
||||
print("connection",connection)
|
||||
local redis = skynet.call(".launcher", "broker .redis snlua redis-cli 127.0.0.1:6379")
|
||||
local redis = skynet.call(".launcher", "broker .redis snlua redis-cli 127.0.0.1:6379 0")
|
||||
print("redis",redis)
|
||||
skynet.exit()
|
||||
end)
|
||||
|
||||
@@ -5,7 +5,7 @@ local table = table
|
||||
local tonumber = tonumber
|
||||
local ipairs = ipairs
|
||||
local unpack = unpack
|
||||
local redis_server = ...
|
||||
local redis_server, redis_db = ...
|
||||
|
||||
local function compose_message(msg)
|
||||
local lines = { "*" .. #msg }
|
||||
@@ -19,8 +19,17 @@ local function compose_message(msg)
|
||||
return cmd
|
||||
end
|
||||
|
||||
local function select_db(id)
|
||||
local result , ok = skynet.call(skynet.self(), skynet.unpack, skynet.pack("SELECT", tostring(id)))
|
||||
assert(result and ok == "OK")
|
||||
print("select",id)
|
||||
end
|
||||
|
||||
local function init()
|
||||
socket.connect(redis_server)
|
||||
if redis_db then
|
||||
select_db(redis_db)
|
||||
end
|
||||
end
|
||||
|
||||
local request_queue = { head = 1, tail = 1 }
|
||||
|
||||
@@ -394,7 +394,11 @@ remote_query_harbor(int harbor_id) {
|
||||
char tmp2[sz+1];
|
||||
memcpy(tmp2,zmq_msg_data(&reply),sz);
|
||||
tmp2[sz] = '\0';
|
||||
_remote_harbor_update(harbor_id, tmp2);
|
||||
if (sz == 0) {
|
||||
skynet_error(NULL,"Request harbor %d failed",harbor_id);
|
||||
} else {
|
||||
_remote_harbor_update(harbor_id, tmp2);
|
||||
}
|
||||
zmq_msg_close(&reply);
|
||||
}
|
||||
|
||||
|
||||
@@ -263,6 +263,13 @@ skynet_command(struct skynet_context * context, const char * cmd , const char *
|
||||
return skynet_handle_namehandle(context->handle, param + 1);
|
||||
} else {
|
||||
assert(context->handle!=0);
|
||||
int i;
|
||||
for (i=0;i<param[i];i++) {
|
||||
if (!(param[i] >= '0' && param[i] <= '9')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(param[i]);
|
||||
skynet_harbor_register(param, context->handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user