Ignore:
Timestamp:
Apr 30, 2009, 10:45:50 AM (16 years ago)
Author:
Yuri Dario
Message:

Enable reconnection on level change, fixes ticket:66.

File:
1 edited

Legend:

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

    r179 r180  
    598598        rootlevel = pRes->rootlevel;
    599599        if (*path == '\\') path++;
    600 #if 0 // FIXME
     600
    601601        if (rootlevel < 3)
    602602        {
    603603                char * p;
     604                // flag: 1 parameters changed, reconnection required, 0 do nothing
    604605                int newlevel = 0;
    605                 smbwrp_server * tmp = (smbwrp_server *)pConn->mem;
    606                 MemCpy(tmp, &pConn->srv, sizeof(pConn->srv));
     606                // use a temporary resource to test disconnection/reconnection
     607                Resource tmpRes;
     608                // copy exising data
     609                memcpy( &tmpRes, pRes, sizeof( tmpRes));
     610                // pointer to new connection fields
     611                smbwrp_server * tmp = &tmpRes.srv;
    607612                if (rootlevel == 0)
    608613                {
     
    657662                if (newlevel)
    658663                {
    659                         // reconnect to server here
    660                         unsigned long action;
    661                         smb_request req = {0};
    662                         smb_response resp = {0};
    663 
    664                         req.request = SMBREQ_DISCONNECT;
    665                         req.param = pConn->mem;
    666                         req.length = 0;
    667                         req.paramlen = 0;
    668 
    669                         rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action);
    670 
    671                         req.request = SMBREQ_CONNECT;
    672                         req.param = pConn->mem;
    673                         req.length = pRes->memlen;
    674                         req.paramlen = sizeof(pConn->srv);
    675 
    676                         rc = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action);
    677                         if (rc || action < sizeof(resp) || resp.rc)
     664                        // reconnect to server here, first test new connection
     665                        cli_state* tmp_cli = NULL;
     666                        rc = smbwrp_connect( &tmpRes, &tmp_cli);
     667                        if (!rc)
    678668                        {
    679                                 APIRET rc2;
    680                                 rc = rc ? rc : (resp.rc ? resp.rc : ERROR_INVALID_PARAMETER);
    681                                 MemCpy(tmp, &pRes->srv, sizeof(pRes->srv));
    682                                 rc2 = _DosTransactNPipe(pConn, &req, sizeof(req), &resp, sizeof(resp), &action);
    683                                 // TODO: what to do if the reconnect will fail ?
     669                                // new connection is ok, disconnect old one
     670                                cli_state* cli = pConn->cli;
     671                                smbwrp_disconnect( pRes, cli);
     672                                // save tmp data structure
     673                                memcpy( pRes, &tmpRes, sizeof( tmpRes));
     674                                // save new connection handle
     675                                pConn->cli = tmp_cli;
    684676                        }
    685                         else
    686                         {
    687                                 MemCpy(&pConn->srv, tmp, sizeof(pConn->srv));
    688                         }
    689                 }
    690         }
    691 #endif
     677                }
     678        }
     679
    692680        StrCpy(result, "\\");
    693681        StrNCat(result, path, CCHMAXPATH);
Note: See TracChangeset for help on using the changeset viewer.