summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
f9fc407)
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>
/* allocates the job */
job = free_jobs;
/* allocates the job */
job = free_jobs;
+ if (job)
+ free_jobs = job->next;
+ else {
pthread_mutex_unlock(&mutex);
job = malloc(sizeof *job);
pthread_mutex_lock(&mutex);
pthread_mutex_unlock(&mutex);
job = malloc(sizeof *job);
pthread_mutex_lock(&mutex);
}
/* terminate all the threads and all pending requests */
}
/* terminate all the threads and all pending requests */
+void jobs_terminate(int wait)
{
struct job *job;
pthread_t me, other;
{
struct job *job;
pthread_t me, other;
extern int jobs_init(int allowed_count, int start_count, int waiter_count);
extern int jobs_add_me();
extern int jobs_init(int allowed_count, int start_count, int waiter_count);
extern int jobs_add_me();
-extern void jobs_terminate();
+extern void jobs_terminate(int wait);
#include <afb/afb-req-itf.h>
#include "../afb-thread.h"
#include <afb/afb-req-itf.h>
#include "../afb-thread.h"
struct timespec ts;
req.itf = &itf;
struct timespec ts;
req.itf = &itf;
+ jobs_init(4, 0, 20000);
for (i = 0 ; i < 10000 ; i++) {
req.closure = foo = malloc(sizeof *foo);
foo->value = i;
foo->refcount = 1;
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;
unref(foo);
ts.tv_sec = 0;
ts.tv_nsec = 1000000;
ts.tv_sec = 1;
ts.tv_nsec = 0;
nanosleep(&ts, NULL);
ts.tv_sec = 1;
ts.tv_nsec = 0;
nanosleep(&ts, NULL);
- afb_thread_terminate();
-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