Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxython committed Jan 27, 2025
1 parent 63dcf5a commit f10578e
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions gpkg/glibc/shmctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ int __shmctl64(int shmid, int cmd, struct __shmid64_ds *buf) {

if (cmd == IPC_RMID) {
DBG("%s: IPC_RMID for shmid=%x\n", __PRETTY_FUNCTION__, shmid);

int socket_id = ashv_socket_id_from_shmid(shmid);

pthread_mutex_lock(&mutex);

int idx = ashv_find_local_index(shmid);
if (idx == -1 && socket_id != ashv_local_socket_id) {
idx = ashv_read_remote_segment(shmid);
}

if (idx == -1) {
DBG("%s: shmid=%x does not exist locally\n", __PRETTY_FUNCTION__, shmid);
/* We do not rm non-local regions, but do not report an error for that. */
DBG ("%s: ERROR: shmid %x does not exist\n", __PRETTY_FUNCTION__, shmid);
pthread_mutex_unlock(&mutex);
return 0;
errno = EINVAL;
return -1;
}

if (shmem[idx].addr) {
Expand All @@ -35,14 +43,22 @@ int __shmctl64(int shmid, int cmd, struct __shmid64_ds *buf) {
return -1;
}

int socket_id = ashv_socket_id_from_shmid(shmid);

pthread_mutex_lock(&mutex);

int idx = ashv_find_local_index(shmid);
if (idx == -1 && socket_id != ashv_local_socket_id) {
idx = ashv_read_remote_segment(shmid);
}

if (idx == -1) {
DBG ("%s: ERROR: shmid %x does not exist\n", __PRETTY_FUNCTION__, shmid);
pthread_mutex_unlock (&mutex);
errno = EINVAL;
return -1;
}

/* Report max permissive mode */
memset(buf, 0, sizeof(struct shmid_ds));
buf->shm_segsz = shmem[idx].size;
Expand Down

0 comments on commit f10578e

Please sign in to comment.