Close listen socket when done
[fio.git] / memory.c
index b94cd6df35feed843659bc9bf88921bf55ba9be4..82a79bd7175b9a74ca0846a669d767e06d50b84d 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -63,7 +63,7 @@ int fio_pin_memory(void)
 
 static int alloc_mem_shm(struct thread_data *td, unsigned int total_mem)
 {
-       int flags = IPC_CREAT | SHM_R | SHM_W;
+       int flags = IPC_CREAT | S_IRUSR | S_IWUSR;
 
        if (td->o.mem_type == MEM_SHMHUGE) {
                unsigned long mask = td->o.hugepage_size - 1;
@@ -115,7 +115,7 @@ static void free_mem_shm(struct thread_data *td)
        shmctl(td->shm_id, IPC_RMID, &sbuf);
 }
 
-static int alloc_mem_mmap(struct thread_data *td, unsigned int total_mem)
+static int alloc_mem_mmap(struct thread_data *td, size_t total_mem)
 {
        int flags = MAP_PRIVATE;
 
@@ -155,7 +155,7 @@ static int alloc_mem_mmap(struct thread_data *td, unsigned int total_mem)
        return 0;
 }
 
-static void free_mem_mmap(struct thread_data *td, unsigned int total_mem)
+static void free_mem_mmap(struct thread_data *td, size_t total_mem)
 {
        dprint(FD_MEM, "munmap %u %p\n", total_mem, td->orig_buffer);
        munmap(td->orig_buffer, td->orig_buffer_size);
@@ -166,7 +166,7 @@ static void free_mem_mmap(struct thread_data *td, unsigned int total_mem)
        }
 }
 
-static int alloc_mem_malloc(struct thread_data *td, unsigned int total_mem)
+static int alloc_mem_malloc(struct thread_data *td, size_t total_mem)
 {
        td->orig_buffer = malloc(total_mem);
        dprint(FD_MEM, "malloc %u %p\n", total_mem, td->orig_buffer);
@@ -181,11 +181,11 @@ static void free_mem_malloc(struct thread_data *td)
 }
 
 /*
- * Setup the buffer area we need for io.
+ * Set up the buffer area we need for io.
  */
 int allocate_io_mem(struct thread_data *td)
 {
-       unsigned int total_mem;
+       size_t total_mem;
        int ret = 0;
 
        if (td->io_ops->flags & FIO_NOIO)
@@ -200,6 +200,8 @@ int allocate_io_mem(struct thread_data *td)
                        total_mem += td->o.mem_align - page_size;
        }
 
+       dprint(FD_MEM, "Alloc %lu for buffers\n", (size_t) total_mem);
+
        if (td->o.mem_type == MEM_MALLOC)
                ret = alloc_mem_malloc(td, total_mem);
        else if (td->o.mem_type == MEM_SHM || td->o.mem_type == MEM_SHMHUGE)