Skip to content

Commit

Permalink
Confirm process status for avoiding dead-lock.
Browse files Browse the repository at this point in the history
* twittering-mode.el: Confirm process status for avoiding
dead-lock.
(twittering-oauth-get-token-alist-native): confirm the process
status in order to avoid dead-lock. If the process exited
abnormally, the variable `result' becomes nil.
(twittering-oauth-get-token-alist-curl): likewise.
(twittering-verify-credentials): wait for the process to exit
in order to avoid dead-lock.
(twittering-get-list-index-sync): likewise.
  • Loading branch information
cvmat committed Jun 28, 2010
1 parent a66617b commit 69c6266
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 11 deletions.
12 changes: 12 additions & 0 deletions ChangeLog
@@ -1,3 +1,15 @@
2010-06-29 Tadashi MATSUO <tad@mymail.twin.jp>

* twittering-mode.el: Confirm process status for avoiding
dead-lock.
(twittering-oauth-get-token-alist-native): confirm the process
status in order to avoid dead-lock. If the process exited
abnormally, the variable `result' becomes nil.
(twittering-oauth-get-token-alist-curl): likewise.
(twittering-verify-credentials): wait for the process to exit
in order to avoid dead-lock.
(twittering-get-list-index-sync): likewise.

2010-06-09 Yuto Hayamizu <y.hayamizu@gmail.com>

* twittering-mode.el (twittering-oauth-get-access-token): reject
Expand Down
57 changes: 46 additions & 11 deletions twittering-mode.el
Expand Up @@ -1142,10 +1142,20 @@ function."
proc
(lambda (&rest args)
(let* ((proc (car args))
(buffer (process-buffer proc)))
(when buffer
(buffer (process-buffer proc))
(status (process-status proc)))
(cond
((not (memq status '(nil closed exit failed signal)))
;; continue
)
(buffer
(when twittering-debug-mode
(with-current-buffer (twittering-debug-buffer)
(insert-buffer-substring buffer)))
(setq result
(twittering-oauth-get-response-alist buffer))))))
(twittering-oauth-get-response-alist buffer)))
(t
(setq result nil))))))
(process-send-string proc request-str)
(while (eq result 'queried)
(sit-for 0.1))
Expand Down Expand Up @@ -1217,10 +1227,20 @@ function."
proc
(lambda (&rest args)
(let* ((proc (car args))
(buffer (process-buffer proc)))
(when buffer
(buffer (process-buffer proc))
(status (process-status proc)))
(cond
((not (memq status '(nil closed exit failed signal)))
;; continue
)
(buffer
(when twittering-debug-mode
(with-current-buffer (twittering-debug-buffer)
(insert-buffer-substring buffer)))
(setq result
(twittering-oauth-get-response-alist buffer))))))
(twittering-oauth-get-response-alist buffer)))
(t
(setq result nil))))))
(while (eq result 'queried)
(sit-for 0.1))
result))))))
Expand Down Expand Up @@ -2940,12 +2960,22 @@ authorized -- The account has been authorized.")
(twittering-call-api
'verify-credentials
`((sentinel . twittering-http-get-verify-credentials-sentinel)))))
(unless proc
(cond
((null proc)
(setq twittering-account-authorization nil)
(message "Authorization for the account \"%s\" failed. Type M-x twit to retry."
(twittering-get-username))
(setq twittering-username nil)
(setq twittering-password nil))))))
(setq twittering-password nil))
(t
(while (and (eq twittering-account-authorization 'queried)
(memq (process-status proc) '(run connect open)))
(sit-for 0.1))
(when (eq twittering-account-authorization 'queried)
(setq twittering-account-authorization nil)
(message "Authorization failed. Type M-x twit to retry.")
(setq twittering-username nil)
(setq twittering-password nil))))))))

(defun twittering-http-get-verify-credentials-sentinel (header-info proc noninteractive &optional suc-msg)
(let ((status-line (cdr (assq 'status-line header-info)))
Expand Down Expand Up @@ -5185,10 +5215,15 @@ variable `twittering-status-format'."

(defun twittering-get-list-index-sync (username)
(setq twittering-list-index-retrieved nil)
(twittering-get-list-index username)
(while (not twittering-list-index-retrieved)
(sit-for 0.1))
(let ((proc (twittering-get-list-index username)))
(when proc
(while (and (not twittering-list-index-retrieved)
(not (memq (process-status proc)
'(exit signal closed failed nil))))
(sit-for 0.1))))
(cond
((null twittering-list-index-retrieved)
nil)
((stringp twittering-list-index-retrieved)
(if (string= "" twittering-list-index-retrieved)
(message "%s does not have a list." username)
Expand Down

0 comments on commit 69c6266

Please sign in to comment.