Ignore:
Timestamp:
Feb 18, 2008, 9:28:27 AM (17 years ago)
Author:
Paul Smedley
Message:

Relaunch smbcd when it crashes whilst accessing a file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/ndpsmb/ndpsmb.c

    r116 r121  
    12781278        smbwrp_fileinfo * finfo = (smbwrp_fileinfo *)pConn->mem;
    12791279        char path[CCHMAXPATH+1] = {0};
    1280 
    1281         log("NdpQueryInfo in <%s>\n", szPath);
    1282 
    1283         do {
    1284                 if (ph->fsphStrChr(szPath, '*') || ph->fsphStrChr(szPath, '?'))
    1285                 {
    1286                         rc = ERROR_FILE_NOT_FOUND;
    1287                         break;
    1288                 }
    1289 
    1290                 rc = checkconnection(pConn);
    1291                 if (rc)
    1292                 {
    1293                         break;
    1294                 }
    1295 
    1296                 rc = pathparser(pRes, pConn, szPath, path);
    1297                 switch (rc)
    1298                 {
    1299                         case NO_ERROR :
    1300                         case ERROR_FILE_NOT_FOUND:
    1301                         case ERROR_PATH_NOT_FOUND:
    1302                         case ERROR_ACCESS_DENIED:
    1303                         case ERROR_INVALID_PARAMETER:
    1304                         {
     1280        int retry = 0;
     1281
     1282        do
     1283          {
     1284                log("NdpQueryInfo in <%s>, retry = %d\n", szPath, retry);
     1285
     1286                do {
     1287
     1288                        if (ph->fsphStrChr(szPath, '*') || ph->fsphStrChr(szPath, '?'))
     1289                        {
     1290                                rc = ERROR_FILE_NOT_FOUND;
    13051291                                break;
    13061292                        }
    1307                         default :
    1308                         {       
    1309                                 rc = ERROR_PATH_NOT_FOUND;
    1310                         }
    1311                 }
    1312                 if (rc)
    1313                 {
    1314                         break;
    1315                 }
    1316                 StrNCpy(finfo->fname, path, sizeof(finfo->fname) - 1);
    1317                 req.request = SMBREQ_GETINFO;
    1318                 req.param = pConn->mem;
    1319                 req.paramlen = sizeof(*finfo);
    1320                 req.length = req.paramlen;
    1321                 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action);
    1322                 if (pConn->rc || action < sizeof(resp) || resp.rc)
    1323                 {
    1324                         switch (resp.rc)
     1293
     1294                        rc = checkconnection(pConn);
     1295                        if (rc)
     1296                        {
     1297                                break;
     1298                        }
     1299
     1300                        rc = pathparser(pRes, pConn, szPath, path);
     1301                        switch (rc)
    13251302                        {
    13261303                                case NO_ERROR :
     
    13291306                                case ERROR_ACCESS_DENIED:
    13301307                                case ERROR_INVALID_PARAMETER:
     1308                                {
    13311309                                        break;
     1310                                }
    13321311                                default :
     1312                                {       
     1313                                        rc = ERROR_PATH_NOT_FOUND;
     1314                                }
     1315                        }
     1316                        if (rc)
     1317                        {
     1318                                break;
     1319                        }
     1320                        StrNCpy(finfo->fname, path, sizeof(finfo->fname) - 1);
     1321                        req.request = SMBREQ_GETINFO;
     1322                        req.param = pConn->mem;
     1323                        req.paramlen = sizeof(*finfo);
     1324                        req.length = req.paramlen;
     1325                        pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action);
     1326                        if (pConn->rc || action < sizeof(resp) || resp.rc)
     1327                        {
     1328                                switch (resp.rc)
    13331329                                {
    1334                                         resp.rc = ERROR_PATH_NOT_FOUND;
     1330                                        case NO_ERROR :
     1331                                        case ERROR_FILE_NOT_FOUND:
     1332                                        case ERROR_PATH_NOT_FOUND:
     1333                                        case ERROR_ACCESS_DENIED:
     1334                                        case ERROR_INVALID_PARAMETER:
     1335                                        break;
     1336                                        default :
     1337                                        {
     1338                                                resp.rc = ERROR_PATH_NOT_FOUND;
     1339                                        }
    13351340                                }
    1336                         }
    1337                         rc = pConn->rc ? pConn->rc : (resp.rc ? resp.rc : ERROR_INVALID_PARAMETER);
    1338                 }
    1339                 else
    1340                 {
    1341                         finfo->easize = -1;
    1342                         if (ifL)
    1343                         {
    1344                                 getfindinfoL(pConn, plist, finfo, 0, NULL);
     1341                                rc = pConn->rc ? pConn->rc : (resp.rc ? resp.rc : ERROR_INVALID_PARAMETER);
    13451342                        }
    13461343                        else
    13471344                        {
    1348                                 int trc;
    1349                                 FILEFINDBUF3 buf = {0};
    1350                                 getfindinfo(pConn, &buf, finfo);
    1351                                 trc = ph->fsphAddFileFind32(plist, &buf, finfo, sizeof(*finfo), 0);
    1352                                 log("NdpQueryInfo got info <%s> attr %08x size %d namelen %d date %lu %lu. Plist 0x%08x rc = %d\n", buf.achName, buf.attrFile, buf.cbFile, buf.cchName, buf.fdateLastWrite, buf.ftimeLastWrite, plist, trc);
    1353                         }
    1354                 }
    1355                 if (rc == ERROR_FILE_NOT_FOUND)
    1356                 {
    1357                         // now try the upper path
    1358                         char * p = ph->fsphStrChr(finfo->fname, '\\');
    1359                         if (p && p > finfo->fname)
    1360                         {
    1361                                 *p = 0;
    1362                                 rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action);
    1363                                 if (pConn->rc || action < sizeof(resp) || resp.rc)
    1364                                 {       
    1365                                         rc = pConn->rc ? pConn->rc : (resp.rc ? ERROR_PATH_NOT_FOUND : ERROR_INVALID_PARAMETER);
     1345                                finfo->easize = -1;
     1346                                if (ifL)
     1347                                {
     1348                                        getfindinfoL(pConn, plist, finfo, 0, NULL);
    13661349                                }
    1367                         }
    1368                 }
    1369         } while (0);
    1370 
    1371         log("NdpQueryInfo <%s> (%s) %d %d\n", szPath, path, rc, pConn->rc);
     1350                                else
     1351                                {
     1352                                        int trc;
     1353                                        FILEFINDBUF3 buf = {0};
     1354                                        getfindinfo(pConn, &buf, finfo);
     1355                                        trc = ph->fsphAddFileFind32(plist, &buf, finfo, sizeof(*finfo), 0);
     1356                                        log("NdpQueryInfo got info <%s> attr %08x size %d namelen %d date %lu %lu. Plist 0x%08x rc = %d\n", buf.achName, buf.attrFile, buf.cbFile, buf.cchName, buf.fdateLastWrite, buf.ftimeLastWrite, plist, trc);
     1357                                }
     1358                        }
     1359                        if (rc == ERROR_FILE_NOT_FOUND)
     1360                        {
     1361                                // now try the upper path
     1362                                char * p = ph->fsphStrChr(finfo->fname, '\\');
     1363                                if (p && p > finfo->fname)
     1364                                {
     1365                                        *p = 0;
     1366                                        rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action);
     1367                                        if (pConn->rc || action < sizeof(resp) || resp.rc)
     1368                                        {       
     1369                                                rc = pConn->rc ? pConn->rc : (resp.rc ? ERROR_PATH_NOT_FOUND : ERROR_INVALID_PARAMETER);
     1370                                        }
     1371                                }
     1372                        }
     1373                } while (0);
     1374                log("NdpQueryInfo <%s> (%s) %d %d\n", szPath, path, rc, pConn->rc);
     1375                retry = rc && !retry;
     1376        } while (retyr);
     1377       
    13721378        return rc;
    13731379}
Note: See TracChangeset for help on using the changeset viewer.