mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-23 19:43:09 +00:00
@@ -1,3 +1,10 @@
|
||||
v0.2.1 (2014-5-19)
|
||||
-----------
|
||||
* Bugfix: check all the events already read after socket close
|
||||
* Bugfix: socket data in gate service
|
||||
* Bugfix: boundary problem in harbor service
|
||||
* Bugfix: stdin handle is 0
|
||||
|
||||
v0.2.0 (2014-5-12)
|
||||
-----------
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ function socket.bind(os_fd)
|
||||
end
|
||||
|
||||
function socket.stdin()
|
||||
return socket.bind(1)
|
||||
return socket.bind(0)
|
||||
end
|
||||
|
||||
function socket.start(id, func)
|
||||
|
||||
@@ -106,7 +106,7 @@ mallctl_int64(const char* name, size_t* newval) {
|
||||
} else {
|
||||
je_mallctl(name, &v, &len, NULL, 0);
|
||||
}
|
||||
// printf("name: %s, value: %zd\n", name, v);
|
||||
// skynet_error(NULL, "name: %s, value: %zd\n", name, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -117,9 +117,9 @@ mallctl_opt(const char* name, int* newval) {
|
||||
if(newval) {
|
||||
int ret = je_mallctl(name, &v, &len, newval, sizeof(int));
|
||||
if(ret == 0) {
|
||||
printf("set new value(%d) for (%s) succeed\n", *newval, name);
|
||||
skynet_error(NULL, "set new value(%d) for (%s) succeed\n", *newval, name);
|
||||
} else {
|
||||
printf("set new value(%d) for (%s) failed: error -> %d\n", *newval, name, ret);
|
||||
skynet_error(NULL, "set new value(%d) for (%s) failed: error -> %d\n", *newval, name, ret);
|
||||
}
|
||||
} else {
|
||||
je_mallctl(name, &v, &len, NULL, 0);
|
||||
@@ -196,15 +196,15 @@ void
|
||||
dump_c_mem() {
|
||||
int i;
|
||||
size_t total = 0;
|
||||
printf("dump all service mem:\n");
|
||||
skynet_error(NULL, "dump all service mem:");
|
||||
for(i=0; i<SLOT_SIZE; i++) {
|
||||
mem_data* data = &mem_stats[i];
|
||||
if(data->handle != 0 && data->allocated != 0) {
|
||||
total += data->allocated;
|
||||
printf("0x%x -> %zdkb\n", data->handle, data->allocated >> 10);
|
||||
skynet_error(NULL, "0x%x -> %zdkb", data->handle, data->allocated >> 10);
|
||||
}
|
||||
}
|
||||
printf("+total: %zdkb\n",total >> 10);
|
||||
skynet_error(NULL, "+total: %zdkb",total >> 10);
|
||||
}
|
||||
|
||||
char *
|
||||
|
||||
@@ -13,12 +13,13 @@
|
||||
#define PTYPE_SYSTEM 4
|
||||
#define PTYPE_HARBOR 5
|
||||
#define PTYPE_SOCKET 6
|
||||
// read lualib/skynet.lua lualib/simplemonitor.lua
|
||||
// read lualib/skynet.lua examples/simplemonitor.lua
|
||||
#define PTYPE_ERROR 7
|
||||
// read lualib/skynet.lua lualib/mqueue.lua
|
||||
// read lualib/skynet.lua lualib/mqueue.lua lualib/snax.lua
|
||||
#define PTYPE_RESERVED_QUEUE 8
|
||||
#define PTYPE_RESERVED_DEBUG 9
|
||||
#define PTYPE_RESERVED_LUA 10
|
||||
#define PTYPE_RESERVED_SNAX 11
|
||||
|
||||
#define PTYPE_TAG_DONTCOPY 0x10000
|
||||
#define PTYPE_TAG_ALLOCSESSION 0x20000
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#define DEFAULT_SLOT_SIZE 4
|
||||
#define MAX_SLOT_SIZE 0x40000000
|
||||
|
||||
struct handle_name {
|
||||
char * name;
|
||||
@@ -168,6 +169,7 @@ static void
|
||||
_insert_name_before(struct handle_storage *s, char *name, uint32_t handle, int before) {
|
||||
if (s->name_count >= s->name_cap) {
|
||||
s->name_cap *= 2;
|
||||
assert(s->name_cap <= MAX_SLOT_SIZE);
|
||||
struct handle_name * n = skynet_malloc(s->name_cap * sizeof(struct handle_name));
|
||||
int i;
|
||||
for (i=0;i<before;i++) {
|
||||
|
||||
@@ -815,6 +815,22 @@ report_accept(struct socket_server *ss, struct socket *s, struct socket_message
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
clear_closed_event(struct socket_server *ss, struct socket_message * result, int type) {
|
||||
if (type == SOCKET_CLOSE || type == SOCKET_ERROR) {
|
||||
int id = result->id;
|
||||
int i;
|
||||
for (i=ss->event_index; i<ss->event_n; i++) {
|
||||
struct event *e = &ss->ev[i];
|
||||
struct socket *s = e->s;
|
||||
if (s) {
|
||||
if (s->type == SOCKET_TYPE_INVALID && s->id == id) {
|
||||
e->s = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return type
|
||||
int
|
||||
@@ -823,9 +839,10 @@ socket_server_poll(struct socket_server *ss, struct socket_message * result, int
|
||||
if (ss->checkctrl) {
|
||||
if (has_cmd(ss)) {
|
||||
int type = ctrl_cmd(ss, result);
|
||||
if (type != -1)
|
||||
if (type != -1) {
|
||||
clear_closed_event(ss, result, type);
|
||||
return type;
|
||||
else
|
||||
} else
|
||||
continue;
|
||||
} else {
|
||||
ss->checkctrl = 0;
|
||||
@@ -865,12 +882,14 @@ socket_server_poll(struct socket_server *ss, struct socket_message * result, int
|
||||
int type = send_buffer(ss, s, result);
|
||||
if (type == -1)
|
||||
break;
|
||||
clear_closed_event(ss, result, type);
|
||||
return type;
|
||||
}
|
||||
if (e->read) {
|
||||
int type = forward_message(ss, s, result);
|
||||
if (type == -1)
|
||||
break;
|
||||
clear_closed_event(ss, result, type);
|
||||
return type;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
local skynet = require "skynet"
|
||||
local mqueue = require "mqueue"
|
||||
|
||||
skynet.start(function()
|
||||
local id = 0
|
||||
local pingserver = skynet.newservice "pingserver"
|
||||
mqueue.register(function(str)
|
||||
id = id + 1
|
||||
str = string.format("id = %d , %s",id, str)
|
||||
return skynet.call(pingserver, "lua", "PING", str)
|
||||
end)
|
||||
end)
|
||||
Reference in New Issue
Block a user