app/trace: exit if shm mmap fails
Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Icbe76cafddf5bd1e457c87e8241e68cb18a044dd
This commit is contained in:
parent
57986fb884
commit
21ceba8855
@ -360,13 +360,21 @@ int main(int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
snprintf(shm_name, sizeof(shm_name), "/%s_trace.pid%d", app_name, shm_pid);
|
snprintf(shm_name, sizeof(shm_name), "/%s_trace.pid%d", app_name, shm_pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = shm_open(shm_name, O_RDONLY, 0600);
|
fd = shm_open(shm_name, O_RDONLY, 0600);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf(stderr, "Could not open shm %s.\n", shm_name);
|
fprintf(stderr, "Could not open shm %s.\n", shm_name);
|
||||||
usage();
|
usage();
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
history_ptr = mmap(NULL, sizeof(*g_histories), PROT_READ, MAP_SHARED, fd, 0);
|
history_ptr = mmap(NULL, sizeof(*g_histories), PROT_READ, MAP_SHARED, fd, 0);
|
||||||
|
if (history_ptr == MAP_FAILED) {
|
||||||
|
fprintf(stderr, "Could not mmap shm %s.\n", shm_name);
|
||||||
|
usage();
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
g_histories = (struct spdk_trace_histories *)history_ptr;
|
g_histories = (struct spdk_trace_histories *)history_ptr;
|
||||||
|
|
||||||
tsc_rate = g_histories->tsc_rate;
|
tsc_rate = g_histories->tsc_rate;
|
||||||
|
Loading…
Reference in New Issue
Block a user