/[mldonkey]/mldonkey/src/networks/bittorrent/bTClients.ml
ViewVC logotype

Diff of /mldonkey/src/networks/bittorrent/bTClients.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.44 by spiralvoice, Thu Aug 4 22:00:23 2005 UTC revision 1.45 by spiralvoice, Sun Aug 7 12:57:21 2005 UTC
# Line 496  let rec client_parse_header counter cc i Line 496  let rec client_parse_header counter cc i
496      set_client_state (c) (Connected (-1));      set_client_state (c) (Connected (-1));
497      if not init_sent then      if not init_sent then
498        begin        begin
499          c.client_incoming<-true;          c.client_incoming <- true;
500          send_init !!client_uid file_id sock;          send_init !!client_uid file_id sock;
501        end;        end;
502      connection_ok c.client_connection_control;      connection_ok c.client_connection_control;
# Line 511  let rec client_parse_header counter cc i Line 511  let rec client_parse_header counter cc i
511        in common swarmer -> compare : partition -> partition -> bool        in common swarmer -> compare : partition -> partition -> bool
512      *)      *)
513    
 (*    send_client c Unchoke;  *)  
   
514      set_rtimeout sock !!client_timeout;      set_rtimeout sock !!client_timeout;
515  (*Once parse succesfully we define the function      (* Once parsed succesfully we define the function client_to_client
516      client_to_client to be the function used when a message         to be the function used when a message is read *)
     is read*)  
517      gconn.gconn_handler <- Reader (fun gconn sock ->      gconn.gconn_handler <- Reader (fun gconn sock ->
518          bt_handler TcpMessages.parsing (client_to_client c) c sock          bt_handler TcpMessages.parsing (client_to_client c) c sock
519      );      );
# Line 576  and update_client_bitmap c = Line 573  and update_client_bitmap c =
573  *)  *)
574  and get_from_client sock (c: client) =  and get_from_client sock (c: client) =
575    let file = c.client_file in    let file = c.client_file in
576  (*Check if there's not enough requests in the 'pipeline'    (* Check if there's not enough requests in the 'pipeline'
577      and if a request can be send (not choked and file is downloading) *)       and if a request can be send (not choked and file is downloading) *)
578    if List.length c.client_ranges_sent < max_range_requests &&    if List.length c.client_ranges_sent < max_range_requests &&
579      file_state file = FileDownloading && (c.client_choked == false) then      file_state file = FileDownloading && (c.client_choked == false) then
580  (*num is the number of the piece, x and y are the position    (* num is the number of the piece, x and y are the position
581  of the subpiece in the piece(!), r is a (CommonSwarmer) range *)       of the subpiece in the piece(!), r is a (CommonSwarmer) range *)
582    
583      let up = match c.client_uploader with      let up = match c.client_uploader with
584          None -> assert false          None -> assert false
# Line 749  and client_to_client c sock msg = Line 746  and client_to_client c sock msg =
746                    [] -> lprintf_nl () "EMPTY Ranges !!!"                    [] -> lprintf_nl () "EMPTY Ranges !!!"
747                  | (p1,p2,r) :: _ ->                  | (p1,p2,r) :: _ ->
748                      let (x,y) = Int64Swarmer.range_range r in                      let (x,y) = Int64Swarmer.range_range r in
749                      lprintf_nl () "Current range %Ld [%d] (asked %Ld-%Ld[%Ld-%Ld])"                      lprintf_nl () "Current range from %s : %Ld [%d] (asked %Ld-%Ld[%Ld-%Ld])"
750                        position len                        c.client_software position len
751                        p1 p2 x y                        p1 p2 x y
752                );                );
753    
# Line 845  and client_to_client c sock msg = Line 842  and client_to_client c sock msg =
842    
843                let verified = Int64Swarmer.verified_bitmap swarmer in                let verified = Int64Swarmer.verified_bitmap swarmer in
844                let npieces = Int64Swarmer.partition_size swarmer in                let npieces = Int64Swarmer.partition_size swarmer in
845                  (* parse the pieces to see if the client is interesting *)
846                for i = 0 to npieces -1  do                for i = 0 to npieces -1  do
847                  (* lprintf "bitmap: %c, verified: %c" bitmap.[i] verified.[i]; *)                  (* lprintf "bitmap: %c, verified: %c" bitmap.[i] verified.[i]; *)
848                  if bitmap.[i] = '1' && verified.[i] < '2' then                  if bitmap.[i] = '1' && verified.[i] < '2' then
# Line 882  and client_to_client c sock msg = Line 880  and client_to_client c sock msg =
880                let n = Int64.to_int n in                let n = Int64.to_int n in
881                let verified = Int64Swarmer.verified_bitmap swarmer in                let verified = Int64Swarmer.verified_bitmap swarmer in
882                (* lprintf_nl "verified: %c;" verified.[n]; *)                (* lprintf_nl "verified: %c;" verified.[n]; *)
883                  (* if the peer has a chunk we don't, tell him we're interested and update his bitmap *)
884                if verified.[n] < '2' then begin                if verified.[n] < '2' then begin
885                    c.client_interesting <- true;                    c.client_interesting <- true;
886                    send_interested c;                    send_interested c;
# Line 967  and client_to_client c sock msg = Line 966  and client_to_client c sock msg =
966                    [] ->                    [] ->
967                        CommonUploads.ready_for_upload (as_client c);                        CommonUploads.ready_for_upload (as_client c);
968                    | _ -> ());                    | _ -> ());
969                  c.client_upload_requests <-                  c.client_upload_requests <- c.client_upload_requests @ [n,pos,len];
                   c.client_upload_requests @ [n,pos,len];  
970                  let file = c.client_file in                  let file = c.client_file in
971                  match file.file_shared with                  match file.file_shared with
972                      None -> ()                      None -> ()
# Line 1158  let listen () = Line 1156  let listen () =
1156        ) in        ) in
1157      listen_sock := Some s;      listen_sock := Some s;
1158      ()      ()
1159    with e ->    with e ->
1160        if !verbose_connect then        if !verbose_connect then
1161          lprintf_nl () "Exception %s while init bittorrent server"          lprintf_nl () "Exception %s while init bittorrent server"
1162            (Printexc2.to_string e)            (Printexc2.to_string e)
# Line 1243  let get_sources_from_tracker file = Line 1241  let get_sources_from_tracker file =
1241          File.to_string filename          File.to_string filename
1242        with e -> lprintf_nl () "Empty reply from tracker"; ""        with e -> lprintf_nl () "Empty reply from tracker"; ""
1243      in      in
1244      let v =      let v =
1245         match tracker_reply with         match tracker_reply with
1246         | "" ->         | "" ->
1247          if !verbose_connect then          if !verbose_connect then

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26