Fix: remove unused align.h header
[lttng-ust.git] / libringbuffer / shm.c
index 8ac321e3931906888f79dd9e2419a7dbca8225de..7991d06fef6e93266f15c476e42be23768109958 100644 (file)
@@ -39,9 +39,6 @@
  * Ensure we have the required amount of space available by writing 0
  * into the entire buffer. Not doing so can trigger SIGBUS when going
  * beyond the available shm space.
- *
- * Also ensure the file metadata is synced with the storage by using
- * fsync(2).
  */
 static
 int zero_file(int fd, size_t len)
@@ -70,11 +67,6 @@ int zero_file(int fd, size_t len)
                }
                written += retlen;
        }
-       ret = fsync(fd);
-       if (ret) {
-               ret = (int) -errno;
-               goto error;
-       }
        ret = 0;
 error:
        free(zeropage);
@@ -142,6 +134,15 @@ struct shm_object *_shm_object_table_alloc_shm(struct shm_object_table *table,
                PERROR("ftruncate");
                goto error_ftruncate;
        }
+       /*
+        * Also ensure the file metadata is synced with the storage by using
+        * fsync(2).
+        */
+       ret = fsync(shmfd);
+       if (ret) {
+               PERROR("fsync");
+               goto error_fsync;
+       }
        obj->shm_fd_ownership = 0;
        obj->shm_fd = shmfd;
 
@@ -161,6 +162,7 @@ struct shm_object *_shm_object_table_alloc_shm(struct shm_object_table *table,
        return obj;
 
 error_mmap:
+error_fsync:
 error_ftruncate:
 error_zero_file:
 error_fcntl:
@@ -277,11 +279,6 @@ struct shm_object *shm_object_table_append_shm(struct shm_object_table *table,
        obj->shm_fd = shm_fd;
        obj->shm_fd_ownership = 1;
 
-       ret = fcntl(obj->wait_fd[1], F_SETFD, FD_CLOEXEC);
-       if (ret < 0) {
-               PERROR("fcntl");
-               goto error_fcntl;
-       }
        /* The write end of the pipe needs to be non-blocking */
        ret = fcntl(obj->wait_fd[1], F_SETFL, O_NONBLOCK);
        if (ret < 0) {
This page took 0.02402 seconds and 4 git commands to generate.