Changeset 862 for branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c
- Timestamp:
- Feb 1, 2018, 11:27:28 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c
r860 r862 205 205 return NULL; 206 206 207 libssh2_session_set_blocking(result->session, 0);207 libssh2_session_set_blocking(result->session, 1); 208 208 209 209 while ((rc = libssh2_session_handshake(result->session, result->sock_id)) … … 418 418 */ 419 419 int ssh_fetch(maps* conf,const char* localPath,const char* targetPath,int cnt){ 420 char mem[1024];421 420 size_t nread; 422 421 size_t memuse=0; … … 436 435 if (!sessions[cnt]->sftp_session && 437 436 (libssh2_session_last_errno(sessions[cnt]->session) != LIBSSH2_ERROR_EAGAIN)) { 438 439 437 fprintf(stderr, "Unable to init SFTP session\n"); 440 438 return -1; … … 452 450 } 453 451 else { 454 //non-blocking open455 452 waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session); 456 453 } 457 454 } 455 if(!sftp_handle) 456 zSleep(100); 458 457 } while (!sftp_handle); 459 458 … … 461 460 do { 462 461 do { 463 rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem)); 464 /*fprintf(stderr, "libssh2_sftp_read returned %d\n", 465 rc);*/ 462 char* mem=(char*)malloc(16*1024*1024); 463 rc = libssh2_sftp_read(sftp_handle, mem,16*1024*1024); 466 464 if(rc > 0) { 467 //write(2, mem, rc);468 465 fwrite(mem, rc, 1, local); 469 466 } 467 free(mem); 470 468 } while (rc > 0); 471 469 … … 585 583 */ 586 584 bool ssh_close_session(maps* conf,SSHCON* con){ 585 if(con==NULL) 586 return true; 587 587 while (libssh2_session_disconnect(con->session, "Normal Shutdown, Thank you for using the ZOO-Project sshapi") 588 588 == LIBSSH2_ERROR_EAGAIN); … … 593 593 #endif 594 594 libssh2_session_free(con->session); 595 con=NULL; 595 596 return true; 596 597 } … … 639 640 getMapArray(input->content,"targetPath",i)}; 640 641 641 setMapArray(queueMaps->content,"input",queueIndex ,input->name);642 setMapArray(queueMaps->content,"localPath",queueIndex ,tmp[0]->value);643 setMapArray(queueMaps->content,"targetPath",queueIndex ,tmp[1]->value);644 queueIndex+=1; 642 setMapArray(queueMaps->content,"input",queueIndex+i,input->name); 643 setMapArray(queueMaps->content,"localPath",queueIndex+i,tmp[0]->value); 644 setMapArray(queueMaps->content,"targetPath",queueIndex+i,tmp[1]->value); 645 645 646 } 646 647 } 647 648 } 648 #ifdef SSH_DEBUG649 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);650 fflush(stderr);651 dumpMaps(queueMaps);652 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);653 fflush(stderr);654 dumpMaps(*conf);655 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);656 fflush(stderr);657 #endif658 649 return true; 659 650 } … … 664 655 return false; 665 656 } 666 #ifdef SSH_DEBUG667 fprintf(stderr,"*** %s %d\n",__FILE__,__LINE__);668 fflush(stderr);669 dumpMaps(getMaps(*conf,"uploadQueue"));670 fprintf(stderr,"*** %s %d\n",__FILE__,__LINE__);671 fflush(stderr);672 #endif673 657 map* queueLengthMap=getMapFromMaps(*conf,"uploadQueue","length"); 674 658 maps* queueMaps=getMaps(*conf,"uploadQueue"); … … 682 666 getMapArray(queueMaps->content,"targetPath",i) 683 667 }; 684 #ifdef SSH_DEBUG685 fprintf(stderr,"*** %s %d %s %s\n",__FILE__,__LINE__,argv[1]->value,argv[2]->value);686 #endif687 668 /**/zooLock* lck; 688 669 if((lck=lockFile(*conf,argv[1]->value,'w'))!=NULL){/**/ … … 703 684 } 704 685 } 686 while (libssh2_session_disconnect(test->session, "Normal Shutdown, Thank you for using the ZOO-Project sshapi") 687 == LIBSSH2_ERROR_EAGAIN); 688 #ifdef WIN32 689 closesocket(test->sock_id); 690 #else 691 close(test->sock_id); 692 #endif 693 libssh2_session_free(test->session); 694 free(test); 695 test=NULL; 696 sessions[ssh_get_cnt(*conf)-1]=NULL; 697 maps* tmp=getMaps(*conf,"lenv"); 698 addIntToMap(tmp->content,"nb_sessions",ssh_get_cnt(*conf)-1); 699 705 700 return true; 706 701 }
Note: See TracChangeset
for help on using the changeset viewer.