Skip to content

Commit

Permalink
evanix: set thread name
Browse files Browse the repository at this point in the history
  • Loading branch information
sinanmohd committed Jul 17, 2024
1 parent 5d33ec0 commit fb21e08
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions src/evanix.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,27 @@ struct evanix_opts_t evanix_opts = {
.solver_report = false,
};

static int evanix_build_thread_create(struct build_thread *build_thread);
static int evanix(char *expr);

/* This function returns errno on failure, consistent with the POSIX threads
* functions, rather than returning -errno. */
static int evanix_build_thread_create(struct build_thread *build_thread)
{
int ret;

ret = pthread_create(&build_thread->tid, NULL, build_thread_entry,
build_thread);
if (ret != 0)
return ret;

ret = pthread_setname_np(build_thread->tid, "evanix_build");
if (ret != 0)
return ret;

return 0;
}

static int evanix(char *expr)
{
struct queue_thread *queue_thread = NULL;
Expand All @@ -58,33 +77,36 @@ static int evanix(char *expr)

ret = pthread_create(&queue_thread->tid, NULL, queue_thread_entry,
queue_thread);
if (ret < 0) {
if (ret != 0) {
print_err("%s", strerror(ret));
goto out_free;
}
ret = pthread_setname_np(queue_thread->tid, "evanix_queue");
if (ret != 0) {
print_err("%s", strerror(ret));
goto out_free;
}

if (evanix_opts.ispipelined)
ret = pthread_create(&build_thread->tid, NULL,
build_thread_entry, build_thread);
ret = evanix_build_thread_create(build_thread);
else
ret = pthread_join(queue_thread->tid, NULL);
if (ret < 0) {
if (ret != 0) {
print_err("%s", strerror(ret));
goto out_free;
}

if (evanix_opts.ispipelined)
ret = pthread_join(queue_thread->tid, NULL);
else
ret = pthread_create(&build_thread->tid, NULL,
build_thread_entry, build_thread);
if (ret < 0) {
ret = evanix_build_thread_create(build_thread);
if (ret != 0) {
print_err("%s", strerror(ret));
goto out_free;
}

ret = pthread_join(build_thread->tid, NULL);
if (ret < 0) {
if (ret != 0) {
print_err("%s", strerror(ret));
goto out_free;
}
Expand Down

0 comments on commit fb21e08

Please sign in to comment.