Loading src/shared_array_attach.c +5 −4 Original line number Diff line number Diff line Loading @@ -46,11 +46,13 @@ static PyObject *do_attach(const char *name) if ((fd = open_file(name, O_RDWR, 0)) < 0) return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); /* Find the file size */ if (fstat(fd, &file_info) < 0) { close(fd); return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); } /* Ignore short files */ if (file_info.st_size < sizeof (*meta)) { close(fd); PyErr_SetString(PyExc_IOError, "No SharedArray at this address"); Loading @@ -64,9 +66,8 @@ static PyObject *do_attach(const char *name) if (map_addr == MAP_FAILED) return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); meta = (struct array_meta *) (map_addr + (map_size - sizeof(*meta))); /* Check the meta data */ meta = (struct array_meta *) (map_addr + (map_size - sizeof (*meta))); if (strncmp(meta->magic, SHARED_ARRAY_MAGIC, sizeof (meta->magic))) { munmap(map_addr, map_size); PyErr_SetString(PyExc_IOError, "No SharedArray at this address"); Loading src/shared_array_create.c +5 −4 Original line number Diff line number Diff line Loading @@ -70,7 +70,8 @@ static PyObject *do_create(const char *name, int ndims, npy_intp *dims, PyArray_ return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); } /* Find actual file size after growing (on some systems it rounds up to 4K)*/ /* Find the actual file size after growing (on some systems it rounds * up to 4K) */ if (fstat(fd, &file_info) < 0) { close(fd); return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); Loading @@ -83,7 +84,7 @@ static PyObject *do_create(const char *name, int ndims, npy_intp *dims, PyArray_ if (map_addr == MAP_FAILED) return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); /* Append meta-data to the array in memory */ /* Append the meta-data to the array in memory */ meta = (struct array_meta *) (map_addr + (map_size - sizeof (*meta))); strncpy(meta->magic, SHARED_ARRAY_MAGIC, sizeof (meta->magic)); meta->size = size; Loading src/shared_array_delete.c +9 −7 Original line number Diff line number Diff line Loading @@ -42,28 +42,30 @@ static PyObject *do_delete(const char *name) if ((fd = open_file(name, O_RDWR, 0)) < 0) return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); /* Find the file size */ if (fstat(fd, &file_info) < 0) { close(fd); return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); } /* Ignore short files */ if (file_info.st_size < sizeof (*meta)) { close(fd); PyErr_SetString(PyExc_IOError, "No SharedArray at this address (too small)"); PyErr_SetString(PyExc_IOError, "No SharedArray at this address"); return NULL; } map_size = file_info.st_size; /* Map whole file into memory */ map_addr = mmap(NULL, map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); /* Map the whole file into memory */ map_addr = mmap(NULL, map_size, PROT_READ, MAP_SHARED, fd, 0); close(fd); if (map_addr == MAP_FAILED) return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); meta = (struct array_meta *) (map_addr + (map_size - sizeof(*meta))); /* Check the meta data */ meta = (struct array_meta *) (map_addr + (map_size - sizeof (*meta))); if (strncmp(meta->magic, SHARED_ARRAY_MAGIC, sizeof (meta->magic))) { munmap(map_addr, map_size); PyErr_SetString(PyExc_IOError, "No SharedArray at this address"); return NULL; } Loading Loading
src/shared_array_attach.c +5 −4 Original line number Diff line number Diff line Loading @@ -46,11 +46,13 @@ static PyObject *do_attach(const char *name) if ((fd = open_file(name, O_RDWR, 0)) < 0) return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); /* Find the file size */ if (fstat(fd, &file_info) < 0) { close(fd); return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); } /* Ignore short files */ if (file_info.st_size < sizeof (*meta)) { close(fd); PyErr_SetString(PyExc_IOError, "No SharedArray at this address"); Loading @@ -64,9 +66,8 @@ static PyObject *do_attach(const char *name) if (map_addr == MAP_FAILED) return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); meta = (struct array_meta *) (map_addr + (map_size - sizeof(*meta))); /* Check the meta data */ meta = (struct array_meta *) (map_addr + (map_size - sizeof (*meta))); if (strncmp(meta->magic, SHARED_ARRAY_MAGIC, sizeof (meta->magic))) { munmap(map_addr, map_size); PyErr_SetString(PyExc_IOError, "No SharedArray at this address"); Loading
src/shared_array_create.c +5 −4 Original line number Diff line number Diff line Loading @@ -70,7 +70,8 @@ static PyObject *do_create(const char *name, int ndims, npy_intp *dims, PyArray_ return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); } /* Find actual file size after growing (on some systems it rounds up to 4K)*/ /* Find the actual file size after growing (on some systems it rounds * up to 4K) */ if (fstat(fd, &file_info) < 0) { close(fd); return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); Loading @@ -83,7 +84,7 @@ static PyObject *do_create(const char *name, int ndims, npy_intp *dims, PyArray_ if (map_addr == MAP_FAILED) return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); /* Append meta-data to the array in memory */ /* Append the meta-data to the array in memory */ meta = (struct array_meta *) (map_addr + (map_size - sizeof (*meta))); strncpy(meta->magic, SHARED_ARRAY_MAGIC, sizeof (meta->magic)); meta->size = size; Loading
src/shared_array_delete.c +9 −7 Original line number Diff line number Diff line Loading @@ -42,28 +42,30 @@ static PyObject *do_delete(const char *name) if ((fd = open_file(name, O_RDWR, 0)) < 0) return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); /* Find the file size */ if (fstat(fd, &file_info) < 0) { close(fd); return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); } /* Ignore short files */ if (file_info.st_size < sizeof (*meta)) { close(fd); PyErr_SetString(PyExc_IOError, "No SharedArray at this address (too small)"); PyErr_SetString(PyExc_IOError, "No SharedArray at this address"); return NULL; } map_size = file_info.st_size; /* Map whole file into memory */ map_addr = mmap(NULL, map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); /* Map the whole file into memory */ map_addr = mmap(NULL, map_size, PROT_READ, MAP_SHARED, fd, 0); close(fd); if (map_addr == MAP_FAILED) return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); meta = (struct array_meta *) (map_addr + (map_size - sizeof(*meta))); /* Check the meta data */ meta = (struct array_meta *) (map_addr + (map_size - sizeof (*meta))); if (strncmp(meta->magic, SHARED_ARRAY_MAGIC, sizeof (meta->magic))) { munmap(map_addr, map_size); PyErr_SetString(PyExc_IOError, "No SharedArray at this address"); return NULL; } Loading