Git Product home page Git Product logo

ltask's People

Contributors

actboy168 avatar cabriter avatar cloudwu avatar gowa2017 avatar hanxi avatar haoyu234 avatar iwifigame avatar kinbei avatar rondsny avatar sniper00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ltask's Issues

WSL Ubuntu 18.04 gcc 7.5 build failed

cc -g -Wall --shared -I/mnt/d/GitProjects/ltask/3rd/lua -Isrc -o ltask.dll src/ltask.c src/queue.c src/sysinfo.c src/service.c src/config.c src/lua-seri.c src/message.c src/systime.c src/timer.c src/sysapi.c -L/usr/local/bin -llua54
In file included from src/ltask.c:16:0:
src/timer.h:11:16: error: conflicting types for ‘timer_create’
 struct timer * timer_create();
                ^~~~~~~~~~~~
In file included from /usr/include/pthread.h:24:0,
                 from src/thread.h:75,
                 from src/ltask.c:10:
/usr/include/time.h:240:12: note: previous declaration of ‘timer_create’ was here
 extern int timer_create (clockid_t __clock_id,
            ^~~~~~~~~~~~
src/ltask.c: In function ‘luaseri_remove’:
src/ltask.c:895:2: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration]
  free(data);
  ^~~~
src/ltask.c:895:2: warning: incompatible implicit declaration of built-in function ‘free’
src/ltask.c:895:2: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
src/ltask.c: In function ‘lunpack_remove’:
src/ltask.c:914:2: warning: incompatible implicit declaration of built-in function ‘free’
  free(msg);
  ^~~~
src/ltask.c:914:2: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
In file included from src/atomic.h:76:0,
                 from src/queue.h:4,
                 from src/queue.c:1:
src/atomic.h: In function ‘atomic_ptr_init’:
src/atomic.h:113:21: error: ‘uintptr_t’ undeclared (first use in this function); did you mean ‘__uint128_t’?
  atomic_init(aptr, (uintptr_t)v);
                     ^
src/atomic.h:113:21: note: each undeclared identifier is reported only once for each function it appears in
src/atomic.h:113:31: error: expected ‘)’ before ‘v’
  atomic_init(aptr, (uintptr_t)v);
                               ^
src/atomic.h: In function ‘atomic_ptr_store’:
src/atomic.h:123:22: error: ‘uintptr_t’ undeclared (first use in this function); did you mean ‘__uint128_t’?
  atomic_store(aptr, (uintptr_t)v);
                      ^
src/atomic.h:123:32: error: expected ‘)’ before ‘v’
  atomic_store(aptr, (uintptr_t)v);
                                ^
In file included from src/queue.h:4:0,
                 from src/queue.c:1:
src/atomic.h: In function ‘atomic_ptr_cas’:
src/atomic.h:128:2: error: unknown type name ‘uintptr_t’; did you mean ‘__uint128_t’?
  uintptr_t temp = (uintptr_t)oval;
  ^~~~~~~~~
  __uint128_t
src/atomic.h:128:20: error: ‘uintptr_t’ undeclared (first use in this function); did you mean ‘__uint128_t’?
  uintptr_t temp = (uintptr_t)oval;
                    ^~~~~~~~~
                    __uint128_t
src/atomic.h:128:30: error: expected ‘,’ or ‘;’ before ‘oval’
  uintptr_t temp = (uintptr_t)oval;
                              ^~~~
In file included from src/atomic.h:76:0,
                 from src/queue.h:4,
                 from src/queue.c:1:
src/atomic.h:129:62: error: expected ‘)’ before ‘nval’
  return atomic_compare_exchange_weak(aptr, &temp, (uintptr_t)nval);
                                                              ^
src/atomic.h:129:9: error: size mismatch in argument 2 of ‘__atomic_compare_exchange’
  return atomic_compare_exchange_weak(aptr, &temp, (uintptr_t)nval);
         ^
In file included from src/atomic.h:76:0,
                 from src/queue.h:4,
                 from src/service.c:2:
src/atomic.h: In function ‘atomic_ptr_init’:
src/atomic.h:113:21: error: ‘uintptr_t’ undeclared (first use in this function); did you mean ‘__uint128_t’?
  atomic_init(aptr, (uintptr_t)v);
                     ^
src/atomic.h:113:21: note: each undeclared identifier is reported only once for each function it appears in
src/atomic.h:113:31: error: expected ‘)’ before ‘v’
  atomic_init(aptr, (uintptr_t)v);
                               ^
src/atomic.h: In function ‘atomic_ptr_store’:
src/atomic.h:123:22: error: ‘uintptr_t’ undeclared (first use in this function); did you mean ‘__uint128_t’?
  atomic_store(aptr, (uintptr_t)v);
                      ^
src/atomic.h:123:32: error: expected ‘)’ before ‘v’
  atomic_store(aptr, (uintptr_t)v);
                                ^
In file included from src/queue.h:4:0,
                 from src/service.c:2:
src/atomic.h: In function ‘atomic_ptr_cas’:
src/atomic.h:128:2: error: unknown type name ‘uintptr_t’; did you mean ‘__uint128_t’?
  uintptr_t temp = (uintptr_t)oval;
  ^~~~~~~~~
  __uint128_t
src/atomic.h:128:20: error: ‘uintptr_t’ undeclared (first use in this function); did you mean ‘__uint128_t’?
  uintptr_t temp = (uintptr_t)oval;
                    ^~~~~~~~~
                    __uint128_t
src/atomic.h:128:30: error: expected ‘,’ or ‘;’ before ‘oval’
  uintptr_t temp = (uintptr_t)oval;
                              ^~~~
In file included from src/atomic.h:76:0,
                 from src/queue.h:4,
                 from src/service.c:2:
src/atomic.h:129:62: error: expected ‘)’ before ‘nval’
  return atomic_compare_exchange_weak(aptr, &temp, (uintptr_t)nval);
                                                              ^
src/atomic.h:129:9: error: size mismatch in argument 2 of ‘__atomic_compare_exchange’
  return atomic_compare_exchange_weak(aptr, &temp, (uintptr_t)nval);
         ^
In file included from src/timer.c:3:0:
src/timer.h:11:16: error: conflicting types for ‘timer_create’
 struct timer * timer_create();
                ^~~~~~~~~~~~
In file included from /usr/include/pthread.h:24:0,
                 from src/spinlock.h:43,
                 from src/timer.c:1:
/usr/include/time.h:240:12: note: previous declaration of ‘timer_create’ was here
 extern int timer_create (clockid_t __clock_id,
            ^~~~~~~~~~~~
src/timer.c:162:1: error: conflicting types for ‘timer_create’
 timer_create() {
 ^~~~~~~~~~~~
In file included from /usr/include/pthread.h:24:0,
                 from src/spinlock.h:43,
                 from src/timer.c:1:
/usr/include/time.h:240:12: note: previous declaration of ‘timer_create’ was here
 extern int timer_create (clockid_t __clock_id,
            ^~~~~~~~~~~~
src/sysapi.c: In function ‘sys_sleep’:
src/sysapi.c:13:9: error: ‘usec’ undeclared (first use in this function); did you mean ‘csec’?
  usleep(usec * 1000);
         ^~~~
         csec
src/sysapi.c:13:9: note: each undeclared identifier is reported only once for each function it appears in
Makefile:26: recipe for target 'ltask.dll' failed
make: *** [ltask.dll] Error 1

an error occurs in service/root.lua but no error log

在 service/root.lua 中增加 error("an error") 调用,运行示例无错误日志,然后进程退出。

看调用堆栈如下所示,当 service/root.lua 无论是语法报错还是运行加载函数报错,跑到 https://github.com/cloudwu/ltask/blob/master/service/service.lua#L303 这里来,但是没有任何实际的作用,不会打印错误日志。ps 即使把这里的 errobj 打印出来,也没有包含堆栈信息,也不方便定位错误。

-- 打印 errobj
stack traceback:
        ( service:1 )
        service/root.lua:13: in local 'f'
function sys_service.init ->中如下其中一个报错
  https://github.com/cloudwu/ltask/blob/master/service/service.lua#L811 报错
  https://github.com/cloudwu/ltask/blob/master/service/service.lua#L816 报错
local function system -> 
local function wakeup_session ->
local function resume_session(co, ...)
	running_thread = co
	local ok, errobj = coroutine.resume(co, ...)
	running_thread = nil
	if ok then
		return errobj
	else
		local from = session_coroutine_address[co]
		local session = session_coroutine_response[co]

		-- term session
		session_coroutine_address[co] = nil
		session_coroutine_response[co] = nil

		errobj = traceback(errobj, co)
		if from == nil or from == 0 then
			-- system message
			print(tostring(errobj))
		else
			ltask.error(from, session, errobj)  -- 没有任何作用
		end
		coroutine.close(co)
	end
end

有概率出现日志输出服务的 label 为 nil 了

输出结果如下:

d:\work\ltask>lua main.lua examples\timer\config
[Mon Sep 20 00:34:29 2021.91 : system    ]      ltask Start
[Mon Sep 20 00:34:29 2021.92 : nil       ]      Bootstrap Begin
[Mon Sep 20 00:34:29 2021.92 : nil       ]      Mon Sep 20 00:34:29 2021
[Mon Sep 20 00:34:29 2021.92 : nil       ]      User init :     Hello
[Mon Sep 20 00:34:29 2021.92 : nil       ]      Spawn user      5
[Mon Sep 20 00:34:29 2021.92 : nil       ]      ERR     4       Error : 5
stack traceback:
        ( service:5 )
        examples/timer/user.lua:9: in local 's'
        ( service:4 )
        examples/timer/bootstrap.lua:18: in local 'f'
[Mon Sep 20 00:34:30 2021.02 : nil       ]      REQ     3       10
[Mon Sep 20 00:34:30 2021.13 : nil       ]      REQ     2       20
[Mon Sep 20 00:34:30 2021.27 : nil       ]      1
[Mon Sep 20 00:34:30 2021.38 : nil       ]      2
[Mon Sep 20 00:34:30 2021.47 : nil       ]      3
[Mon Sep 20 00:34:30 2021.58 : nil       ]      PING    PONG
[Mon Sep 20 00:34:30 2021.58 : nil       ]      true
[Mon Sep 20 00:34:30 2021.58 : nil       ]      true
[Mon Sep 20 00:34:30 2021.58 : nil       ]      Bootstrap End
[Mon Sep 20 00:34:30 2021.58 : nil       ]      User exit

独占线程处理sending队列时,同一个服务的消息会不会出现乱序

  1. 假如 sending 队列要发送消息到 服务 S ,顺序是:a,b,c,d,e
  2. 发送 a 时,S blocked, a 被放到 e 后边
  3. 发送 b 时,S 变为非blocked, 这样 b 就先于 a 被处理了

queue_push_ptr(sending, msg);

static void
dispatch_exclusive_sending(struct exclusive_thread *e, struct queue *sending) {
	struct ltask *task = e->task;
	struct service_pool *P = task->services;
	int len = queue_length(sending);
	int i;
	for (i=0;i<len;i++) {
		struct message *msg = (struct message *)queue_pop_ptr(sending);
		switch (service_push_message(P, msg->to, msg)) {
		case 0 :	// succ
			break;
		case 1 :	// block, push back
			queue_push_ptr(sending, msg);
			break;
		default :	// dead, delete message
			// todo : report somewhere or release object in message
			message_delete(msg);
			break;
		}
		if (service_status_get(P, msg->to) == SERVICE_STATUS_IDLE) {
			debug_printf(e->logger, "Service %x is in schedule", msg->to.id);
			service_status_set(P, msg->to, SERVICE_STATUS_SCHEDULE);
			schedule_back(task, msg->to);
		}
	}
}

当时间服务(timer)出错时,无任何输出

在service/timer.lua第三行添加error语句。再运行ltask例子。会卡住,也没有相应的错误信息输出。如下。

local ltask = require "ltask"
local exclusive = require "ltask.exclusive"
error("some error happened")

原因是print被改写成压入日志信息,而日志服务又依赖于时间服务来驱动读取日志,此时,时间服务没有正常启动。

worker 有时候会阻塞

不确定是不是以下原因:
worker 正要 sleep 的时候,这时 scheduler 给它安排新的 job,可能会造成 service_ready 有值且 sleeping == 1 的情况, 之后也无法唤醒了。

in function require_cmodule after luaL_requiref maybe better clear the top value

see https://github.com/cloudwu/ltask/blob/master/src/service.c#L295luaL_requiref 成功返回后,stack top 是 require 后的 module ,调用 lua_pop(L, 1) 清除掉这个不用的值似乎会更好一些,虽然对程序运行没有影响。

static int
require_cmodule(lua_State *L) {
	const char *name = (const char *)lua_touserdata(L, 1);
	lua_CFunction f = (lua_CFunction)lua_touserdata(L, 2);
	luaL_requiref(L, name, f, 0);
	return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.