Commit 4f7e89ce authored by David Kågedal's avatar David Kågedal
Browse files

Diverse ändringar...

parent bfb46c94
......@@ -539,6 +539,7 @@ text is a member of some recipient of this text."
(mapcar 'not x)))))))
(lyskom-wait-queue 'sending)
(if (and (null author-is-member)
(not (zerop author-number))
(lyskom-j-or-n-p
(let ((kom-deferred-printing nil))
(lyskom-format
......
......@@ -154,6 +154,9 @@ Email-address:\n\nOther:\t")
(presentation-help . "You are writing your presentation.\n")
(not-present-anywhere . "Not in any conference.")
(in-secret-conference . "Secret conference (%#1d).")
(start-new-session-same-server
. "You are already connected to that server. Do you want a new session? ")
(new-session-in-buffer . "\n\n---- New session at %s ----\n\n")
......@@ -375,7 +378,7 @@ Read all about it at http://www.lysator.liu.se/history/")
(matching-regexp . "Conferences/users matching `%#1s'\n")
(who-is-active-all . "Showing all sessions.\n")
(who-is-active-last-minnutes . "Showing all sessions active tha last %#1d minutes.\n")
(who-is-active-last-minutes . "Showing all sessions active tha last %#1d minutes.\n")
(showing-invisibles . "Showing invisible sessions.\n")
(null-who-info . "No one (active) is logged in.\n")
......
......@@ -318,6 +318,12 @@ Return a dotted pair consisting of the QUEUE-NAME and the new queue."
(nconc lyskom-call-data new-queue-list))
(car new-queue-list)))
(defun lyskom-set-queue-priority (queue-name priority)
(put queue-name 'lyskom-queue-priority priority))
(defun lyskom-queue-priority (queue-name)
(or (get queue-name 'lyskom-queue-priority)
0))
(defun lyskom-call-add (queue-name type &rest data)
"Add an entry to the kom-queue QUEUE-NAME. The entry is of type TYPE
......@@ -333,33 +339,44 @@ and third argument DATA contains the rest of the necessary data."
"Send a packet to the server.
Add info on lyskom-pending-calls. Update lyskom-ref-no.
Args: KOM-QUEUE STRING."
(let ((str (concat lyskom-ref-no string "\n")))
(if (>= lyskom-number-of-pending-calls
lyskom-max-pending-calls)
(lyskom-queue-enter lyskom-output-queue str)
(lyskom-process-send-string lyskom-proc str)
(++ lyskom-number-of-pending-calls)))
;; Queue it
(lyskom-queue-enter (aref lyskom-output-queues
(lyskom-queue-priority kom-queue))
(cons lyskom-ref-no string))
(setq lyskom-pending-calls
(cons
(cons lyskom-ref-no
kom-queue)
lyskom-pending-calls))
(++ lyskom-ref-no))
(cons (cons lyskom-ref-no kom-queue)
lyskom-pending-calls))
(++ lyskom-ref-no)
;; Send something from the output queues
(lyskom-check-output-queues))
(defun lyskom-check-output-queues ()
"Check for pending calls to the server.
Send calls from queues with higher priority first, and make sure that at
most lyskom-max-pending-calls are sent to the server at the same time."
(catch 'done
(let ((i 9))
(while (< lyskom-number-of-pending-calls
lyskom-max-pending-calls)
(while (lyskom-queue-isempty (aref lyskom-output-queues i))
(-- i)
(if (< i 0) (throw 'done nil)))
(let ((entry (lyskom-queue-delete-first
(aref lyskom-output-queues i))))
(++ lyskom-number-of-pending-calls)
(lyskom-process-send-string
lyskom-proc
(concat (car entry) (cdr entry) "\n")))))))
(defun lyskom-decrease-pending-calls ()
"A reply has come.
Send a pending call or decrease lyskom-number-of-pending-calls."
(cond
((and (<= lyskom-number-of-pending-calls lyskom-max-pending-calls)
(lyskom-queue->first lyskom-output-queue))
(lyskom-process-send-string
lyskom-proc
(lyskom-queue->first lyskom-output-queue))
(lyskom-queue-delete-first lyskom-output-queue))
(t
(-- lyskom-number-of-pending-calls)
(if (< lyskom-number-of-pending-calls 0)
(setq lyskom-number-of-pending-calls 0)))))
(-- lyskom-number-of-pending-calls)
(if (< lyskom-number-of-pending-calls 0)
(setq lyskom-number-of-pending-calls 0))
(lyskom-check-output-queues))
(defun lyskom-process-send-string (process string)
......
No preview for this file type
......@@ -811,7 +811,7 @@ i.e creates the buffer, sets all markers and pointers."
"Parse the results of a successful call and call the handler."
(lyskom-save-excursion
(set-buffer buffer)
(let* ((kom-queue (cdr (assoc ref-no lyskom-pending-calls)))
(let* ((kom-queue (cdr (assq ref-no lyskom-pending-calls)))
(call-info (lyskom-locate-ref-no kom-queue ref-no)))
(set-buffer lyskom-unparsed-buffer)
(if call-info
......@@ -880,7 +880,7 @@ CALL-INFO is destructively changed to
"Parse the result of an unsuccessful call and call the handler."
(lyskom-save-excursion
(set-buffer buffer)
(let* ((kom-queue (cdr (assoc ref-no lyskom-pending-calls)))
(let* ((kom-queue (cdr (assq ref-no lyskom-pending-calls)))
(call-info (lyskom-locate-ref-no kom-queue ref-no))
errno)
(set-buffer lyskom-unparsed-buffer)
......
......@@ -401,38 +401,42 @@ with big maps."
(lyskom-format-objects 34 conf-no
first-local no-of-texts)))
;; As far as I can tell, this function is not used. /davidk
;;(defun z-initiate-get-map (kom-queue handler conf-no first-local
;; no-of-texts &rest data)
;; "Get mapping from local to global text-nos for CONF-NO from server.
;;Args: KOM-QUEUE HANDLER CONF-NO FIRST-LOCAL NO-OF-TEXTS &rest DATA.
;;This function will automatically split fetching of big maps to small
;;chunks of lyskom-fetch-map-nos texts/chunk if KOM-QUEUE is not already
;;used to collect a result. This currently gives a big performance gain.
;;Unfortunately it is impossible (or at least very hard) to do the same
;;thing when a collect is in progress. This will of course be fixed in
;;protocol B."
;; (cond
;; ((lyskom-kom-queue-collect-p kom-queue)
;; ;; Use oldstyle single big map. Sorry.
;; (initiate-get-map kom-queue handler conf-no
;; first-local no-of-texts data))
;; (t
;; ;; You win.
;; (lyskom-collect-ignore-err kom-queue)
;; (while (> no-of-texts 0)
;; (initiate-get-map kom-queue nil conf-no
;; first-local lyskom-fetch-map-nos data)
;; (setq first-local (+ lyskom-fetch-map-nos first-local))
;; (setq no-of-texts (- no-of-texts lyskom-fetch-map-nos)))
;; (lyskom-list-use kom-queue 'lyskom-receive-get-map handler data))))
(defun lyskom-receive-get-map (map-list handler data-list)
"Receive a list of maps.
Args: MAP-LIST HANDLER DATA-LIST."
(apply handler (apply 'lyskom-map-concat map-list) data-list))
(defun z-initiate-get-map (kom-queue handler conf-no first-local
no-of-texts &rest data)
"Get mapping from local to global text-nos for CONF-NO from server.
Args: KOM-QUEUE HANDLER CONF-NO FIRST-LOCAL NO-OF-TEXTS &rest DATA.
This function will automatically split fetching of big maps to small
chunks of lyskom-fetch-map-nos texts/chunk if KOM-QUEUE is not already
used to collect a result. This currently gives a big performance gain.
Unfortunately it is impossible (or at least very hard) to do the same
thing when a collect is in progress. This will of course be fixed in
protocol B."
(cond
((kom-queue->collect-flag (cdr-safe (assq kom-queue lyskom-call-data)))
;; Use oldstyle single big map. Sorry.
(apply 'initiate-get-map
kom-queue handler conf-no first-local no-of-texts data))
(t
;; You win.
(initiate-get-map kom-queue 'lyskom-receive-partial-map conf-no
first-local lyskom-fetch-map-nos
(+ lyskom-fetch-map-nos first-local)
(- no-of-texts lyskom-fetch-map-nos)
conf-no nil kom-queue data handler))))
(defun lyskom-receive-partial-map (map first-local no-of-texts
conf-no map-so-far kom-queue
data-list handler)
"Receive a partial map and start fetching a new chunk."
(let ((map-list (nconc map-so-far (list map))))
(if (<= no-of-texts 0)
(apply handler (apply 'lyskom-map-concat map-list) data-list)
(initiate-get-map kom-queue 'lyskom-receive-partial-map conf-no
first-local lyskom-fetch-map-nos
(+ lyskom-fetch-map-nos first-local)
(- no-of-texts lyskom-fetch-map-nos)
conf-no map-list kom-queue data-list handler))))
(defun initiate-get-time (kom-queue handler &rest data)
"Get time from server.
......
......@@ -76,77 +76,99 @@ See lyskom-mode for details."
(t
(setq host (substring host 0 (match-beginning 0)))))))
(let* ((buffer (generate-new-buffer host))
(name (buffer-name buffer))
(let* ((buffer (get-buffer host))
(name nil)
(proc nil))
(unwind-protect
(progn
(setq proc (open-network-stream name buffer host port))
(switch-to-buffer buffer)
(lyskom-mode) ;Clearing lyskom-default...
(setq lyskom-buffer buffer)
(setq lyskom-default-user-name username)
(setq lyskom-default-password password)
(setq lyskom-server-name host)
(setq lyskom-proc proc)
(lyskom-setup-faces)
(lyskom-insert
(lyskom-format 'try-connect lyskom-clientversion host))
(set-process-filter proc 'lyskom-connect-filter)
(lyskom-process-send-string proc
(concat "A"
(lyskom-format-objects
(concat (user-login-name)
"%" (system-name)))))
(while (eq 'lyskom-connect-filter (process-filter proc))
(accept-process-output proc))
;; Now we have got the correct response.
(set-process-sentinel proc 'lyskom-sentinel)
(save-excursion
(lyskom-init-parse buffer))
;; Tell the server who we are
(initiate-set-client-version 'background nil
"lyskom.el" lyskom-clientversion)
(setq lyskom-server-info (blocking-do 'get-server-info))
(setq lyskom-server-version
(list (/ (server-info->version lyskom-server-info) 10000)
(/ (% (server-info->version lyskom-server-info) 10000)
100)
(% (server-info->version lyskom-server-info) 100)))
(lyskom-setup-client-for-server-version)
(lyskom-format-insert
'connection-done
(if (zerop (elt lyskom-server-version 2))
(format "%d.%d"
(elt lyskom-server-version 0)
(elt lyskom-server-version 1))
(format "%d.%d.%d"
(if (and buffer
(lyskom-buffer-p buffer)
(not (j-or-n-p (lyskom-get-string
'start-new-session-same-server))))
(switch-to-buffer buffer)
(unwind-protect
(progn
(cond (buffer
(set-buffer buffer)
(goto-char (point-max))
(let ((time (decode-time (current-time))))
(setcar (cdr (cdr (cdr (cdr time))))
(1- (car (cdr (cdr (cdr (cdr time)))))))
(setcar (cdr (cdr (cdr (cdr (cdr time)))))
(- (car (cdr (cdr (cdr (cdr (cdr time))))))
1900))
(insert
(format (lyskom-get-string 'new-session-in-buffer)
(lyskom-format-time
(apply 'lyskom-create-time time))))
(setq name (buffer-name buffer))))
(t
(setq buffer (generate-new-buffer host))
(setq name (buffer-name buffer))))
(setq proc (open-network-stream name buffer host port))
(switch-to-buffer buffer)
(lyskom-mode) ;Clearing lyskom-default...
(setq lyskom-buffer buffer)
(setq lyskom-default-user-name username)
(setq lyskom-default-password password)
(setq lyskom-server-name host)
(setq lyskom-proc proc)
(lyskom-setup-faces)
(lyskom-insert
(lyskom-format 'try-connect lyskom-clientversion host))
(set-process-filter proc 'lyskom-connect-filter)
(lyskom-process-send-string proc
(concat "A"
(lyskom-format-objects
(concat (user-login-name)
"%" (system-name)))))
(while (eq 'lyskom-connect-filter (process-filter proc))
(accept-process-output proc))
;; Now we have got the correct response.
(set-process-sentinel proc 'lyskom-sentinel)
(save-excursion
(lyskom-init-parse buffer))
;; Tell the server who we are
(initiate-set-client-version 'background nil
"lyskom.el" lyskom-clientversion)
(setq lyskom-server-info (blocking-do 'get-server-info))
(setq lyskom-server-version
(list (/ (server-info->version lyskom-server-info) 10000)
(/ (% (server-info->version lyskom-server-info) 10000)
100)
(% (server-info->version lyskom-server-info) 100)))
(lyskom-setup-client-for-server-version)
(lyskom-format-insert
'connection-done
(if (zerop (elt lyskom-server-version 2))
(format "%d.%d"
(elt lyskom-server-version 0)
(elt lyskom-server-version 1))
(format "%d.%d.%d"
(elt lyskom-server-version 0)
(elt lyskom-server-version 1)
(elt lyskom-server-version 2))))
(if (not (zerop (server-info->motd-of-lyskom lyskom-server-info)))
(let ((text (blocking-do 'get-text
(server-info->motd-of-lyskom
lyskom-server-info))))
(lyskom-insert
(if text
(text->text-mass text)
(lyskom-get-string 'lyskom-motd-was-garbed)))
(lyskom-insert "\n")))
;; Can't use lyskom-end-of-command here.
(setq lyskom-executing-command nil)
;; Log in
(kom-start-anew t)
(setq lyskom-buffer-list (cons lyskom-buffer lyskom-buffer-list))
(setq init-done t))
;; Something went wrong. Lets cleanup everything. :->
(if init-done
nil
(if proc (delete-process proc))
(kill-buffer buffer))))))
(if (not (zerop (server-info->motd-of-lyskom lyskom-server-info)))
(let ((text (blocking-do 'get-text
(server-info->motd-of-lyskom
lyskom-server-info))))
(lyskom-insert
(if text
(text->text-mass text)
(lyskom-get-string 'lyskom-motd-was-garbed)))
(lyskom-insert "\n")))
;; Can't use lyskom-end-of-command here.
(setq lyskom-executing-command nil)
;; Log in
(kom-start-anew t)
(setq lyskom-buffer-list (cons lyskom-buffer lyskom-buffer-list))
(setq init-done t))
;; Something went wrong. Lets cleanup everything. :->
(if init-done
nil
(if proc (delete-process proc))
(kill-buffer buffer)))))))
(defun lyskom-setup-client-check-version (spec version)
......@@ -575,6 +597,7 @@ to see, set of call."
(make-local-variable 'kom-friends)
(make-local-variable 'kom-permanent-filter-list)
(make-local-variable 'kom-session-filter-list)
(make-local-variable 'lyskom-accept-async-flag)
(make-local-variable 'lyskom-blocking-return)
(make-local-variable 'lyskom-buffer)
(make-local-variable 'lyskom-command-to-do)
......@@ -586,11 +609,13 @@ to see, set of call."
(make-local-variable 'lyskom-default-password)
(make-local-variable 'lyskom-default-user-name)
(make-local-variable 'lyskom-do-when-done)
(make-local-variable 'lyskom-dynamic-session-info-flag)
(make-local-variable 'lyskom-dont-change-prompt)
(make-local-variable 'lyskom-errno)
(make-local-variable 'lyskom-executing-command)
(make-local-variable 'lyskom-fetched-texts)
(make-local-variable 'lyskom-filter-list)
(make-local-variable 'lyskom-idle-time-flag)
(make-local-variable 'lyskom-is-administrator)
(make-local-variable 'lyskom-is-parsing)
(make-local-variable 'lyskom-is-waiting)
......@@ -602,6 +627,7 @@ to see, set of call."
(make-local-variable 'lyskom-last-personal-message-sender)
(make-local-variable 'lyskom-last-viewed)
(make-local-variable 'lyskom-list-of-edit-buffers)
(make-local-variable 'lyskom-long-conf-types-flag)
(make-local-variable 'lyskom-marked-text-cache)
(make-local-variable 'lyskom-membership)
(make-local-variable 'lyskom-membership-is-read)
......@@ -610,7 +636,7 @@ to see, set of call."
(make-local-variable 'lyskom-number-of-pending-calls)
(make-local-variable 'lyskom-options-done)
(make-local-variable 'lyskom-other-clients-user-areas)
(make-local-variable 'lyskom-output-queue)
(make-local-variable 'lyskom-output-queues)
(make-local-variable 'lyskom-pending-calls)
(make-local-variable 'lyskom-pers-cache)
(make-local-variable 'lyskom-pers-no)
......@@ -629,7 +655,6 @@ to see, set of call."
(make-local-variable 'lyskom-set-last-read-flag)
(make-local-variable 'lyskom-uconf-stats-flag)
(make-local-variable 'lyskom-z-lookup-flag)
(make-local-variable 'lyskom-accept-async-flag)
(make-local-variable 'lyskom-session-no)
(make-local-variable 'lyskom-session-priority)
(make-local-variable 'lyskom-text-cache)
......@@ -654,7 +679,11 @@ to see, set of call."
(setq lyskom-server-info server-info)
(setq lyskom-server-name server-name)
(setq lyskom-do-when-done (cons kom-do-when-done kom-do-when-done))
(setq lyskom-output-queue (lyskom-queue-create))
(setq lyskom-output-queues (make-vector 10 nil))
(let ((i 0))
(while (< i 10)
(aset lyskom-output-queues i (lyskom-queue-create))
(++ i)))
(setq lyskom-list-of-edit-buffers nil)
(setq lyskom-pending-calls nil)
(lyskom-set-mode-line (lyskom-get-string 'not-present-anywhere))))
......@@ -159,7 +159,9 @@ Email-adress:\n\nAnnat:\t")
(presentation-help . "Du skriver just nu din presentation.\n")
(not-present-anywhere . "Ej n\344rvarande i n\345got m\366te.")
(in-secret-conference . "Hemligt m\366te (%#1d).")
(start-new-session-same-server
. "Du k\366r redan mot den servern. Vill du starta en ny session? ")
(new-session-in-buffer . "\n\n---- Ny session startad %s ----\n\n")
; From internal.el:
......
......@@ -804,8 +804,11 @@ Each element on the list has the format
REF-NO unique number assigned by lyskom-send-packet.
KOM-QUEUE is a kom-queue. (See lyskom-call-data).")
(defvar lyskom-output-queue nil
(defvar lyskom-output-queues nil
"Pending output to the server.
This is a vector of ten elements, each of which is a kom-queue. calls from
queues with a higher index (priority) are always sent first.
At most lyskom-max-pending-calls calls are sent at once.")
(defvar lyskom-max-pending-calls 20
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment