Skip to content

Commit fe29cfd

Browse files
HirakawaTakaraJSeimizu
authored andcommitted
Clean up module if mmap error occured and add more log information
1 parent 667090b commit fe29cfd

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/libevp-agent/module_impl_obj.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ module_impl_obj_load(struct module *m, const struct Module *modspec)
114114
return EINVAL;
115115
}
116116
} else if (ret != ENOENT) {
117+
/* Clean up the module if some IO error occurs. */
118+
plat_mod_fs_file_unlink(m);
119+
117120
/* some IO error in check_hash */
118121
return ret;
119122
}

src/libevp-agent/platform.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ plat_mod_fs_file_mmap(struct module *module, const void **data, size_t *size,
135135
struct stat sb;
136136
if (fstat(fd, &sb) == -1) {
137137
*error = errno;
138-
xlog_error("%s: error on stat: %d", __func__, *error);
138+
xlog_error("%s: error on stat %s(%d): errno=%d", __func__,
139+
filename, fd, *error);
139140
goto failure;
140141
}
141142

@@ -145,7 +146,8 @@ plat_mod_fs_file_mmap(struct module *module, const void **data, size_t *size,
145146

146147
if (addr == MAP_FAILED) {
147148
*error = errno;
148-
xlog_error("%s: error on mmap: %d", __func__, errno);
149+
xlog_error("%s: error on mmap %s(%d): errno=%d, st_size=%zu",
150+
__func__, filename, fd, errno, sb.st_size);
149151
goto failure;
150152
}
151153

0 commit comments

Comments
 (0)