Ignore:
Timestamp:
Jan 3, 2011, 5:29:44 PM (15 years ago)
Author:
Silvan Scherrer
Message:

samba client 2.1: read fixes, more caching

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/src/ndpsmb.c

    r505 r508  
    804804
    805805        *pconn = (HCONNECTION)pConn;
    806         debuglocal(9,"NdpCreateConnection %d\n", rc);
     806        debuglocal(9,"NdpCreateConnection [%p] %d\n", pConn, rc);
    807807        return rc;
    808808}
     
    816816        int rc;
    817817
    818         debuglocal(9,"NdpFreeConnection in\n");
     818        debuglocal(9,"NdpFreeConnection in [%p]\n", pConn);
    819819        if (pConn->file.fd >= 0)
    820820        {
     
    858858        int retry = 0;
    859859
    860                 debuglocal(9,"NdpQueryPathInfo in <%s>, retry = %d\n", szPath, retry);
     860                debuglocal(9,"NdpQueryPathInfo in [%p] <%s>, retry = %d\n", pConn, szPath, retry);
    861861       
    862862                // is wildcard is specified, we suppose parent dir exist, so exit immediately
     
    975975        char * p;
    976976
    977         debug_printf("NdpFindStart in\n");
     977        debug_printf("NdpFindStart in [%p]\n", pConn);
    978978
    979979                strncpy(dir, szPath, sizeof(dir) - 1);
     
    10861086        smbwrp_fileinfo finfo;
    10871087
    1088         debug_printf("NdpSetPathInfo in FIXME\n");
     1088        debug_printf("NdpSetPathInfo in [%p]\n", pConn);
     1089
     1090        // delete the dir chache
     1091        dircache_invalidate(szPathName, pRes->pdc, 1);
    10891092
    10901093        do {
     
    11961199        path = finfo->fname;
    11971200
    1198         debuglocal(9,"NdpEAQuery in <%s> %08x %d\n", path, pGEAList, pGEAList ? pGEAList->cbList : 0);
     1201        debuglocal(9,"NdpEAQuery in [%p] <%s> %08x %d\n", pConn, path, pGEAList, pGEAList ? pGEAList->cbList : 0);
    11991202
    12001203        do {
     
    12421245        smbwrp_fileinfo *finfo;
    12431246
    1244         debuglocal(9,"NdpEASet in\n");
     1247        debuglocal(9,"NdpEASet in [%p]\n", pConn);
    12451248
    12461249        if (!pfi || !pfi->pszName || !pFEAList || pFEAList->cbList <= sizeof(long))
     
    13221325        }
    13231326
    1324         debuglocal(9,"NdpEASize in <%s> \n", path);
     1327        debuglocal(9,"NdpEASize in [%p] <%s> \n", pConn, path);
    13251328
    13261329        do {
     
    13621365        char path[CCHMAXPATH+1] = {0};
    13631366       
    1364         debuglocal(9,"NdpSetCurrentDir in\n");
     1367        debuglocal(9,"NdpSetCurrentDir in [%p]\n", pConn);
    13651368
    13661369        do {
     
    13981401        char path[CCHMAXPATH+1] = {0};
    13991402
    1400         debuglocal(9,"NdpForceDelete in\n");
     1403        debuglocal(9,"NdpForceDelete in [%p]\n", pConn);
    14011404
    14021405        dircache_invalidate(szFile, pRes->pdc, 1);
     
    14241427        char path[CCHMAXPATH+1] = {0};
    14251428
    1426         debuglocal(9,"NdpCreateDir in\n");
     1429        debuglocal(9,"NdpCreateDir in [%p]\n", pConn);
    14271430
    14281431        dircache_invalidate(szDirName, pRes->pdc, 1);
     
    14501453        char path[CCHMAXPATH+1] = {0};
    14511454
    1452         debuglocal(9,"NdpDeleteDir in\n");
     1455        debuglocal(9,"NdpDeleteDir in [%p]\n", pConn);
    14531456
    14541457        dircache_invalidate(szDir, pRes->pdc, 1);
     
    14781481        char * p = szDst;
    14791482
    1480         debuglocal(9,"NdpMove in from <%s> to <%s>\n", szSrc, szDst);
     1483        debuglocal(9,"NdpMove in [%p] from <%s> to <%s>\n", pConn, szSrc, szDst);
    14811484
    14821485        dircache_invalidate(szSrc, pRes->pdc, 1);
     
    15341537        char path[CCHMAXPATH+1] = {0};
    15351538
    1536         debuglocal(9,"smbopen in %d\n", pConn->file.fd);
     1539        debuglocal(9,"smbopen in [%p] %d\n", pConn, pConn->file.fd);
    15371540
    15381541        if (flags & O_CREAT)
     
    16151618        char path[CCHMAXPATH+1] = {0};
    16161619
    1617         debuglocal(9,"NdpSetFileAttribute in\n");
     1620        debuglocal(9,"NdpSetFileAttribute in [%p]\n", pConn);
    16181621        do {
    16191622                rc = pathparser(pRes, pConn, szFileName, path);
     
    16631666        smbwrp_fileinfo finfo;
    16641667
    1665         debug_printf("NdpFileQueryInfo in\n");
     1668        debug_printf("NdpFileQueryInfo in [%p]\n", pConn);
    16661669        do {
    16671670                if (pConn->file.fd < 0 || !*pConn->file.fname)
     
    17011704        }
    17021705
    1703         debuglocal(9,"NdpFileEAQuery in <%s>/%d pGEAList=%08x\n", pConn->file.fname, pConn->file.fd, pGEAList);
     1706        debuglocal(9,"NdpFileEAQuery in [%p] <%s>/%d pGEAList=%08x\n", pConn, pConn->file.fname, pConn->file.fd, pGEAList);
    17041707        do {
    17051708                if (pConn->file.fd < 0)
     
    17481751        unsigned long action;
    17491752
    1750         debuglocal(9,"NdpFileEASet in\n");
     1753        debuglocal(9,"NdpFileEASet in [%p]\n", pConn);
    17511754
    17521755        if (!pFEAList || pFEAList->cbList <= sizeof(long))
     
    18061809        }
    18071810
    1808         debuglocal(9,"NdpFileEASize in <%s>/%d \n", pConn->file.fname, pConn->file.fd);
     1811        debuglocal(9,"NdpFileEASize in [%p] <%s>/%d \n", pConn, pConn->file.fname, pConn->file.fd);
    18091812        do {
    18101813                if (pConn->file.fd < 0)
     
    18491852        unsigned long action, attrFile;
    18501853
    1851         debug_printf("NdpFileSetInfo in\n");
     1854        debug_printf("NdpFileSetInfo in [%p]\n", pConn);
    18521855        do {
    18531856                if (pConn->file.fd < 0 || !*pConn->file.fname)
     
    18741877        unsigned long action;
    18751878
    1876         debuglocal(9,"NdpFileSetFilePtrl in\n");
     1879        debuglocal(9,"NdpFileSetFilePtrL in [%p]\n", pConn);
    18771880
    18781881        do {
     
    19091912        unsigned long action;
    19101913
    1911         debuglocal(9,"NdpFileClose in %d <%s>\n", pConn->file.fd, pConn->file.fd < 0 ? "!null!" : pConn->file.fname);
     1914        debuglocal(9,"NdpFileClose in [%p] %d <%s>\n", pConn, pConn->file.fd, pConn->file.fd < 0 ? "!null!" : pConn->file.fname);
     1915
     1916        // delete the dir chache
     1917        dircache_invalidate(pConn->file.fullname, pRes->pdc, 1);
    19121918
    19131919        do {
     
    19481954        unsigned long action;
    19491955
    1950         debuglocal(9,"NdpFileNewSizeL in\n");
     1956        debuglocal(9,"NdpFileNewSizeL in [%p]\n", pConn);
    19511957
    19521958        do {
     
    19651971}
    19661972
     1973#define NDPSMB_READ_MAX_SIZE (65536 - 4096)
     1974
    19671975int APIENTRY NdpFileRead (HCONNECTION conn, NDFILEHANDLE handle, void *pBuffer, ULONG ulRead, ULONG *pulActual)
    19681976{
     
    19731981        unsigned long onedone;
    19741982        unsigned long action;
    1975 
    1976         debuglocal(9,"NdpFileRead in\n");
     1983        ULONG ulReadCompleted = 0;
     1984
     1985        debuglocal(9,"NdpFileRead in [%p]\n", pConn);
    19771986
    19781987        do {
     
    19821991                        break;
    19831992                }
    1984                 rc = smbwrp_read(pConn->cli, &pConn->file, pBuffer, ulRead, pulActual);
     1993                while (ulReadCompleted < ulRead)
     1994                {
     1995                        ULONG ulActual;
     1996                        ULONG ulToRead = ulRead - ulReadCompleted;
     1997                        debuglocal(9,"NdpFileRead completed %d, to read %d\n", ulReadCompleted, ulToRead);
     1998                        if (ulToRead > NDPSMB_READ_MAX_SIZE)
     1999                        {
     2000                                ulToRead = NDPSMB_READ_MAX_SIZE;
     2001                        }
     2002                        rc = smbwrp_read(pConn->cli, &pConn->file, (char *)pBuffer + ulReadCompleted, ulToRead, &ulActual);
     2003                        if (ulActual == 0 || rc != NO_ERROR)
     2004                        {
     2005                                break;
     2006                        }
     2007                        ulReadCompleted += ulActual;
     2008                }
    19852009                //*pulActual = ulRead;
    19862010                //DosSleep(0);
    19872011
    19882012        } while (0);
     2013
     2014        if (ulReadCompleted > 0)
     2015        {
     2016                rc = NO_ERROR; /* Still were able to read some data. */
     2017        }
     2018
     2019        if (rc == NO_ERROR)
     2020        {
     2021                *pulActual = ulReadCompleted;
     2022        }
     2023
    19892024        debuglocal(9,"NdpFileRead <%s> %lu %lu %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulRead, *pulActual, rc);
    19902025
     
    20012036        unsigned long action;
    20022037
    2003         debuglocal(9,"NdpFileWrite in\n");
     2038        debuglocal(9,"NdpFileWrite in [%p]\n", pConn);
    20042039
    20052040        do {
Note: See TracChangeset for help on using the changeset viewer.