Ignore:
Timestamp:
Jul 26, 2016, 11:47:31 AM (9 years ago)
Author:
Paul Smedley
Message:

Introduce smb_echo, used to confirm server connection is still active before trying a connection

Location:
branches/client-3.0/src
Files:
3 edited

Legend:

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

    r932 r933  
    11881188                debuglocal(9,"NdpFindStart: dir [%s], dir_mask [%s], mask [%s], szPath [%s]\n",
    11891189                        state.dir, state.dir_mask, state.mask, state.fullpath);
     1190
     1191                /* use cli_echo to check the connection is alive - if not, reconnect */
     1192                rc = smbwrp_echo(pConn->cli);
     1193                if (rc)
     1194                {
     1195                debuglocal(4,"NdpFindStart, smbwrp_echo rc = %d, reconnecting.....\n",rc);
     1196                        int rcCon = smbwrp_connect( pRes, &pConn->cli);
     1197                        if (rcCon)
     1198                                return ERROR_PATH_NOT_FOUND;
     1199                }
    11901200                rc = smbwrp_filelist( &pRes->srv, pConn->cli, &state);
    11911201                // we need to handle reconnection also here, because NdpQueryPathInfo
  • branches/client-3.0/src/smbwrp.c

    r931 r933  
    12211221}
    12221222
     1223/*****************************************************
     1224Send an echo to the server to confirm it is still alive
     1225*******************************************************/
     1226int _System smbwrp_echo(cli_state * cli)
     1227{
     1228        debuglocal(4," smbwrp_echo\n");
     1229        unsigned char garbage[16];
     1230        NTSTATUS status;
     1231        if (!cli)
     1232        {
     1233                return maperror(EINVAL);
     1234        }
     1235        /* Ping the server to keep the connection alive using SMBecho. */
     1236        memset(garbage, 0xf0, sizeof(garbage));
     1237        unsigned int old_timeout = cli->timeout;
     1238        cli->timeout = 2000;// we don't want to wait 20 seconds
     1239        status = cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage)));
     1240        cli->timeout = old_timeout; // reset back to previous value
     1241        if (NT_STATUS_IS_OK(status)) {
     1242                return 0;
     1243        } else {
     1244                return -1;
     1245        }
     1246}
  • branches/client-3.0/src/smbwrp.h

    r931 r933  
    197197int _System smbwrp_flistea(cli_state * cli, smbwrp_file *file, void * buffer, unsigned long size);
    198198int _System smbwrp_dskattr(cli_state * cli, FSALLOCATE *pfsa);
     199int _System smbwrp_echo(cli_state * cli);
    199200
    200201/* Directory cache helpers. */
Note: See TracChangeset for help on using the changeset viewer.