Search squid archive

Re: SIGBUS attempting to use rock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/18/2019 9:49 AM, Alex Rousskov wrote:
Actually, the location of shared memory segments is chosen by the OS.
Not all OSes do what Linux does. The code dealing with [naming] shared
memory segments is more complicated than you probably imagine. However,
let's not spend time arguing about these low-level specifics here: If
you can contribute an improvement, please post a plan on squid-dev.
Otherwise, let's leave these low-level details to those contributing
improvements.

You don't need to know where the OS put the file (though /dev/shm is a well known location and easily could be checked explicitly).

$ man fstatvfs

The attached example seems to work fine and could be incorporated into ipc/mem/Segment.cc.

I'd be happy to post this on squid-dev / submit a pull request.


/*
  $ gcc -o shm_statvfs shm_statvfs.c -lrt
 */

#include <fcntl.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <unistd.h>

const char FILENAME[] = "statvfs.test.tmp";

int
main(int   argc,
     char *argv)
{
  int rv;
  int fd;
  struct statvfs vfs;

  fd = shm_open(FILENAME,O_CREAT|O_RDWR,S_IRUSR|S_IWUSR);

  rv = fstatvfs(fd,&vfs);
  printf("fstatvfs(%d,%p) = %d\n",fd,&vfs,rv);
  if(rv == -1)
    return 1;

  printf("frsize: %ld\n"
         "bavail: %ld\n"
         "total avail: %ld\n",
         vfs.f_frsize,
         vfs.f_bavail,
         vfs.f_frsize*vfs.f_bavail);

  close(fd);

  shm_unlink(FILENAME);

  return 0;
}
_______________________________________________
squid-users mailing list
squid-users@xxxxxxxxxxxxxxxxxxxxx
http://lists.squid-cache.org/listinfo/squid-users

[Index of Archives]     [Linux Audio Users]     [Samba]     [Big List of Linux Books]     [Linux USB]     [Yosemite News]

  Powered by Linux