Changeset 897 for branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c
- Timestamp:
- Mar 21, 2019, 4:14:14 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c
r890 r897 3 3 * Author : Gérald FENOY 4 4 * 5 * Copyright 2017 GeoLabs SARL. All rights reserved.5 * Copyright 2017-2019 GeoLabs SARL. All rights reserved. 6 6 * 7 7 * This work was supported by public funds received in the framework of GEOSUD, … … 322 322 */ 323 323 bool ssh_copy(maps* conf,const char* localPath,const char* targetPath,int cnt){ 324 char mem[1024 * 1 000];324 char mem[1024 * 16]; 325 325 size_t nread; 326 326 size_t memuse=0; 327 327 time_t start; 328 328 long total = 0; 329 int counter=0; 329 330 int duration; 330 331 int rc; … … 391 392 break; 392 393 393 if(memuse - rc) { 394 memmove(&mem[0], &mem[rc], memuse - rc); 395 memuse -= rc; 396 } 397 else 398 memuse = 0; 394 memuse = 0; 399 395 400 396 } while (rc > 0); … … 438 434 } 439 435 if(!sessions[cnt]->sftp_session) 440 zSleep(1 );436 zSleep(10); 441 437 } while (!sessions[cnt]->sftp_session); 442 438 do { … … 453 449 } 454 450 if(!sftp_handle) 455 zSleep(1 );451 zSleep(10); 456 452 } while (!sftp_handle); 457 453 458 454 int result=0; 455 int counter=0; 459 456 do { 460 457 do { 461 char* mem=(char*)malloc(16*1024 *1024);462 rc = libssh2_sftp_read(sftp_handle, mem,16*1024 *1024);458 char* mem=(char*)malloc(16*1024); 459 rc = libssh2_sftp_read(sftp_handle, mem,16*1024); 463 460 if(rc > 0) { 464 461 fwrite(mem, rc, 1, local); 465 462 } 466 463 free(mem); 464 if(counter%25==0) 465 zSleep(10); 467 466 } while (rc > 0); 468 467 469 468 if(rc != LIBSSH2_ERROR_EAGAIN) { 470 469 result=-1; 471 470 break; 472 471 } 473 472 474 473 struct timeval timeout; 475 474 fd_set fd; 476 475 timeout.tv_sec = 10; 477 476 timeout.tv_usec = 0; 478 477 479 478 FD_ZERO(&fd); 480 479 481 480 FD_SET(sessions[cnt]->sock_id, &fd); 482 481 483 482 rc = select(sessions[cnt]->sock_id+1, &fd, &fd, NULL, &timeout); 484 483 if(rc <= 0) { … … 489 488 return -1; 490 489 } 491 490 491 if(counter%50==0) 492 zSleep(10); 493 counter++; 494 492 495 } while (1); 493 496 duration = (int)(time(NULL)-start);
Note: See TracChangeset
for help on using the changeset viewer.