Ignore:
Timestamp:
Sep 14, 2020, 11:46:32 PM (5 years ago)
Author:
bird
Message:

kash: Use reference counting of parser output in threaded-mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/shfile.c

    r3454 r3458  
    921921 * Safe to call more than once.
    922922 */
    923 void shfile_uninit(shfdtab *pfdtab)
     923void shfile_uninit(shfdtab *pfdtab, int tracefd)
    924924{
    925925    if (!pfdtab)
     
    930930        unsigned left = pfdtab->size;
    931931        struct shfile *pfd = pfdtab->tab;
     932        unsigned tracefdfound = 0;
    932933        while (left-- > 0)
    933934        {
    934935            if (pfd->fd != -1)
    935936            {
     937                if (pfd->fd != tracefd)
     938                {
    936939#if K_OS == K_OS_WINDOWS
    937                 BOOL rc = CloseHandle((HANDLE)pfd->native);
    938                 assert(rc == TRUE); K_NOREF(rc);
    939 #else
    940                 int rc = close((int)pfd->native);
    941                 assert(rc == 0); K_NOREF(rc);
    942 #endif
    943                 pfd->fd     = -1;
    944                 pfd->native = -1;
     940                    BOOL rc = CloseHandle((HANDLE)pfd->native);
     941                    assert(rc == TRUE); K_NOREF(rc);
     942#else
     943                    int rc = close((int)pfd->native);
     944                    assert(rc == 0); K_NOREF(rc);
     945#endif
     946                    pfd->fd     = -1;
     947                    pfd->native = -1;
     948                }
     949                else
     950                    tracefdfound++; /* there is only the one */
    945951            }
    946952            pfd++;
    947953        }
     954
     955        if (!tracefdfound)
     956        { /* likely */ }
     957        else
     958            return;
    948959
    949960        sh_free(NULL, pfdtab->tab);
Note: See TracChangeset for help on using the changeset viewer.