X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=libringbuffer%2Fshm.c;h=d1e50449678f7e6092e2a9d37c3279f767f51aa7;hb=18fc8d7163331ebf5fabd2e638c0b3e52cd40e53;hp=781295beb718c69057fb9ba54e89916fba5ad00c;hpb=7a7849896a95db678d916ccb7c5d91371828e3f8;p=lttng-ust.git diff --git a/libringbuffer/shm.c b/libringbuffer/shm.c index 781295be..d1e50449 100644 --- a/libringbuffer/shm.c +++ b/libringbuffer/shm.c @@ -1,9 +1,21 @@ /* * libringbuffer/shm.c * - * Copyright 2011 (c) - Mathieu Desnoyers + * Copyright (C) 2005-2012 Mathieu Desnoyers * - * Dual LGPL v2.1/GPL v2 license. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; only + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "shm.h" @@ -17,6 +29,8 @@ #include #include #include +#include +#include struct shm_object_table *shm_object_table_create(size_t max_nb_obj) { @@ -34,7 +48,7 @@ struct shm_object *shm_object_table_append(struct shm_object_table *table, int shmfd, waitfd[2], ret, i, sigblocked = 0; struct shm_object *obj; char *memory_map; - char tmp_name[NAME_MAX] = "ust-shm-tmp-XXXXXX"; + char tmp_name[NAME_MAX] = "/ust-shm-tmp-XXXXXX"; sigset_t all_sigs, orig_sigs; if (table->allocated_len >= table->size) @@ -210,10 +224,12 @@ void shmp_object_destroy(struct shm_object *obj) assert(0); } } - ret = close(obj->shm_fd); - if (ret) { - PERROR("close"); - assert(0); + if (obj->shm_fd >= 0) { + ret = close(obj->shm_fd); + if (ret) { + PERROR("close"); + assert(0); + } } for (i = 0; i < 2; i++) { if (obj->wait_fd[i] < 0)