@@ -9,13 +9,21 @@ int __shmctl64(int shmid, int cmd, struct __shmid64_ds *buf) {
9
9
10
10
if (cmd == IPC_RMID ) {
11
11
DBG ("%s: IPC_RMID for shmid=%x\n" , __PRETTY_FUNCTION__ , shmid );
12
+
13
+ int socket_id = ashv_socket_id_from_shmid (shmid );
14
+
12
15
pthread_mutex_lock (& mutex );
16
+
13
17
int idx = ashv_find_local_index (shmid );
18
+ if (idx == -1 && socket_id != ashv_local_socket_id ) {
19
+ idx = ashv_read_remote_segment (shmid );
20
+ }
21
+
14
22
if (idx == -1 ) {
15
- DBG ("%s: shmid=%x does not exist locally\n" , __PRETTY_FUNCTION__ , shmid );
16
- /* We do not rm non-local regions, but do not report an error for that. */
23
+ DBG ("%s: ERROR: shmid %x does not exist\n" , __PRETTY_FUNCTION__ , shmid );
17
24
pthread_mutex_unlock (& mutex );
18
- return 0 ;
25
+ errno = EINVAL ;
26
+ return -1 ;
19
27
}
20
28
21
29
if (shmem [idx ].addr ) {
@@ -35,14 +43,22 @@ int __shmctl64(int shmid, int cmd, struct __shmid64_ds *buf) {
35
43
return -1 ;
36
44
}
37
45
46
+ int socket_id = ashv_socket_id_from_shmid (shmid );
47
+
38
48
pthread_mutex_lock (& mutex );
49
+
39
50
int idx = ashv_find_local_index (shmid );
51
+ if (idx == -1 && socket_id != ashv_local_socket_id ) {
52
+ idx = ashv_read_remote_segment (shmid );
53
+ }
54
+
40
55
if (idx == -1 ) {
41
56
DBG ("%s: ERROR: shmid %x does not exist\n" , __PRETTY_FUNCTION__ , shmid );
42
57
pthread_mutex_unlock (& mutex );
43
58
errno = EINVAL ;
44
59
return -1 ;
45
60
}
61
+
46
62
/* Report max permissive mode */
47
63
memset (buf , 0 , sizeof (struct shmid_ds ));
48
64
buf -> shm_segsz = shmem [idx ].size ;
0 commit comments