[ADD] Try to renegociate an XMPP stream on failure

This commit is contained in:
lda 2025-02-19 16:14:30 +00:00
commit 40e3242465

View file

@ -244,6 +244,8 @@ ParseeXMPPThread(void *argp)
} }
} }
while (!args->halted)
{
while (true) while (true)
{ {
char *id; char *id;
@ -300,10 +302,38 @@ ParseeXMPPThread(void *argp)
if (!args->halted) if (!args->halted)
{ {
Log(LOG_WARNING, "XMPP server is closing stream..."); Log(LOG_WARNING, "XMPP server is closing stream...");
Log(LOG_WARNING, "Stopping %s...", NAME); for (size_t i = 0; i < 50; i++)
error = true; {
UtilSleepMillis(100); /* Wait a bit so that temporary failures don't fuck everything up */
Log(LOG_WARNING, "Restarting XMPP stream.");
/* This is the part where a new connection is being considered */
XMPPFinishCompStream(jabber);
XMPPEndCompStream(jabber);
args->jabber = XMPPInitialiseCompStream(
args->config->component_addr,
args->config->component_host,
args->config->component_port
);
jabber = args->jabber;
if (!jabber || !XMPPAuthenticateCompStream(jabber, args->config->shared_comp_secret))
{
/* Oops, there is something wrong! */
Log(LOG_ERR, "Couldn't authenticate to XMPP server");
XMPPEndCompStream(jabber);
args->jabber = NULL;
jabber = NULL;
if (i == 4)
{
pthread_mutex_unlock(&args->halt_lock);
break;
}
}
}
} }
pthread_mutex_unlock(&args->halt_lock); pthread_mutex_unlock(&args->halt_lock);
}
info.running = false; info.running = false;
for (i = 0; i < info.available_dispatchers; i++) for (i = 0; i < info.available_dispatchers; i++)