fix: correct valgrind errors

main
Sean McBride 4 years ago
parent 0892e98d76
commit eca987ccb4

@ -4,6 +4,7 @@
#include "types.h"
extern int runtime_epoll_file_descriptor;
extern u32 runtime_total_worker_processors;
void alloc_linear_memory(void);
void expand_memory(void);

@ -84,14 +84,16 @@ runtime_allocate_available_cores()
runtime_total_worker_processors = max_possible_workers;
if (max_possible_workers >= WORKER_THREAD_CORE_COUNT)
runtime_total_worker_processors = WORKER_THREAD_CORE_COUNT;
assert(runtime_total_worker_processors == WORKER_THREAD_CORE_COUNT);
} else {
/* If single core, we'll do everything on CPUID 0 */
runtime_first_worker_processor = 0;
runtime_total_worker_processors = 1;
}
debuglog("Number of cores %u, sandboxing cores %u (start: %u) and module reqs %u\n",
runtime_total_online_processors, runtime_total_worker_processors, runtime_first_worker_processor,
LISTENER_THREAD_CORE_ID);
printf("Number of cores %u, sandboxing cores %u (start: %u) and module reqs %u\n",
runtime_total_online_processors, runtime_total_worker_processors, runtime_first_worker_processor,
LISTENER_THREAD_CORE_ID);
}
/**

@ -257,8 +257,7 @@ module_new_from_json(char *file_name)
fprintf(stderr, "Attempt to read %s into buffer failed: %s\n", file_name, strerror(errno));
goto fread_err;
}
assert(strlen(file_buffer) > 1);
assert(total_chars_read > 0);
/* Close the file */
errno = 0;
@ -274,7 +273,7 @@ module_new_from_json(char *file_name)
jsmntok_t tokens[JSON_MAX_ELEMENT_SIZE * JSON_MAX_ELEMENT_COUNT];
/* Use Jasmine to parse the JSON */
int total_tokens = jsmn_parse(&module_parser, file_buffer, strlen(file_buffer), tokens,
int total_tokens = jsmn_parse(&module_parser, file_buffer, total_chars_read, tokens,
sizeof(tokens) / sizeof(tokens[0]));
if (total_tokens < 0) {
if (total_tokens == JSMN_ERROR_INVAL) {

@ -11,6 +11,7 @@
#include "current_sandbox.h"
#include "local_runqueue.h"
#include "module.h"
#include "runtime.h"
#include "sandbox.h"
#include "software_interrupt.h"
#include "types.h"
@ -66,9 +67,10 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
/* A POSIX signal is delivered to one of the threads in our process.If sent by the kernel, "broadcast"
* by forwarding to all all threads */
if (signal_info->si_code == SI_KERNEL) {
for (int i = 0; i < WORKER_THREAD_CORE_COUNT; i++) {
if (pthread_self() == runtime_worker_threads[i]) continue;
pthread_kill(runtime_worker_threads[i], SIGALRM);
for (int i = 0; i < runtime_total_worker_processors; i++) {
if (pthread_self() != runtime_worker_threads[i]) {
pthread_kill(runtime_worker_threads[i], SIGALRM);
}
}
} else {
/* If not sent by the kernel, this should be a signal forwarded from another thread */

Loading…
Cancel
Save