mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-14 00:45:10 +00:00
[WIP/FIX] Lock write operations to XMPP
I *think* that fixes stream errors with two threads writing at once. Even if it doesn't, I think it's always a nice-to-have.
This commit is contained in:
parent
42d69226f0
commit
37155316b2
4 changed files with 32 additions and 0 deletions
|
|
@ -76,6 +76,7 @@ XMPPInitialiseCompStream(char *host, int port)
|
|||
comp = Malloc(sizeof(*comp));
|
||||
comp->host = StrDuplicate(host);
|
||||
comp->stream = stream;
|
||||
pthread_mutex_init(&comp->write_lock, NULL);
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
|
@ -112,6 +113,8 @@ XMPPAuthenticateCompStream(XMPPComponent *comp, char *shared)
|
|||
return false;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&comp->write_lock);
|
||||
|
||||
stream = comp->stream;
|
||||
as = comp->host;
|
||||
StreamPrintf(stream,
|
||||
|
|
@ -178,6 +181,7 @@ XMPPAuthenticateCompStream(XMPPComponent *comp, char *shared)
|
|||
Free(handshake);
|
||||
end:
|
||||
XMLFreeLexer(sax);
|
||||
pthread_mutex_unlock(&comp->write_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -188,6 +192,7 @@ XMPPEndCompStream(XMPPComponent *comp)
|
|||
{
|
||||
return;
|
||||
}
|
||||
pthread_mutex_destroy(&comp->write_lock);
|
||||
StreamClose(comp->stream);
|
||||
Free(comp->host);
|
||||
Free(comp);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue