Software / code / prosody
Comparison
plugins/mod_s2s/mod_s2s.lua @ 10810:8a0a923e1ced
mod_s2s: Run stream close in async context
Allows async processing during stream shutdown. Fixes potential ASYNC-01
issues, however no such issues known at the time of this commit.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 08 May 2020 23:55:51 +0200 |
| parent | 10809:86ea811ee25b |
| child | 10849:19e7092e062c |
comparison
equal
deleted
inserted
replaced
| 10809:86ea811ee25b | 10810:8a0a923e1ced |
|---|---|
| 453 end | 453 end |
| 454 end | 454 end |
| 455 end | 455 end |
| 456 end | 456 end |
| 457 | 457 |
| 458 function stream_callbacks.streamclosed(session) | 458 function stream_callbacks._streamclosed(session) |
| 459 (session.log or log)("debug", "Received </stream:stream>"); | 459 (session.log or log)("debug", "Received </stream:stream>"); |
| 460 session:close(false); | 460 session:close(false); |
| 461 end | |
| 462 | |
| 463 function stream_callbacks.streamclosed(session, attr) | |
| 464 -- run _streamclosed in async context | |
| 465 session.thread:run({ stream = "closed", attr = attr }); | |
| 461 end | 466 end |
| 462 | 467 |
| 463 function stream_callbacks.error(session, error, data) | 468 function stream_callbacks.error(session, error, data) |
| 464 if error == "no-stream" then | 469 if error == "no-stream" then |
| 465 session.log("debug", "Invalid opening stream header (%s)", (data:gsub("^([^\1]+)\1", "{%1}"))); | 470 session.log("debug", "Invalid opening stream header (%s)", (data:gsub("^([^\1]+)\1", "{%1}"))); |
| 566 session.thread = runner(function (stanza) | 571 session.thread = runner(function (stanza) |
| 567 if st.is_stanza(stanza) then | 572 if st.is_stanza(stanza) then |
| 568 core_process_stanza(session, stanza); | 573 core_process_stanza(session, stanza); |
| 569 elseif stanza.stream == "opened" then | 574 elseif stanza.stream == "opened" then |
| 570 stream_callbacks._streamopened(session, stanza.attr); | 575 stream_callbacks._streamopened(session, stanza.attr); |
| 576 elseif stanza.stream == "closed" then | |
| 577 stream_callbacks._streamclosed(session, stanza.attr); | |
| 571 end | 578 end |
| 572 end, runner_callbacks, session); | 579 end, runner_callbacks, session); |
| 573 | 580 |
| 574 local log = session.log or log; | 581 local log = session.log or log; |
| 575 session.stream = stream; | 582 session.stream = stream; |