Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
Prevent multiple parallel connections
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tmolitor-stud-tu committed Sep 10, 2020
1 parent 7176e82 commit 88ada6a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mod_push_appserver_apns/mod_push_appserver_apns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 88ada6a

Please sign in to comment.