Skip to content

Commit

Permalink
fix win build
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Du <[email protected]>
  • Loading branch information
frankdjx committed Nov 13, 2023
1 parent 71fa1a1 commit dd7fbbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/src/mt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

#include "mt_main.h"

#ifndef WINDOWSENV
#include <pwd.h>
#endif

#include "datapath/mt_queue.h"
#include "dev/mt_dev.h"
Expand Down Expand Up @@ -401,9 +403,13 @@ static int _mt_stop(struct mtl_main_impl* impl) {
}

static int mt_user_info_init(struct mtl_main_impl* impl) {
int ret;
int ret = -EIO;
struct mt_user_info* info = &impl->u_info;

#ifdef WINDOWSENV /* todo */
snprintf(info->hostname, sizeof(info->hostname), "%s", "unknow");
snprintf(info->user, sizeof(info->user), "%s", "unknow");
#else
ret = gethostname(info->hostname, sizeof(info->hostname));
if (ret < 0) {
warn("%s, gethostname fail %d\n", __func__, ret);
Expand All @@ -413,6 +419,7 @@ static int mt_user_info_init(struct mtl_main_impl* impl) {
struct passwd* user_info = getpwuid(uid);
snprintf(info->user, sizeof(info->user), "%s",
user_info ? user_info->pw_name : "unknow");
#endif

info->pid = getpid();

Expand Down
3 changes: 2 additions & 1 deletion lib/src/mt_sch.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ static int sch_lcore_shm_uinit(struct mt_lcore_mgr* mgr) {
err("%s, can not stat shared memory, %s\n", __func__, strerror(errno));
} else {
if (shmds.shm_nattch == 0) { /* remove ipc if we are the last user */
notice("%s, remove shared memory as we are the last user\n", __func__);
ret = shmctl(mgr->lcore_shm_id, IPC_RMID, NULL);
if (ret < 0) {
warn("%s, can not remove shared memory, %s\n", __func__, strerror(errno));
Expand Down Expand Up @@ -1039,7 +1040,7 @@ int mtl_lcore_shm_print(void) {
shm_entry = &lcore_shm->lcores_info[i];
if (shm_entry->active) {
info("%s, lcore %d active on %s@%s with pid: %d\n", __func__, i, shm_entry->user,
shm_entry->hostname, shm_entry->pid);
shm_entry->hostname, (int)shm_entry->pid);
}
}

Expand Down

0 comments on commit dd7fbbc

Please sign in to comment.