session id always be positive

This commit is contained in:
云风
2013-08-02 10:45:00 +08:00
parent 1d0d2678ed
commit 6be6a8171f
2 changed files with 29 additions and 23 deletions

View File

@@ -127,7 +127,8 @@ skynet_context_new(const char * name, const char *param) {
int
skynet_context_newsession(struct skynet_context *ctx) {
int session = ++ctx->session_id;
// session always be a positive number
int session = (++ctx->session_id) & 0x7fffffff;
return session;
}
@@ -353,8 +354,6 @@ skynet_command(struct skynet_context * context, const char * cmd , const char *
char * session_ptr = NULL;
int ti = strtol(param, &session_ptr, 10);
int session = skynet_context_newsession(context);
if (session < 0)
return NULL;
skynet_timeout(context->handle, ti, session);
sprintf(context->result, "%d", session);
return context->result;