#include "eal_internal_cfg.h"
static int mp_fd = -1;
+static pthread_t mp_handle_tid;
static char mp_filter[PATH_MAX]; /* Filter for secondary process sockets */
static char mp_dir_path[PATH_MAX]; /* The directory path for all mp sockets */
static pthread_mutex_t mp_mutex_action = PTHREAD_MUTEX_INITIALIZER;
struct mp_msg_internal msg;
struct sockaddr_un sa;
- while (1) {
+ while (mp_fd >= 0) {
if (read_msg(&msg, &sa) == 0)
process_msg(&msg, &sa);
}
struct pending_request *req = (struct pending_request *)arg;
enum async_action action;
struct timespec ts_now;
- struct timeval now;
- if (gettimeofday(&now, NULL) < 0) {
+ if (clock_gettime(CLOCK_MONOTONIC, &ts_now) < 0) {
RTE_LOG(ERR, EAL, "Cannot get current time\n");
goto no_trigger;
}
- ts_now.tv_nsec = now.tv_usec * 1000;
- ts_now.tv_sec = now.tv_sec;
action = process_async_request(req, &ts_now);
}
static void
-close_socket_fd(void)
+close_socket_fd(int fd)
{
char path[PATH_MAX];
- if (mp_fd < 0)
- return;
-
- close(mp_fd);
+ close(fd);
create_socket_path(peer_name, path, sizeof(path));
unlink(path);
}
{
char path[PATH_MAX];
int dir_fd;
- pthread_t mp_handle_tid;
const struct internal_config *internal_conf =
eal_get_internal_configuration();
void
rte_mp_channel_cleanup(void)
{
- close_socket_fd();
+ int fd;
+
+ if (mp_fd < 0)
+ return;
+
+ fd = mp_fd;
+ mp_fd = -1;
+ pthread_cancel(mp_handle_tid);
+ pthread_join(mp_handle_tid, NULL);
+ close_socket_fd(fd);
}
/**
struct rte_mp_reply *reply, const struct timespec *ts)
{
int ret;
+ pthread_condattr_t attr;
struct rte_mp_msg msg, *tmp;
struct pending_request pending_req, *exist;
strlcpy(pending_req.dst, dst, sizeof(pending_req.dst));
pending_req.request = req;
pending_req.reply = &msg;
- pthread_cond_init(&pending_req.sync.cond, NULL);
+ pthread_condattr_init(&attr);
+ pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
+ pthread_cond_init(&pending_req.sync.cond, &attr);
exist = find_pending_request(dst, req->name);
if (exist) {
int dir_fd, ret = -1;
DIR *mp_dir;
struct dirent *ent;
- struct timeval now;
- struct timespec end;
+ struct timespec now, end;
const struct internal_config *internal_conf =
eal_get_internal_configuration();
return -1;
}
- if (gettimeofday(&now, NULL) < 0) {
+ if (clock_gettime(CLOCK_MONOTONIC, &now) < 0) {
RTE_LOG(ERR, EAL, "Failed to get current time\n");
rte_errno = errno;
goto end;
}
- end.tv_nsec = (now.tv_usec * 1000 + ts->tv_nsec) % 1000000000;
+ end.tv_nsec = (now.tv_nsec + ts->tv_nsec) % 1000000000;
end.tv_sec = now.tv_sec + ts->tv_sec +
- (now.tv_usec * 1000 + ts->tv_nsec) / 1000000000;
+ (now.tv_nsec + ts->tv_nsec) / 1000000000;
/* for secondary process, send request to the primary process only */
if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
int dir_fd, ret = 0;
DIR *mp_dir;
struct dirent *ent;
- struct timeval now;
+ struct timespec now;
struct timespec *end;
bool dummy_used = false;
const struct internal_config *internal_conf =
return -1;
}
- if (gettimeofday(&now, NULL) < 0) {
+ if (clock_gettime(CLOCK_MONOTONIC, &now) < 0) {
RTE_LOG(ERR, EAL, "Failed to get current time\n");
rte_errno = errno;
return -1;
end = ¶m->end;
reply = ¶m->user_reply;
- end->tv_nsec = (now.tv_usec * 1000 + ts->tv_nsec) % 1000000000;
+ end->tv_nsec = (now.tv_nsec + ts->tv_nsec) % 1000000000;
end->tv_sec = now.tv_sec + ts->tv_sec +
- (now.tv_usec * 1000 + ts->tv_nsec) / 1000000000;
+ (now.tv_nsec + ts->tv_nsec) / 1000000000;
reply->nb_sent = 0;
reply->nb_received = 0;
reply->msgs = NULL;