core: Fixed #121 Single mode crashes
This commit is contained in:
parent
341b221458
commit
cb3486eb7b
4 changed files with 15 additions and 0 deletions
|
@ -51,6 +51,10 @@ bool is_runner(void) {
|
|||
return is_current_process(g_current_proc);
|
||||
}
|
||||
|
||||
bool is_single_mode(void) {
|
||||
return g_current_proc == NULL;
|
||||
}
|
||||
|
||||
static void close_process(void *ptr, CR_UNUSED void *meta) {
|
||||
struct worker *proc = ptr;
|
||||
sfree(proc->ctx.suite_stats);
|
||||
|
|
|
@ -77,6 +77,7 @@ void run_worker(struct worker_context *ctx);
|
|||
void set_runner_process(void);
|
||||
void unset_runner_process(void);
|
||||
bool is_runner(void);
|
||||
bool is_single_mode(void);
|
||||
struct process_status wait_proc(struct worker *proc);
|
||||
struct worker *spawn_test_worker(struct execution_context *ctx, cr_worker_func func);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "compat/process.h"
|
||||
#include "core/worker.h"
|
||||
|
||||
#define URL "ipc://%scriterion_%llu.sock"
|
||||
|
||||
|
@ -61,6 +62,9 @@ error: {}
|
|||
}
|
||||
|
||||
int connect_client(void) {
|
||||
if (is_single_mode())
|
||||
return 0;
|
||||
|
||||
int sock = nn_socket(AF_SP, NN_REQ);
|
||||
if (sock < 0)
|
||||
return -1;
|
||||
|
@ -87,5 +91,8 @@ error: {}
|
|||
}
|
||||
|
||||
void close_socket(int sock) {
|
||||
if (is_single_mode())
|
||||
return;
|
||||
|
||||
nn_close(sock);
|
||||
}
|
||||
|
|
|
@ -80,6 +80,9 @@ const char *message_names[] = {
|
|||
};
|
||||
|
||||
void cr_send_to_runner(const criterion_protocol_msg *message) {
|
||||
if (is_single_mode())
|
||||
return;
|
||||
|
||||
if (write_message(g_client_socket, message) != 1) {
|
||||
criterion_perror("Could not write the \"%s\" message down the event pipe: %s.\n",
|
||||
message_names[message->data.which_value],
|
||||
|
|
Loading…
Add table
Reference in a new issue