From 88ada6afc65f3ca53fe51db15e47d62c49c8097c Mon Sep 17 00:00:00 2001 From: Thilo Molitor Date: Thu, 10 Sep 2020 22:49:10 +0200 Subject: [PATCH] Prevent multiple parallel connections http_client.connect() is async and imposes a race condition if we set the gobal connection variable *after* this async call returns. We now set connection = true to prevent further calls to http_client.connect() and write the correct value to the connection global once the async call returns. --- mod_push_appserver_apns/mod_push_appserver_apns.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod_push_appserver_apns/mod_push_appserver_apns.lua b/mod_push_appserver_apns/mod_push_appserver_apns.lua index 6b232a0..9e0dce7 100644 --- a/mod_push_appserver_apns/mod_push_appserver_apns.lua +++ b/mod_push_appserver_apns/mod_push_appserver_apns.lua @@ -12,7 +12,6 @@ local cq = require "net.cqueues".cq; local http_client = require "http.client"; local new_headers = require "http.headers".new; local ce = require "cqueues.errno"; -local new_tls_context = require "http.tls".new_client_context; local openssl_ctx = require "openssl.ssl.context"; local x509 = require "openssl.x509"; local pkey = require "openssl.pkey"; @@ -108,6 +107,7 @@ local function apns_handler(event) -- create new connection local err, errno; + connection = true; -- prevent multiple parallel connections (http_client.connect() is async) connection, err, errno = http_client.connect({ host = push_host; port = push_port;