--- navi2ch-net.el.orig Fri Aug 6 23:02:01 2004 +++ navi2ch-net.el Sun Aug 28 22:55:41 2005 @@ -127,6 +127,33 @@ (list shell-file-name shell-command-switch command) command)))) +;; (let ((sum 0)) +;; (dotimes (i 400 sum) +;; (setq sum (+ sum (1- (floor (expt 1.00925 i))))))) +;; => 3602 +(defvar navi2ch-net-connect-wait-power 1.00925) +(defvar navi2ch-net-connect-time-list '()) + +(defun navi2ch-net-connect-wait (host) + (let* ((host (intern host)) + (now (navi2ch-float-time)) + (limit (- now 3600.0)) + (list (delq nil (mapcar (lambda (x) (if (> (cdr x) limit) x)) + navi2ch-net-connect-time-list))) + (len (length (delq nil (mapcar (lambda (x) + (if (eq host (car x)) x)) + list)))) + (wait (floor (- (+ (expt navi2ch-net-connect-wait-power len) + (or (cdr (assq host list)) now)) + 1 + now)))) + (when (> wait 0) + (message "waiting for %dsec..." wait) + (sleep-for wait) + (message "waiting for %dsec...done" wait)) + (setq navi2ch-net-connect-time-list + (cons (cons host (navi2ch-float-time)) list)))) + (defun navi2ch-net-send-request (url method &optional other-header content) (setq navi2ch-net-last-url url) (unless navi2ch-net-enable-http11 @@ -141,6 +168,7 @@ file (cdr (assq 'file list)) port (cdr (assq 'port list)) host2ch (cdr (assq 'host2ch list)))) + (navi2ch-net-connect-wait host) (when navi2ch-net-http-proxy (setq credentials (navi2ch-net-http-proxy-basic-credentials navi2ch-net-http-proxy-userid --- navi2ch-util.el.orig Sun Oct 10 00:01:11 2004 +++ navi2ch-util.el Sun Aug 28 22:55:41 2005 @@ -1269,5 +1269,13 @@ (setq bol (1+ (navi2ch-line-end-position)))))) (goto-char start)) +(defun navi2ch-float-time (&optional specified-time) + "Return the current time, as a float number of seconds since the epoch. +If an argument is given, it specifies a time to convert to float +instead of the current time." + (apply (lambda (high low &optional usec) + (+ (* high 65536.0) low (/ (or usec 0) 1000000.0))) + (or specified-time (current-time)))) + (run-hooks 'navi2ch-util-load-hook) ;;; navi2ch-util.el ends here