From 4dfc7f88c1215eab9651f567369377acd3d9c149 Mon Sep 17 00:00:00 2001 From: teranisi Date: Wed, 13 Jun 2001 10:08:52 +0000 Subject: [PATCH] * elmo-pop3.el (elmo-pop3-lock): New buffer local variable. (elmo-pop3-send-command): Call elmo-pop3-lock. (elmo-pop3-read-response): Call elmo-pop3-unlock. (elmo-pop3-read-contents): Ditto. (elmo-pop3-lock): New function. (elmo-pop3-unlock): Ditto. (elmo-pop3-locked-p): Ditto. (elmo-pop3-commit): Don't delete process if elmo-pop3-locked-p returns t. --- elmo/ChangeLog | 12 ++++++++++++ elmo/elmo-pop3.el | 29 ++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 7e45117..73becaf 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,15 @@ +2001-06-13 Yuuichi Teranishi + + * elmo-pop3.el (elmo-pop3-lock): New buffer local variable. + (elmo-pop3-send-command): Call elmo-pop3-lock. + (elmo-pop3-read-response): Call elmo-pop3-unlock. + (elmo-pop3-read-contents): Ditto. + (elmo-pop3-lock): New function. + (elmo-pop3-unlock): Ditto. + (elmo-pop3-locked-p): Ditto. + (elmo-pop3-commit): Don't delete process if elmo-pop3-locked-p + returns t. + 2001-06-11 Yuuichi Teranishi * elmo-util.el (elmo-file-field-primitive-condition-match): diff --git a/elmo/elmo-pop3.el b/elmo/elmo-pop3.el index e36af94..acf13cc 100644 --- a/elmo/elmo-pop3.el +++ b/elmo/elmo-pop3.el @@ -54,13 +54,15 @@ (defvar elmo-pop3-size-hash nil) ; number -> size (defvar elmo-pop3-uidl-done nil) (defvar elmo-pop3-list-done nil) +(defvar elmo-pop3-lock nil) (defvar elmo-pop3-local-variables '(elmo-pop3-read-point elmo-pop3-uidl-number-hash elmo-pop3-number-uidl-hash elmo-pop3-uidl-done elmo-pop3-size-hash - elmo-pop3-list-done)) + elmo-pop3-list-done + elmo-pop3-lock)) (luna-define-method elmo-network-close-session ((session elmo-pop3-session)) (when (elmo-network-session-process-internal session) @@ -93,6 +95,7 @@ (erase-buffer)) (goto-char (point-min)) (setq elmo-pop3-read-point (point)) + (elmo-pop3-lock) (process-send-string process command) (process-send-string process "\r\n"))) @@ -133,6 +136,7 @@ (concat return-value "\n" response-string) response-string))) (setq elmo-pop3-read-point match-end))) + (elmo-pop3-unlock) return-value))) (defun elmo-pop3-process-filter (process output) @@ -323,8 +327,7 @@ (elmo-pop3-parse-uidl-response response))))) (defun elmo-pop3-read-contents (buffer process) - (save-excursion - (set-buffer buffer) + (with-current-buffer buffer (let ((case-fold-search nil) match-end) (goto-char elmo-pop3-read-point) @@ -332,6 +335,7 @@ (accept-process-output process) (goto-char elmo-pop3-read-point)) (setq match-end (point)) + (elmo-pop3-unlock) (elmo-delete-cr (buffer-substring elmo-pop3-read-point (- match-end 3)))))) @@ -480,6 +484,19 @@ nil)) (t nil))) + +(defun elmo-pop3-lock () + "Lock pop3 process." + (setq elmo-pop3-lock t)) + +(defun elmo-pop3-unlock () + "Unlock pop3 process." + (setq elmo-pop3-lock nil)) + +(defun elmo-pop3-locked-p (process) + "Return t if pop3 PROCESS is locked." + (with-current-buffer (process-buffer process) + elmo-pop3-lock)) (defun elmo-pop3-retrieve-headers (buffer tobuffer process articles) (save-excursion @@ -805,8 +822,10 @@ (defun elmo-pop3-commit (spec) (if (elmo-pop3-plugged-p spec) (let ((session (elmo-pop3-get-session spec 'if-exists))) - (and session - (elmo-network-close-session session))))) + (when (and session + (not (elmo-pop3-locked-p + (elmo-network-session-process-internal session)))) + (elmo-network-close-session session))))) (require 'product) -- 1.7.10.4