Print this page
pbchk
cleanup port_free_event_local() semantics

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/portfs/port.c
          +++ new/usr/src/uts/common/fs/portfs/port.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27   27  /*
  28      - * Copyright (c) 2015 Joyent, Inc.  All rights reserved.
       28 + * Copyright 2020 Joyent, Inc.
  29   29   */
  30   30  
  31   31  #include <sys/types.h>
  32   32  #include <sys/systm.h>
  33   33  #include <sys/cred.h>
  34   34  #include <sys/modctl.h>
  35   35  #include <sys/vfs.h>
  36   36  #include <sys/vfs_opreg.h>
  37   37  #include <sys/sysmacros.h>
  38   38  #include <sys/cmn_err.h>
↓ open down ↓ 1360 lines elided ↑ open up ↑
1399 1399                  lev = NULL;     /* start with first event in the queue */
1400 1400                  for (nevents = 0; nevents < nmax; ) {
1401 1401                          pev = port_get_kevent(glist, lev);
1402 1402                          if (pev == NULL)        /* no more events available */
1403 1403                                  break;
1404 1404                          if (pev->portkev_flags & PORT_KEV_FREE) {
1405 1405                                  /* Just discard event */
1406 1406                                  list_remove(glist, pev);
1407 1407                                  pev->portkev_flags &= ~(PORT_CLEANUP_DONE);
1408 1408                                  if (PORT_FREE_EVENT(pev))
1409      -                                        port_free_event_local(pev, 0);
     1409 +                                        port_free_event_local(pev, B_TRUE);
1410 1410                                  tnent--;
1411 1411                                  continue;
1412 1412                          }
1413 1413  
1414 1414                          /* move event data to copyout list */
1415 1415                          if (port_copy_event(&kevp[nevents], pev, glist)) {
1416 1416                                  /*
1417 1417                                   * Event can not be delivered to the
1418 1418                                   * current process.
1419 1419                                   */
↓ open down ↓ 27 lines elided ↑ open up ↑
1447 1447                  lev = NULL;     /* start with first event in the queue */
1448 1448                  for (nevents = 0; nevents < nmax; ) {
1449 1449                          pev = port_get_kevent(glist, lev);
1450 1450                          if (pev == NULL)        /* no more events available */
1451 1451                                  break;
1452 1452                          if (pev->portkev_flags & PORT_KEV_FREE) {
1453 1453                                  /* Just discard event */
1454 1454                                  list_remove(glist, pev);
1455 1455                                  pev->portkev_flags &= ~(PORT_CLEANUP_DONE);
1456 1456                                  if (PORT_FREE_EVENT(pev))
1457      -                                        port_free_event_local(pev, 0);
     1457 +                                        port_free_event_local(pev, B_TRUE);
1458 1458                                  tnent--;
1459 1459                                  continue;
1460 1460                          }
1461 1461  
1462 1462                          /* move event data to copyout list */
1463 1463                          if (port_copy_event32(&kevp32[nevents], pev, glist)) {
1464 1464                                  /*
1465 1465                                   * Event can not be delivered to the
1466 1466                                   * current process.
1467 1467                                   */
↓ open down ↓ 151 lines elided ↑ open up ↑
1619 1619                  if (error) {
1620 1620                          /*
1621 1621                           * Event can not be delivered.
1622 1622                           * Caller must reinsert the event into the queue.
1623 1623                           */
1624 1624                          pkevp->portkev_flags = flags;
1625 1625                          return (error);
1626 1626                  }
1627 1627          }
1628 1628          if (free_event)
1629      -                port_free_event_local(pkevp, 0);
     1629 +                port_free_event_local(pkevp, B_TRUE);
1630 1630          return (0);
1631 1631  }
1632 1632  
1633 1633  #ifdef  _SYSCALL32_IMPL
1634 1634  /*
1635 1635   * 1. copy kernel event structure to user event structure.
1636 1636   * 2. PORT_KEV_WIRED event structures will be reused by the "source"
1637 1637   * 3. Remove PORT_KEV_DONEQ flag (event removed from the event queue)
1638 1638   * 4. Other types of event structures can be delivered back to the port cache
1639 1639   *    (port_free_event_local()).
↓ open down ↓ 34 lines elided ↑ open up ↑
1674 1674                  if (error) {
1675 1675                          /*
1676 1676                           * Event can not be delivered.
1677 1677                           * Caller must reinsert the event into the queue.
1678 1678                           */
1679 1679                          pkevp->portkev_flags = flags;
1680 1680                          return (error);
1681 1681                  }
1682 1682          }
1683 1683          if (free_event)
1684      -                port_free_event_local(pkevp, 0);
     1684 +                port_free_event_local(pkevp, B_TRUE);
1685 1685          return (0);
1686 1686  }
1687 1687  #endif  /* _SYSCALL32_IMPL */
1688 1688  
1689 1689  /*
1690 1690   * copyout alert event.
1691 1691   */
1692 1692  static int
1693 1693  port_get_alert(port_alert_t *pa, port_event_t *uevp)
1694 1694  {
↓ open down ↓ 197 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX