summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-03-28 10:18:06 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-03-28 10:21:06 +0200
commit48827b7b9862ab5961f938f38a8667e15421a50c (patch)
treeb3f2100155ae7adc2125ab93f162a8566f39d8af /src/tests
parentf9fc4077cc0eb167f3e65f54cc27717c79beee92 (diff)
Fix bug in recycling jobs
The bug was creating an infinite loop starving the system (or other possible horrific stuff). Also updated the test. Change-Id: Id71dd112d2ed4651ac8aa56d2c57b088d69b8655 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test-thread.c7
-rwxr-xr-xsrc/tests/test-thread.sh4
2 files changed, 6 insertions, 5 deletions
diff --git a/src/tests/test-thread.c b/src/tests/test-thread.c
index cc676bd0..2f0e1853 100644
--- a/src/tests/test-thread.c
+++ b/src/tests/test-thread.c
@@ -7,6 +7,7 @@
#include <afb/afb-req-itf.h>
#include "../afb-thread.h"
+#include "../jobs.h"
struct foo {
int value;
@@ -77,12 +78,12 @@ int main()
struct timespec ts;
req.itf = &itf;
- afb_thread_init(4, 1);
+ jobs_init(4, 0, 20000);
for (i = 0 ; i < 10000 ; i++) {
req.closure = foo = malloc(sizeof *foo);
foo->value = i;
foo->refcount = 1;
- afb_thread_call(req, process, 5, (&ts) + (i % 4));
+ afb_thread_req_call(req, process, 5, (&ts) + (i % 7));
unref(foo);
ts.tv_sec = 0;
ts.tv_nsec = 1000000;
@@ -91,7 +92,7 @@ int main()
ts.tv_sec = 1;
ts.tv_nsec = 0;
nanosleep(&ts, NULL);
- afb_thread_terminate();
+ jobs_terminate();
}
diff --git a/src/tests/test-thread.sh b/src/tests/test-thread.sh
index 6d1b3a53..d5186d19 100755
--- a/src/tests/test-thread.sh
+++ b/src/tests/test-thread.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-cc test-thread.c ../afb-thread.c ../verbose.c ../afb-sig-handler.c -o test-thread -lrt -lpthread -I../../include
-./test-thread
+cc test-thread.c ../afb-thread.c ../verbose.c ../sig-monitor.c ../jobs.c -o test-thread -lrt -lpthread -I../../include -g -O2
+gdb ./test-thread