243 |
end |
end |
244 |
|
|
245 |
let print_socket buf s = |
let print_socket buf s = |
246 |
Printf.bprintf buf "FD %s:%d: %20s\n" |
Printf.bprintf buf "FD %s:%d: %20s" |
247 |
(s.name) (get_fd_num s.fd) |
(s.name) (get_fd_num s.fd) |
248 |
(Date.to_string s.born) |
(Date.to_string s.born) |
249 |
|
|
330 |
} in |
} in |
331 |
(* lprintf "ADD ONE TASK\n"; *) |
(* lprintf "ADD ONE TASK\n"; *) |
332 |
if !debug then begin |
if !debug then begin |
333 |
lprintf "OPENING: %s" ( sprint_socket t); |
lprintf_nl "OPENING: %s" ( sprint_socket t); |
334 |
end; |
end; |
335 |
fd_tasks := t :: !fd_tasks; |
fd_tasks := t :: !fd_tasks; |
336 |
add_fd_to_event_set t; |
add_fd_to_event_set t; |
511 |
let loop () = |
let loop () = |
512 |
add_infinite_timer 1.0 (fun _ -> |
add_infinite_timer 1.0 (fun _ -> |
513 |
if !verbose_bandwidth > 0 then |
if !verbose_bandwidth > 0 then |
514 |
lprintf "[BW1] Resetting bandwidth counters\n"; |
lprintf_nl "[BW1] Resetting bandwidth counters"; |
515 |
List.iter (fun f -> try f () with _ -> ()) !bandwidth_second_timers |
List.iter (fun f -> try f () with _ -> ()) !bandwidth_second_timers |
516 |
); |
); |
517 |
while true do |
while true do |
553 |
select !fd_tasks !timeout; |
select !fd_tasks !timeout; |
554 |
with |
with |
555 |
| e -> |
| e -> |
556 |
lprintf "Exception %s in Select.loop\n" (Printexc2.to_string e); |
lprintf_nl "Exception %s in Select.loop" (Printexc2.to_string e); |
557 |
done |
done |
558 |
|
|
559 |
|
|
567 |
let nb_sockets () = !nb_sockets |
let nb_sockets () = !nb_sockets |
568 |
|
|
569 |
let stats buf t = |
let stats buf t = |
570 |
lprintf "Socket %d\n" (get_fd_num t.fd) |
lprintf_nl "Socket %d" (get_fd_num t.fd) |
571 |
|
|
572 |
let sock_num t = get_fd_num t.fd |
let sock_num t = get_fd_num t.fd |
573 |
|
|
651 |
if !debug then |
if !debug then |
652 |
let buf = Buffer.create 100 in |
let buf = Buffer.create 100 in |
653 |
print_sockets buf; |
print_sockets buf; |
654 |
lprintf "%s\n" (Buffer.contents buf); |
lprintf_nl "%s" (Buffer.contents buf); |
655 |
) |
) |