Changeset 72d5fa1 in rtems-libbsd


Ignore:
Timestamp:
Nov 10, 2017, 10:01:39 AM (20 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5283630d2c9d40deb0183696d278e02644fe4326, bc2ba9a9cdc7381c2a4f2ae6ee303be636f31368
Children:
057656b
Parents:
b15a719
git-author:
Sebastian Huber <sebastian.huber@…> (11/10/17 10:01:39)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/10/17 10:01:54)
Message:

Fix reference counting for file descriptors

Update #3132.

Location:
freebsd/sys
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • freebsd/sys/kern/kern_event.c

    rb15a719 r72d5fa1  
    940940
    941941        finit(fp, FREAD | FWRITE, DTYPE_KQUEUE, kq, &kqueueops);
     942#ifndef __rtems__
    942943        fdrop(fp, td);
     944#endif /* __rtems__ */
    943945
    944946        td->td_retval[0] = fd;
  • freebsd/sys/kern/sys_pipe.c

    rb15a719 r72d5fa1  
    486486        if (error) {
    487487                fdclose(td, rf, fildes[0]);
     488#ifndef __rtems__
    488489                fdrop(rf, td);
     490#endif /* __rtems__ */
    489491                /* rpipe has been closed by fdrop(). */
    490492                pipeclose(wpipe);
     
    493495        /* An extra reference on `wf' has been held for us by falloc_caps(). */
    494496        finit(wf, fflags, DTYPE_PIPE, wpipe, &pipeops);
     497#ifndef __rtems__
    495498        fdrop(wf, td);
     499#endif /* __rtems__ */
    496500        fildes[1] = fd;
     501#ifndef __rtems__
    497502        fdrop(rf, td);
     503#endif /* __rtems__ */
    498504
    499505        return (0);
  • freebsd/sys/kern/uipc_syscalls.c

    rb15a719 r72d5fa1  
    215215                td->td_retval[0] = fd;
    216216        }
     217#ifndef __rtems__
    217218        fdrop(fp, td);
     219#endif /* __rtems__ */
    218220        return (error);
    219221}
     
    617619                        *fp = NULL;
    618620        }
     621#ifndef __rtems__
    619622        if (nfp != NULL)
    620623                fdrop(nfp, td);
     624#endif /* __rtems__ */
    621625        fdrop(headfp, td);
    622626        return (error);
     
    841845                (void) fo_ioctl(fp2, FIONBIO, &fflag, td->td_ucred, td);
    842846        }
     847#ifndef __rtems__
    843848        fdrop(fp1, td);
    844849        fdrop(fp2, td);
     850#endif /* __rtems__ */
    845851        return (0);
    846852free4:
    847853        fdclose(td, fp2, rsv[1]);
     854#ifndef __rtems__
    848855        fdrop(fp2, td);
     856#endif /* __rtems__ */
    849857free3:
    850858        fdclose(td, fp1, rsv[0]);
     859#ifndef __rtems__
    851860        fdrop(fp1, td);
     861#endif /* __rtems__ */
    852862free2:
    853863        if (so2 != NULL)
  • freebsd/sys/sys/file.h

    rb15a719 r72d5fa1  
    414414}
    415415
     416/*
     417 * WARNING: fdalloc() and falloc_caps() do not increment the reference count of
     418 * the file descriptor in contrast to FreeBSD.  We must not call the fdrop()
     419 * corresponding to a fdalloc() or falloc_caps().  The reason for this is that
     420 * FreeBSD performs a lazy cleanup once the reference count reaches zero.
     421 * RTEMS uses the reference count to determine if a cleanup is allowed.
     422 */
    416423#define fdrop(fp, td) rtems_bsd_fdrop(fp)
    417424#endif /* __rtems__ */
  • freebsd/sys/sys/filedesc.h

    rb15a719 r72d5fa1  
    203203
    204204        if (iop != NULL) {
    205                 rtems_libio_iop_hold(iop);
    206205                iop->pathinfo.mt_entry = &rtems_filesystem_null_mt_entry;
    207206                rtems_filesystem_location_add_to_mt_entry(&iop->pathinfo);
     
    224223void    fdclose(struct thread *td, struct file *fp, int idx);
    225224#else /* __rtems__ */
     225/*
     226 * WARNING: Use of fdrop() after fclose() corrupts the file descriptor.  See
     227 * fdrop() comment.
     228 */
    226229static inline void
    227230fdclose(struct thread *td, struct file *fp, int idx)
Note: See TracChangeset for help on using the changeset viewer.