Sfoglia il codice sorgente

mod_auth_token: Don't timeout finished requests

j8
Sam Whited 8 anni fa
parent
commit
c17576a931
1 ha cambiato i file con 9 aggiunte e 1 eliminazioni
  1. 9
    1
      prosody-plugins/mod_auth_token.lua

+ 9
- 1
prosody-plugins/mod_auth_token.lua Vedi File

@@ -103,7 +103,15 @@ function get_public_key(keyId)
103 103
 		}, cb);
104 104
 		-- TODO: Is the done() call racey? Can we cancel this if the request
105 105
 		--       succeedes?
106
-		timer.add_task(http_timeout, function() http.destroy_request(request); done(); end);
106
+		local function cancel()
107
+			-- TODO: This check is racey. Not likely to be a problem, but we should
108
+			--       still stick a mutex on content / code at some point.
109
+			if code == nil then
110
+				http.destroy_request(request);
111
+				done();
112
+			end
113
+		end
114
+		timer.add_task(http_timeout, cancel);
107 115
 		wait();
108 116
 
109 117
 		if code == 200 or code == 204 then

Loading…
Annulla
Salva