[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master e43b040 5/6: Excorporate: Add timeout for synchronous oper

From: Thomas Fitzsimmons
Subject: [elpa] master e43b040 5/6: Excorporate: Add timeout for synchronous operations
Date: Fri, 25 Sep 2020 22:32:45 -0400 (EDT)

branch: master
commit e43b0407de0e60be91ebb6bf091583919cb485a9
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>

    Excorporate: Add timeout for synchronous operations
    * excorporate.el (exco--server-timeout): New variable.
    (exco-operate-synchronously): Use exco--server-timeout.
    (exco-organizer-smtp-email-address): Likewise.  Document
    synchronous operation.
 packages/excorporate/excorporate.el | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/packages/excorporate/excorporate.el 
index 84c404c..b068121 100644
--- a/packages/excorporate/excorporate.el
+++ b/packages/excorporate/excorporate.el
@@ -137,6 +137,9 @@ state machine represents a service connection.")
 (defvar exco--connection-identifiers nil
   "An ordered list of connection identifiers.")
+(defvar exco--server-timeout 5
+  "The timeout in seconds to wait for a synchronous server response.")
 (defun exco--parse-xml-in-current-buffer ()
   "Decode and parse the XML contents of the current buffer."
   (let ((mime-part (mm-dissect-buffer t t)))
@@ -648,7 +651,8 @@ IDENTIFIER is the connection identifier.  Execute operation 
 with ARGUMENTS then call CALLBACK with two arguments, IDENTIFIER
 and the server's response."
   (exco--with-fsm identifier
-    (fsm-call fsm (list name arguments))))
+    (with-timeout (exco--server-timeout (error "Timed out waiting for server"))
+      (fsm-call fsm (list name arguments)))))
 (defun exco-server-version (identifier)
   "Return the server version for connection IDENTIFIER, as a string.
@@ -867,7 +871,11 @@ argument ICALENDAR-TEXT."
   "Return the organizer's SMTP email address as a string.
 IDENTIFIER is the connection identifier to use to resolve
-should be treated as opaque."
+should be treated as opaque.
+This function queries the server synchronously.  It times out and
+returns nil if the server does not respond in under
+`exco--server-timeout' seconds."
   (let* ((wrapped (list (list organizer-structure)))
          (exco-extract-value '(Organizer Mailbox RoutingType) wrapped))
@@ -883,10 +891,11 @@ should be treated as opaque."
-          (2 (progn
-               (message (concat "exco-organizer-smtp-email-address:"
-                                " Server did not respond in time"))
-               nil))
+          (exco--server-timeout
+           (progn
+             (message (concat "exco-organizer-smtp-email-address:"
+                              " Server did not respond in time"))
+             nil))
         (exco-operate-synchronously identifier
                                     `(((UnresolvedEntry . ,email-address))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]