Print this page
OS-5223 removed shm segment is no longer available
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/ipc.c
          +++ new/usr/src/uts/common/os/ipc.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
       23 + * Copyright 2016 Joyent, Inc.
  23   24   */
  24   25  
  25   26  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T         */
  26   27  /*      All Rights Reserved                                     */
  27   28  
  28   29  
  29   30  /*
  30   31   * Common Inter-Process Communication routines.
  31   32   *
  32   33   * Overview
↓ open down ↓ 1177 lines elided ↑ open up ↑
1210 1211                  service->ipcs_table[index].ipct_seq = 0;
1211 1212          service->ipcs_count--;
1212 1213          ASSERT(IPC_PROJ_USAGE(perm, service) > 0);
1213 1214          ASSERT(IPC_ZONE_USAGE(perm, service) > 0);
1214 1215          IPC_PROJ_USAGE(perm, service) -= 1;
1215 1216          IPC_ZONE_USAGE(perm, service) -= 1;
1216 1217          ASSERT(service->ipcs_count || ((IPC_PROJ_USAGE(perm, service) == 0) &&
1217 1218              (IPC_ZONE_USAGE(perm, service) == 0)));
1218 1219  }
1219 1220  
     1221 +/*
     1222 + * Perform actual IPC_RMID, either via ipc_rmid or due to a delayed *_RMID.
     1223 + */
     1224 +void
     1225 +ipc_rmsvc(ipc_service_t *service, kipc_perm_t *perm)
     1226 +{
     1227 +        ASSERT(service->ipcs_count > 0);
     1228 +        ASSERT(MUTEX_HELD(&service->ipcs_lock));
1220 1229  
     1230 +        ipc_remove(service, perm);
     1231 +        mutex_exit(&service->ipcs_lock);
     1232 +
     1233 +        /* perform any per-service removal actions */
     1234 +        service->ipcs_rmid(perm);
     1235 +
     1236 +        ipc_rele(service, perm);
     1237 +}
     1238 +
1221 1239  /*
1222 1240   * Common code to perform an IPC_RMID.  Returns an errno value on
1223 1241   * failure, 0 on success.
1224 1242   */
1225 1243  int
1226 1244  ipc_rmid(ipc_service_t *service, int id, cred_t *cr)
1227 1245  {
1228 1246          kipc_perm_t *perm;
1229 1247          kmutex_t *lock;
1230 1248  
↓ open down ↓ 9 lines elided ↑ open up ↑
1240 1258  
1241 1259          if (secpolicy_ipc_owner(cr, perm) != 0) {
1242 1260                  mutex_exit(lock);
1243 1261                  mutex_exit(&service->ipcs_lock);
1244 1262                  return (EPERM);
1245 1263          }
1246 1264  
1247 1265          /*
1248 1266           * Nothing can fail from this point on.
1249 1267           */
1250      -        ipc_remove(service, perm);
1251      -        mutex_exit(&service->ipcs_lock);
     1268 +        ipc_rmsvc(service, perm);
1252 1269  
1253      -        /* perform any per-service removal actions */
1254      -        service->ipcs_rmid(perm);
1255      -
1256      -        ipc_rele(service, perm);
1257      -
1258 1270          return (0);
1259 1271  }
1260 1272  
1261 1273  /*
1262 1274   * Implementation for shmids, semids, and msgids.  buf is the address
1263 1275   * of the user buffer, nids is the size, and pnids is a pointer to
1264 1276   * where we write the actual number of ids that [would] have been
1265 1277   * copied out.
1266 1278   */
1267 1279  int
↓ open down ↓ 129 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX