Ignore:
Timestamp:
Dec 13, 2010, 4:05:51 PM (15 years ago)
Author:
Silvan Scherrer
Message:

samba client: caching

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/client-2.0/src/ndpsmb.c

    r493 r497  
    224224
    225225
    226 static PLUGINHELPERTABLE2L *ph;
     226PLUGINHELPERTABLE2L *ph;
    227227static int ifL;
    228228
     
    397397        pRes->krb5support = 0;
    398398#endif
     399        pRes->pdc = NULL;
    399400
    400401        t = 0, q = NULL;
     
    503504                }
    504505        }
     506
     507        /* Create a directory cache with expiration time 15 seconds and up to 32 listings cached. */
     508        dircache_create(&pRes->pdc, 10, 32);
    505509
    506510        return rc;
     
    727731{
    728732        Resource *pRes = (Resource *)resource;
     733        dircache_delete(pRes->pdc);
    729734        MemSet(&pRes->srv, 0, sizeof(pRes->srv));
    730735        free(pRes);
     
    963968
    964969                do {
     970                        /* First check if there is information in the directory cache. */
     971                        unsigned long ulAge = 0;
     972                        if (dircache_find_path(pRes->pdc, szPath, &finfo, &ulAge))
     973                        {
     974                                if (ulAge <= 15) /* @todo configurable. */
     975                                {
     976                                        rc = NO_ERROR;
     977                                        finfo.easize = -1;
     978                                        getfindinfoL(pConn, plist, &finfo, 0, NULL);
     979                                        break;
     980                                }
     981                        }
    965982
    966983                        rc = pathparser(pRes, pConn, szPath, path);
     
    10921109                strcpy( state.dir_mask, mask);
    10931110                strcpy( state.mask, path);
     1111                state.fullpath = szPath;
     1112                /* This plugin always reads a complete directory listing and filters results
     1113                 * using actual mask (state.dir_mask) in getfindinfoL.
     1114                 * May be this was a workaround for some server bug.
     1115                 * If this will be changed, then directory listing cache must be changed too,
     1116                 * and must remember the mask, which was used to obtain a listing.
     1117                 * Now the directory cache saves complete directory listings and then uses them to find
     1118                 * information about single files.
     1119                 * However, with a directory cache, it is probably faster to get a full listing and
     1120                 * then use it to obtain info about separate files than to perform a network
     1121                 * list query operation using actual wild cards for each file. Some application,
     1122                 * for example OpenOffice, do this.
     1123                 */
    10941124                p = getlastslash(state.mask);
    10951125                if (p)
     
    11021132                        strcpy(state.mask, "\\*");
    11031133                }
     1134                debuglocal(9,"NdpFindStart: dir [%s], dir_mask [%s], mask [%s], szPath [%s]\n",
     1135                           state.dir, state.dir_mask, state.mask, state.fullpath);
    11041136                rc = smbwrp_filelist( &pRes->srv, pConn->cli, &state);
    11051137                // we need to handle reconnection also here, because NdpQueryPathInfo
     
    14681500        debuglocal(9,"NdpForceDelete in\n");
    14691501
     1502        dircache_invalidate(szFile, pRes->pdc, 1);
     1503
    14701504        do {
    14711505                rc = pathparser(pRes, pConn, szFile, path);
     
    14921526        debuglocal(9,"NdpCreateDir in\n");
    14931527
     1528        dircache_invalidate(szDirName, pRes->pdc, 1);
     1529
    14941530        do {
    14951531                rc = pathparser(pRes, pConn, szDirName, path);
     
    15161552        debuglocal(9,"NdpDeleteDir in\n");
    15171553
     1554        dircache_invalidate(szDir, pRes->pdc, 1);
     1555
    15181556        do {
    15191557                rc = pathparser(pRes, pConn, szDir, path);
     
    15411579
    15421580        debuglocal(9,"NdpMove in from <%s> to <%s>\n", szSrc, szDst);
     1581
     1582        dircache_invalidate(szSrc, pRes->pdc, 1);
     1583        dircache_invalidate(szDst, pRes->pdc, 1);
    15431584
    15441585        do
     
    15951636        debuglocal(9,"smbopen in %d\n", pConn->file.fd);
    15961637
     1638        if (flags & O_CREAT)
     1639        {
     1640                dircache_invalidate(szFileName, pRes->pdc, 1);
     1641        }
    15971642        do {
    15981643                if (pConn->file.fd > 0)
Note: See TracChangeset for help on using the changeset viewer.