From 658f4f8037c93e0d1d669087f8f17d637c4108fc Mon Sep 17 00:00:00 2001 From: spiralvoice Date: Wed, 8 Sep 2010 16:26:04 +0000 Subject: [PATCH] patch #7306 --- distrib/ChangeLog | 3 ++ src/networks/direct_connect/dcClients.ml | 34 ++++++++------ src/networks/direct_connect/dcGlobals.ml | 79 ++++++++++++++++++-------------- src/networks/direct_connect/dcTypes.ml | 5 +- 4 files changed, 72 insertions(+), 49 deletions(-) diff --git a/distrib/ChangeLog b/distrib/ChangeLog index 15a161ce..e18be150 100644 --- a/distrib/ChangeLog +++ b/distrib/ChangeLog @@ -14,6 +14,9 @@ http://mldonkey.sourceforge.net/Windows#MinGW_Installation ChangeLog ========= +2010/09/08 +7306: DC: show client brand, session transfer and duration + 2010/09/07 7302: DC: Fix performance problem with many shared files (ygrek) 7299: configure: abort on unknown options diff --git a/src/networks/direct_connect/dcClients.ml b/src/networks/direct_connect/dcClients.ml index f4a4bbb3..c20e4d44 100644 --- a/src/networks/direct_connect/dcClients.ml +++ b/src/networks/direct_connect/dcClients.ml @@ -722,8 +722,7 @@ let rec client_reader c t sock = if !verbose_msg_clients then lprintf_nl " Client won the election..."; (match c.client_state with (* memorize list loading if that is the case *) | DcConnectionStyle _ -> (* if file was tried to download ... *) - let nc = new_client () in - copy_client c nc; + let nc = new_copy_client c in nc.client_sock <- NoConnection; nc.client_addr <- None; (match c.client_file with @@ -737,8 +736,7 @@ let rec client_reader c t sock = | None -> () ); remove_client_from_clients_file c | _ -> (* DcDownloadListConnecting *) (* if filelist was tried to download *) - let nc = new_client () in - copy_client c nc; + let nc = new_copy_client c in nc.client_sock <- NoConnection; nc.client_addr <- None; (match c.client_user with @@ -1325,7 +1323,8 @@ let client_downloaded c sock nread = (* TODO check tth while loading, abort if e c.client_pos <- c.client_pos ++ downloaded; (match c.client_user with | Some u -> u.user_downloaded <- u.user_downloaded ++ downloaded - | _ -> () ); + | _ -> () ); + c.client_downloaded <- c.client_downloaded ++ downloaded; buf_used b b.len; if c.client_pos > (file_downloaded file) then (* update downloading state *) (* TODO check tth while loading *) add_file_downloaded (as_file file.file_file) (c.client_pos -- (file_downloaded file)); @@ -1350,11 +1349,12 @@ let client_downloaded c sock nread = (* TODO check tth while loading, abort if e (match c.client_user with | Some u -> u.user_downloaded <- u.user_downloaded ++ len | _ -> () ); + c.client_downloaded <- c.client_downloaded ++ len; c.client_receiving <- c.client_receiving -- len; buf_used b b.len; if c.client_receiving = Int64.zero then begin Unix32.close filelist_fd; - if !verbose_download then lprintf_nl "Received filelist from (%s)" (clients_username c); + if !verbose_download then lprintf_nl "Received filelist from (%s)" (clients_username c); c.client_receiving <- Int64.zero; (* this marks client as receiving commands again *) c.client_pos <- Int64.zero; TcpBufferedSocket.set_rtimeout sock infinite_timeout; @@ -1524,6 +1524,7 @@ let dc_upload c bytes = (match c.client_user with | Some u -> u.user_uploaded <- u.user_uploaded ++ uploaded | _ -> () ); + c.client_uploaded <- c.client_uploaded ++ uploaded; (match c.client_state with | DcUpload (dcsh,_,_,_) -> (try @@ -1565,12 +1566,12 @@ module P = GuiTypes let _ = client_ops.op_client_info <- (fun c -> let name = clients_username c in - let kind,downloaded,uploaded = + let kind,total_downloaded,total_uploaded = let ip,port = (match c.client_addr with | Some (ip,port) -> ip,port | None -> Ip.null,0 ) - in + in (match c.client_user with | Some user -> let kind = @@ -1582,6 +1583,11 @@ let _ = let kind = Indirect_location (empty_string,Md4.null,ip,port) in kind,Int64.zero,Int64.zero ) in + let software, version = + match c.client_user with + | Some u -> u.user_myinfo.client_brand, u.user_myinfo.version + | None -> empty_string, empty_string + in let filename = (match c.client_file with | Some file -> file.file_name @@ -1594,12 +1600,14 @@ let _ = P.client_type = client_type c; P.client_name = name; P.client_num = (client_num (as_client c.client_client)); - P.client_connect_time = last_time (); - P.client_software = empty_string; - P.client_release = empty_string; + P.client_connect_time = c.client_connect_time; + P.client_software = software; + P.client_release = version; P.client_emulemod = empty_string; - (*P.client_downloaded = downloaded;*) - (*P.client_uploaded = uploaded;*) + P.client_session_downloaded = c.client_downloaded; + P.client_session_uploaded = c.client_uploaded; + P.client_total_downloaded = total_downloaded; + P.client_total_uploaded = total_uploaded; P.client_upload = Some filename; P.client_sui_verified = None; (* new 2.6.5 *) (* P.client_sock_addr = ""; *) diff --git a/src/networks/direct_connect/dcGlobals.ml b/src/networks/direct_connect/dcGlobals.ml index 5a0c720e..e79aaf40 100644 --- a/src/networks/direct_connect/dcGlobals.ml +++ b/src/networks/direct_connect/dcGlobals.ml @@ -559,7 +559,7 @@ let new_file tiger_root (directory:string) (filename:string) (file_size:int64) = impl_file_received = current_size; impl_file_val = file; impl_file_ops = file_ops; - impl_file_age = last_time (); + impl_file_age = last_time (); impl_file_best_name = filename; } in file_add impl FileNew; (* CommonInteractive.file_add *) @@ -577,42 +577,45 @@ let file_size file = file.file_file.impl_file_size let file_downloaded file = file_downloaded (as_file file.file_file) let file_age file = file.file_file.impl_file_age let file_fd file = file_fd (as_file file.file_file) - -(* Add new client, return client*) + +(* Add new client, return client*) let new_client () = let rec c = { client_client = impl; client_sock = NoConnection; - client_name = None; + client_name = None; client_addr = None; - client_supports = None; - client_lock = ""; - client_file = None; (* (file, filename) *) - client_state = DcIdle; - client_error = NoError; - client_error_count = 0; - client_preread_bytes_left = 0; + client_supports = None; + client_lock = ""; + client_file = None; (* (file, filename) *) + client_state = DcIdle; + client_error = NoError; + client_error_count = 0; + client_preread_bytes_left = 0; client_pos = Int64.zero; - client_endpos = Int64.zero; (* atm. upload end position *) + client_endpos = Int64.zero; (* atm. upload end position *) client_receiving = Int64.zero; - client_user = None; + client_user = None; + client_connect_time = last_time (); client_connection_control = new_connection_control (); + client_downloaded = Int64.zero; + client_uploaded = Int64.zero; } and impl = { dummy_client_impl with impl_client_val = c; impl_client_ops = client_ops; impl_client_upload = None; } in - (*lprintf_nl "New client"; *) - CommonClient.new_client impl; - clients_list := c :: !clients_list; + (*lprintf_nl "New client"; *) + CommonClient.new_client impl; + clients_list := c :: !clients_list; c -(* add client to file & vice versa *) +(* add client to file & vice versa *) let add_client_to_file client file = (* TODO we never empty files clients list so implement some kind of size control *) if not (List.memq client file.file_clients) then begin (* if client is not on file's contact list... *) file.file_clients <- client :: file.file_clients; (* then add this new client to file contact list *) - client.client_file <- Some file; + client.client_file <- Some file; (*file_add_source (as_file file.file_file) (as_client client.client_client)*) (* CommonFile.file_add_source *) end @@ -622,7 +625,7 @@ let add_client_to_user client user = user.user_clients <- user.user_clients @ [ client ]; (* add client to userlist *) client.client_user <- Some user end - + (* New client to user with file *) let new_client_to_user_with_file u f = let c = new_client () in @@ -630,10 +633,10 @@ let new_client_to_user_with_file u f = add_client_to_user c u; add_client_to_file c f; c - + let client_type c = client_type (as_client c.client_client) - + (* Find clients by name, return list of all matching clients *) (*let find_clients_by_name name = let result = ref [] in @@ -670,20 +673,26 @@ let client_state_to_string c = | DcUploadDoneWaitingForMore -> "DcUploadDoneWaitingForMore" ) (* Copy client data to another *) -let copy_client c nc = - (*nc.client_sock <- c.client_sock;*) - nc.client_name <- c.client_name; - nc.client_addr <- c.client_addr; - nc.client_supports <- c.client_supports; - nc.client_lock <- c.client_lock; - nc.client_file <- c.client_file; - (*nc.client_state <- c.client_state;*) - nc.client_pos <- c.client_pos; - nc.client_receiving <- c.client_receiving; - nc.client_user <- c.client_user; - nc.client_error <- c.client_error; - nc.client_error_count <- c.client_error_count; - nc.client_endpos <- c.client_endpos +let new_copy_client c = + { + (new_client ()) with + (*client_sock = c.client_sock;*) + client_name = c.client_name; + client_addr = c.client_addr; + client_supports = c.client_supports; + client_lock = c.client_lock; + client_file = c.client_file; + (*client_state = c.client_state;*) + client_pos = c.client_pos; + client_receiving = c.client_receiving; + client_user = c.client_user; + client_error = c.client_error; + client_error_count = c.client_error_count; + client_endpos = c.client_endpos; + client_connect_time = c.client_connect_time; + client_downloaded = c.client_downloaded; + client_uploaded = c.client_uploaded; + } (* Get clients username *) let clients_username client = diff --git a/src/networks/direct_connect/dcTypes.ml b/src/networks/direct_connect/dcTypes.ml index fbcaeb98..855ba2ba 100644 --- a/src/networks/direct_connect/dcTypes.ml +++ b/src/networks/direct_connect/dcTypes.ml @@ -154,7 +154,7 @@ and dc_shared_file = { mutable dc_shared_chunks : int; } -and client = { (* remember DcGlobals.copy_client if add anything *) +and client = { (* remember DcGlobals.new_copy_client if add anything *) client_client : client CommonClient.client_impl; mutable client_name : string option; mutable client_addr : (Ip.t * int) option; @@ -171,6 +171,9 @@ and client = { (* remember DcGlobals.copy_client if add anything *) mutable client_receiving : int64; mutable client_user : user option; mutable client_connection_control : connection_control; + client_connect_time : int; + mutable client_downloaded : int64; + mutable client_uploaded : int64; } and dc_result = { (* rst of the info (filename & size) are on Commonresults.result_info *) -- 2.11.4.GIT