fix a bunch of coverity issues (#221)

Co-authored-by: reshke <Kirill Reshke>
This commit is contained in:
kirill reshke 2020-10-22 16:01:18 +05:00 committed by GitHub
parent 231e7ccac6
commit 3f23832dd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 16 deletions

View File

@ -101,11 +101,11 @@ od_client_free(od_client_t *client)
free(client);
}
static inline void
static inline od_retcode_t
od_client_notify_read(od_client_t *client)
{
uint64_t value;
machine_read_raw(client->notify_io, &value, sizeof(value));
return machine_read_raw(client->notify_io, &value, sizeof(value));
}
static inline void

View File

@ -212,7 +212,7 @@ od_config_validate(od_config_t *config, od_logger_t *logger)
}
if (config->enable_online_restart_feature && !config->bindwith_reuseport) {
od_dbg_printf_on_dvl_lvl(1, "validation error detected\n", "");
od_dbg_printf_on_dvl_lvl(1, "validation error detected %s\n", "");
od_error(logger,
"config",
NULL,

View File

@ -55,14 +55,18 @@ od_counter_create(size_t sz)
}
t->bucket_mutex = malloc(sizeof(pthread_mutex_t) * sz);
if (t->bucket_mutex == NULL) {
free(t);
return NULL;
}
t->size = sz;
for (size_t i = 0; i < t->size; ++i) {
t->buckets[i] = od_counter_llist_create();
if (t->buckets[i] == NULL)
if (t->buckets[i] == NULL) {
free(t->bucket_mutex);
free(t);
return NULL;
}
const int res = pthread_mutex_init(&t->bucket_mutex[i], NULL);
if (res) {
return NULL;

View File

@ -17,8 +17,11 @@ od_err_logger_create(size_t intervals_count)
for (size_t i = 0; i < intervals_count; ++i) {
err_logger->interval_counters[i] = od_counter_create_default();
if (err_logger->interval_counters[i] == NULL)
if (err_logger->interval_counters[i] == NULL) {
free(err_logger->interval_counters);
free(err_logger);
return NULL;
}
}
pthread_mutex_init(&err_logger->lock, NULL);

View File

@ -373,4 +373,4 @@ merge(td_histogram_t *h)
h->merged_count = total_count;
h->unmerged_nodes = 0;
h->unmerged_count = 0;
}
}

View File

@ -60,6 +60,7 @@ od_watchdog_worker(void *arg)
} else {
kill(instance->pid.pid, SIGKILL);
}
close(fd_ctrl);
return;
}
@ -96,7 +97,7 @@ od_watchdog_worker(void *arg)
}
flock(fd_exec, LOCK_UN | LOCK_NB);
/* request out own process to shutdown */
/* request our own process to shutdown */
kill(instance->pid.pid, OD_SIG_GRACEFUL_SHUTDOWN);
return;
}

View File

@ -1,6 +1,7 @@
#ifndef ODYSSEY_WORKER_POOL_H
#define ODYSSEY_WORKER_POOL_H
#include <macro.h>
/*
* Odyssey.
*
@ -67,15 +68,7 @@ od_worker_pool_wait(od_worker_pool_t *pool)
if (!is_shared)
return;
// In fact we cannot wait anything here - machines may be in epoll waiting
// No new TLS handshakes should be initiated, so, just wait a bit.
machine_sleep(1);
/*
for (int i = 0; i < pool->count; i++) {
od_worker_t *worker = &pool->pool[i];
machine_wait(worker->machine);
}
*/
}
static inline void
@ -93,7 +86,9 @@ od_worker_pool_wait_gracefully_shutdown(od_worker_pool_t *pool)
// machine_sleep(1);
for (int i = 0; i < pool->count; i++) {
od_worker_t *worker = &pool->pool[i];
machine_wait(worker->machine);
int rc = machine_wait(worker->machine);
if (rc != MM_OK_RETCODE)
return;
}
}