On Thu, Jun 24, 2010 at 01:23:44AM -0700, Steven Dake wrote:
> this fixes leaking of files in /dev/shm which happens if corosync is
> started and stopped repeatedly.
>

Couple of suggestions inline.
 
> Regards
> -steve

> Index: exec/logsys.c
> ===================================================================
> --- exec/logsys.c     (revision 2962)
> +++ exec/logsys.c     (working copy)
> @@ -225,6 +225,9 @@
>       int res;
>       const char *file = "fdata-XXXXXX";
>       char path[128];

char path[MAX_PATH];

> +     char buffer[128];
> +     int i;
> +     int written;
>  

snprintf(MAX_PATH, ...)

>       sprintf (path, "/dev/shm/%s", file);
>  
> @@ -237,10 +240,27 @@
>               }
>       }
>  
> -     res = ftruncate (fd, bytes);
> +     /*
> +      * ftruncate doesn't return ENOSPC
> +      * have to use write to determine if shared memory is actually available
> +      */
> +     res = ftruncate (fd, 0);
>       if (res == -1) {

unlink()

>               close (fd);
>       }
> +     memset (buffer, 0, sizeof (buffer));
> +     for (i = 0; i < (bytes / 64); i++) {
> +retry_write:
> +             written = write (fd, buffer, 64);
> +             if (written == -1 && errno == EINTR) {
> +                     goto retry_write;
> +             }
> +             if (written != 64) {

unlink()

> +                     return (-1);
> +             }
> +     }
> +     
> +     unlink (path);
>  
>       addr_orig = mmap (NULL, bytes << 1, PROT_NONE,
>               MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);

Also don't we need to call munmap() when the second mmap() fails?


> @@ -1011,6 +1031,7 @@
>  int _logsys_rec_init (unsigned int fltsize)
>  {
>       size_t flt_real_size;
> +     int res;
>  
>       sem_init (&logsys_thread_start, 0, 0);
>  
> @@ -1034,7 +1055,10 @@
>  
>       flt_real_size = ROUNDUP(fltsize, sysconf(_SC_PAGESIZE)) * 4;
>  
> -     circular_memory_map ((void **)&flt_data, flt_real_size);
> +     res = circular_memory_map ((void **)&flt_data, flt_real_size);
> +     if (res == -1) {

I know they are not "pshared" but it would be good to
call
sem_destroy() and pthread_spin_destroy()
here.

> +             return (-1);
> +     }
>  
>       memset (flt_data, 0, flt_real_size * 2);
>       /*

> _______________________________________________
> Openais mailing list
> [email protected]
> https://lists.linux-foundation.org/mailman/listinfo/openais

_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to