Changeset 70
- Timestamp:
- Sep 11, 2007, 8:16:50 PM (18 years ago)
- Location:
- trunk/samba/source/ndpsmb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/samba/source/ndpsmb/ndpsmb.c
r48 r70 508 508 smb_request req = {0}; 509 509 smb_response resp = {0}; 510 char* mem; 511 510 512 if (!pConn) 511 513 { … … 513 515 } 514 516 log("checkconnection pconnrc %d pipe %d\n", pConn->rc, pConn->pipe); 517 // YD this code need probably to be removed (reworked), since DosQueryNPHState, 518 // DosQueryNPipeInfo, DosPeekNPipe, DosResetBuffer, are all returning 519 // NO_ERROR even if the other pipe end is closed (smbcd crash). 520 // 521 // YD TODO probably checkconnection() call can be removed since we 522 // detect broken pipes inside _DosTransactNPipe 515 523 if (!pConn->rc) 516 524 { … … 537 545 return ERROR_PIPE_NOT_CONNECTED; 538 546 } 547 548 // if we are reconnecting pipe because of a broken pipe, we 549 // need to save shared memory content to allow operation retry 550 mem = malloc( pConn->pRes->memlen); 551 if (mem) 552 memcpy( mem, pConn->mem, pConn->pRes->memlen); 553 554 // reinit connection 539 555 do { 540 556 req.request = SMBREQ_INIT; … … 554 570 break; 555 571 } 556 557 572 MemCpy(pConn->mem, &pConn->srv, sizeof(pConn->srv)); 573 558 574 req.request = SMBREQ_CONNECT; 559 575 req.param = pConn->mem; … … 568 584 } 569 585 MemCpy(&pConn->srv, pConn->mem, sizeof(pConn->srv)); 586 570 587 rc = NO_ERROR; 571 588 } while (0); 572 589 590 // if we are reconnecting pipe because of a broken pipe, we 591 // need to restore shared memory content to allow operation retry 592 if (mem) { 593 memcpy( pConn->mem, mem, pConn->pRes->memlen); 594 free( mem); 595 } 596 573 597 if (pConn->rc && pConn->pipe) 574 598 { … … 576 600 pConn->pipe = 0; 577 601 } 602 return rc; 603 } 604 605 /* 606 * YD Since DosQueryNPHState, 607 * DosQueryNPipeInfo, DosPeekNPipe, DosResetBuffer, are all returning 608 * NO_ERROR even if the other pipe end is closed (smbcd crash), 609 * we can detect broken pipes only when writing/reading from the pipe. 610 */ 611 ULONG APIENTRY _DosTransactNPipe(Connection *pConn, PVOID pOutbuf, ULONG ulOutbufLength, 612 PVOID pInbuf, ULONG ulInbufLength, PULONG pulBytesRead) 613 { 614 APIRET rc; 615 616 // try first 617 rc = DosTransactNPipe(pConn->pipe, pOutbuf, ulOutbufLength, pInbuf, ulInbufLength, pulBytesRead); 618 if (rc != ERROR_BROKEN_PIPE) 619 return rc; 620 // client daemon closed, force open connection again 621 pConn->rc = rc; 622 checkconnection( pConn); 623 // issue command again 624 rc = DosTransactNPipe(pConn->pipe, pOutbuf, ulOutbufLength, pInbuf, ulInbufLength, pulBytesRead); 578 625 return rc; 579 626 } … … 681 728 req.paramlen = 0; 682 729 683 DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);730 rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 684 731 685 732 req.request = SMBREQ_CONNECT; … … 688 735 req.paramlen = sizeof(pConn->srv); 689 736 690 rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);737 rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 691 738 if (rc || action < sizeof(resp) || resp.rc) 692 739 { 740 APIRET rc2; 693 741 rc = rc ? rc : (resp.rc ? resp.rc : ERROR_INVALID_PARAMETER); 694 742 MemCpy(tmp, &pRes->srv, sizeof(pRes->srv)); 695 DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);743 rc2 = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 696 744 // TODO: what to do if the reconnect will fail ? 697 745 } … … 790 838 req.request = SMBREQ_INIT; 791 839 req.param = (char *)0xFFFFFFFF; 792 rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);840 rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 793 841 if (rc || action < sizeof(resp) || resp.rc) 794 842 { … … 815 863 req.length = req.paramlen; 816 864 817 rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);865 rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 818 866 if (rc || action < sizeof(resp) || resp.rc) 819 867 { … … 865 913 req.paramlen = sizeof(pConn->file); 866 914 867 DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);915 _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 868 916 pConn->file.fd = -1; 869 917 } … … 874 922 req.paramlen = 0; 875 923 876 DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);924 _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 877 925 878 926 DosFreeMem(pConn->mem); … … 1080 1128 do { 1081 1129 int i; 1082 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1130 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1083 1131 if (pConn->rc || action < sizeof(resp) 1084 1132 || (resp.rc && resp.rc != ERROR_MORE_DATA)) … … 1177 1225 req.paramlen = sizeof(*finfo); 1178 1226 req.length = req.paramlen; 1179 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1227 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1180 1228 if (pConn->rc || action < sizeof(resp) || resp.rc) 1181 1229 { … … 1218 1266 { 1219 1267 *p = 0; 1220 rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1268 rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1221 1269 if (pConn->rc || action < sizeof(resp) || resp.rc) 1222 1270 { … … 1297 1345 req.paramlen = sizeof(*finfo); 1298 1346 req.length = req.paramlen; 1299 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1347 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1300 1348 if (pConn->rc || action < sizeof(resp) || resp.rc) 1301 1349 { … … 1411 1459 req.length = pRes->memlen - req.paramlen; 1412 1460 pFEASrc = (FEALIST *)(pConn->mem + req.paramlen); 1413 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1461 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1414 1462 if (pConn->rc || action < sizeof(resp) || resp.rc) 1415 1463 { … … 1492 1540 req.paramlen = pFEAList->cbList + CCHMAXPATH + 1; 1493 1541 req.length = req.paramlen; 1494 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1542 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1495 1543 if (pConn->rc || action < sizeof(resp) || resp.rc) 1496 1544 { … … 1556 1604 req.length = pRes->memlen - req.paramlen; 1557 1605 pfealist = (FEALIST *)(pConn->mem + req.paramlen); 1558 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1606 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1559 1607 if (pConn->rc || action < sizeof(resp) || resp.rc) 1560 1608 { … … 1612 1660 req.paramlen = CCHMAXPATH + 1; 1613 1661 req.length = req.paramlen; 1614 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1662 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1615 1663 if (pConn->rc || action < sizeof(resp) || resp.rc) 1616 1664 { … … 1663 1711 req.paramlen = CCHMAXPATH + 1; 1664 1712 req.length = req.paramlen; 1665 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1713 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1666 1714 if (pConn->rc || action < sizeof(resp) || resp.rc) 1667 1715 { … … 1702 1750 req.paramlen = CCHMAXPATH + 1; 1703 1751 req.length = req.paramlen; 1704 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1752 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1705 1753 if (pConn->rc || action < sizeof(resp) || resp.rc) 1706 1754 { … … 1741 1789 req.paramlen = CCHMAXPATH + 1; 1742 1790 req.length = req.paramlen; 1743 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1791 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1744 1792 if (pConn->rc || action < sizeof(resp) || resp.rc) 1745 1793 { … … 1796 1844 req.paramlen = 2 * (CCHMAXPATH + 1); 1797 1845 req.length = req.paramlen; 1798 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1846 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1799 1847 if (pConn->rc || action < sizeof(resp) || resp.rc) 1800 1848 { … … 1871 1919 req.paramlen = sizeof(pConn->file); 1872 1920 req.length = req.paramlen; 1873 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);1921 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1874 1922 if (pConn->rc || action < sizeof(resp) || resp.rc) 1875 1923 { … … 1951 1999 req.paramlen = sizeof(*finfo); 1952 2000 req.length = req.paramlen; 1953 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);2001 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 1954 2002 if (pConn->rc || action < sizeof(resp) || resp.rc) 1955 2003 { … … 2003 2051 req.paramlen = sizeof(pConn->file); 2004 2052 req.length = req.paramlen + sizeof(*finfo); 2005 rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);2053 rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 2006 2054 if (pConn->rc || action < sizeof(resp) || resp.rc) 2007 2055 { … … 2065 2113 req.length = pRes->memlen - req.paramlen; 2066 2114 pFEASrc = (FEALIST *)(pConn->mem + req.paramlen); 2067 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);2115 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 2068 2116 if (pConn->rc || action < sizeof(resp) || resp.rc) 2069 2117 { … … 2139 2187 req.length = req.paramlen; 2140 2188 2141 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);2189 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 2142 2190 if (pConn->rc || action < sizeof(resp) || resp.rc) 2143 2191 { … … 2188 2236 req.length = pRes->memlen - req.paramlen; 2189 2237 pfealist = (FEALIST *)(pConn->mem + req.paramlen); 2190 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);2238 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 2191 2239 if (pConn->rc || action < sizeof(resp) || resp.rc) 2192 2240 { … … 2283 2331 req.paramlen = sizeof(pConn->file) + sizeof(long) + sizeof(long long); 2284 2332 req.length = req.paramlen; 2285 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);2333 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 2286 2334 if (pConn->rc || action < sizeof(resp) || resp.rc) 2287 2335 { … … 2337 2385 req.paramlen = sizeof(pConn->file); 2338 2386 req.length = req.paramlen; 2339 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);2387 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 2340 2388 if (pConn->rc || action < sizeof(resp) || resp.rc) 2341 2389 { … … 2396 2444 req.length = req.paramlen; 2397 2445 2398 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);2446 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 2399 2447 if (pConn->rc || action < sizeof(resp) || resp.rc) 2400 2448 { … … 2445 2493 req.length = req.paramlen + (pRes->memlen - req.paramlen < (ulRead - done) ? pRes->memlen - req.paramlen : (ulRead - done)); 2446 2494 2447 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);2495 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 2448 2496 if (pConn->rc || action < sizeof(resp) || resp.rc) 2449 2497 { … … 2502 2550 req.length += req.paramlen; 2503 2551 2504 pConn->rc = DosTransactNPipe(pConn->pipe, &req, sizeof(req), &resp, sizeof(resp), &action);2552 pConn->rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action); 2505 2553 if (pConn->rc || action < sizeof(resp) || resp.rc) 2506 2554 { -
trunk/samba/source/ndpsmb/smbcd.c
r69 r70 299 299 cli_state * cli = *_cli; 300 300 301 if (!pipe || ! *cli || !reconnect || !srv || !req || !req->param || req->paramlen > req->length || !res)301 if (!pipe || !_cli || !reconnect || !srv || !req || !req->param || req->paramlen > req->length || !res) 302 302 { 303 303 debuglocal(0,"invalid structures\n");
Note:
See TracChangeset
for help on using the changeset viewer.