| 82 |
// Allocate shared memory |
// Allocate shared memory |
| 83 |
size = sizeof(struct shm_header_t) + data_len + 1 + sizeof(long) * (size_t)(line_total + 1); |
size = sizeof(struct shm_header_t) + data_len + 1 + sizeof(long) * (size_t)(line_total + 1); |
| 84 |
|
|
| 85 |
if (unload_file(filename) < 0) |
strncpy(filepath, filename, sizeof(filepath) - 1); |
| 86 |
|
filepath[sizeof(filepath) - 1] = '\0'; |
| 87 |
|
snprintf(shm_name, sizeof(shm_name), "/FILE_SHM_%s", basename(filepath)); |
| 88 |
|
|
| 89 |
|
if (shm_unlink(shm_name) == -1 && errno != ENOENT) |
| 90 |
{ |
{ |
| 91 |
|
log_error("shm_unlink(%s) error (%d)\n", shm_name, errno); |
| 92 |
return -2; |
return -2; |
| 93 |
} |
} |
| 94 |
|
|
|
strncpy(filepath, filename, sizeof(filepath) - 1); |
|
|
filepath[sizeof(filepath) - 1] = '\0'; |
|
|
snprintf(shm_name, sizeof(shm_name), "/%s", basename(filepath)); |
|
|
|
|
| 95 |
if ((fd = shm_open(shm_name, O_CREAT | O_EXCL | O_RDWR, 0600)) == -1) |
if ((fd = shm_open(shm_name, O_CREAT | O_EXCL | O_RDWR, 0600)) == -1) |
| 96 |
{ |
{ |
| 97 |
log_error("shm_open(%s) error (%d)\n", shm_name, errno); |
log_error("shm_open(%s) error (%d)\n", shm_name, errno); |
| 156 |
|
|
| 157 |
strncpy(filepath, filename, sizeof(filepath) - 1); |
strncpy(filepath, filename, sizeof(filepath) - 1); |
| 158 |
filepath[sizeof(filepath) - 1] = '\0'; |
filepath[sizeof(filepath) - 1] = '\0'; |
| 159 |
snprintf(shm_name, sizeof(shm_name), "/%s", basename(filepath)); |
snprintf(shm_name, sizeof(shm_name), "/FILE_SHM_%s", basename(filepath)); |
| 160 |
|
|
| 161 |
if (shm_unlink(shm_name) == -1 && errno != ENOENT) |
if (shm_unlink(shm_name) == -1 && errno != ENOENT) |
| 162 |
{ |
{ |
| 184 |
|
|
| 185 |
strncpy(filepath, filename, sizeof(filepath) - 1); |
strncpy(filepath, filename, sizeof(filepath) - 1); |
| 186 |
filepath[sizeof(filepath) - 1] = '\0'; |
filepath[sizeof(filepath) - 1] = '\0'; |
| 187 |
snprintf(shm_name, sizeof(shm_name), "/%s", basename(filepath)); |
snprintf(shm_name, sizeof(shm_name), "/FILE_SHM_%s", basename(filepath)); |
| 188 |
|
|
| 189 |
if ((fd = shm_open(shm_name, O_RDONLY, 0600)) == -1) |
if ((fd = shm_open(shm_name, O_RDONLY, 0600)) == -1) |
| 190 |
{ |
{ |