Skip to content

Commit

Permalink
(twittering-http-default-sentinel): check process-status before proce…
Browse files Browse the repository at this point in the history
…ssing sentinel.
  • Loading branch information
yata committed Mar 18, 2010
1 parent 8216a02 commit a359850
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Expand Up @@ -4,6 +4,9 @@
Revert part of 2010-03-12 change to prevent an overwrite of a
message which is outputted by `twittering-read-list-name'.

* twittering-mode.el (twittering-http-default-sentinel): Check
process-status before processing sentinel.

2010-03-17 Tadashi MATSUO <tad@mymail.twin.jp>

* twittering-mode.el (twittering-generate-status-formater-base):
Expand Down
51 changes: 31 additions & 20 deletions twittering-mode.el
Expand Up @@ -1964,26 +1964,37 @@ Available keywords:

(defun twittering-http-default-sentinel (func noninteractive proc stat &optional suc-msg)
(debug-printf "http-default-sentinel: proc=%s stat=%s" proc stat)
(let ((temp-buffer (process-buffer proc)))
(unwind-protect
(let* ((header (twittering-get-response-header temp-buffer))
(header-info (twittering-update-server-info header))
(mes
(cond
((null header-info)
"Failure: Bad http response.")
((and func (fboundp func))
(with-current-buffer temp-buffer
(funcall func header-info proc noninteractive suc-msg)))
(t
nil))))
(when (and mes (twittering-buffer-active-p))
(message mes)))
;; unwindforms
(twittering-release-process proc)
(when (and (not twittering-debug-mode) (buffer-live-p temp-buffer))
(kill-buffer temp-buffer))))
)
(let ((temp-buffer (process-buffer proc))
(status (process-status proc))
(mes nil))
(cond
((null status)
(setq mes "Failure: no such process exists."))
;; If a process is running, the processing sentinel has been postponed.
((memq status '(run stop open listen connect))
(debug-printf "http-default-sentinel: postponed by status `%s'" status)
t)
((memq status '(exit signal closed failed))
(unwind-protect
(let* ((header (twittering-get-response-header temp-buffer))
(header-info (twittering-update-server-info header)))
(setq mes
(cond
((null header-info)
"Failure: Bad http response.")
((and func (fboundp func))
(with-current-buffer temp-buffer
(funcall func header-info proc noninteractive suc-msg)))
(t
nil))))
;; unwindforms
(twittering-release-process proc)
(when (and (not twittering-debug-mode) (buffer-live-p temp-buffer))
(kill-buffer temp-buffer))))
(t
(setq mes (format "Failure: unknown condition: %s" status))))
(when (and mes (twittering-buffer-active-p))
(message mes))))

(defun twittering-http-get-default-sentinel (header-info proc noninteractive &optional suc-msg)
(let ((status-line (cdr (assq 'status-line header-info)))
Expand Down

0 comments on commit a359850

Please sign in to comment.