Add timing to logs, fix issue of silently ignored I/O errors
This commit is contained in:
parent
9ef4dddfdc
commit
1bb75f40d2
|
@ -218,13 +218,12 @@ public class MessageProcessor : StreamInteractionModule, Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (iq != null) {
|
while (iq != null) {
|
||||||
debug("MAM: [%s] IN: %s", account.bare_jid.to_string(), iq.stanza.to_string());
|
|
||||||
string? earliest_id = iq.stanza.get_deep_string_content("urn:xmpp:mam:2:fin", "http://jabber.org/protocol/rsm" + ":set", "first");
|
string? earliest_id = iq.stanza.get_deep_string_content("urn:xmpp:mam:2:fin", "http://jabber.org/protocol/rsm" + ":set", "first");
|
||||||
if (earliest_id == null) return true;
|
if (earliest_id == null) return true;
|
||||||
|
|
||||||
if (!mam_times[account].has_key(earliest_id)) error("wtf");
|
if (!mam_times[account].has_key(earliest_id)) error("wtf");
|
||||||
|
|
||||||
debug("MAM: [%s] Update from_id %s\n", account.bare_jid.to_string(), earliest_id);
|
debug("MAM: [%s] Update from_id %s", account.bare_jid.to_string(), earliest_id);
|
||||||
if (!current_catchup_id.has_key(account)) {
|
if (!current_catchup_id.has_key(account)) {
|
||||||
debug("MAM: [%s] We get our first MAM page", account.bare_jid.to_string());
|
debug("MAM: [%s] We get our first MAM page", account.bare_jid.to_string());
|
||||||
string? latest_id = iq.stanza.get_deep_string_content("urn:xmpp:mam:2:fin", "http://jabber.org/protocol/rsm" + ":set", "last");
|
string? latest_id = iq.stanza.get_deep_string_content("urn:xmpp:mam:2:fin", "http://jabber.org/protocol/rsm" + ":set", "last");
|
||||||
|
|
|
@ -26,16 +26,17 @@ public class StanzaWriter {
|
||||||
running = true;
|
running = true;
|
||||||
try {
|
try {
|
||||||
yield output.write_all_async(data, 0, null, null);
|
yield output.write_all_async(data, 0, null, null);
|
||||||
SourceFuncWrapper? sfw = queue.pop_head();
|
|
||||||
if (sfw != null) {
|
|
||||||
sfw.sfun();
|
|
||||||
}
|
|
||||||
} catch (GLib.Error e) {
|
} catch (GLib.Error e) {
|
||||||
throw new XmlError.IO(@"IOError in GLib: $(e.message)");
|
throw new XmlError.IO(@"IOError in GLib: $(e.message)");
|
||||||
} finally {
|
} finally {
|
||||||
|
SourceFuncWrapper? sfw = queue.pop_head();
|
||||||
|
if (sfw != null) {
|
||||||
|
sfw.sfun();
|
||||||
|
} else {
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SourceFuncWrapper : Object {
|
public class SourceFuncWrapper : Object {
|
||||||
|
|
|
@ -108,15 +108,15 @@ public class XmppLog {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void node(string what, StanzaNode node) {
|
public void node(string what, StanzaNode node, XmppStream stream) {
|
||||||
if (should_log_node(node)) {
|
if (should_log_node(node)) {
|
||||||
stderr.printf("%sXMPP %s [%s]%s\n%s\n", use_ansi ? ANSI_COLOR_WHITE : "", what, ident, use_ansi ? ANSI_COLOR_END : "", use_ansi ? node.to_ansi_string(hide_ns) : node.to_string());
|
stderr.printf("%sXMPP %s [%s %p %s]%s\n%s\n", use_ansi ? ANSI_COLOR_WHITE : "", what, ident, stream, new DateTime.now_local().to_string(), use_ansi ? ANSI_COLOR_END : "", use_ansi ? node.to_ansi_string(hide_ns) : node.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void str(string what, string str) {
|
public void str(string what, string str, XmppStream stream) {
|
||||||
if (should_log_str(str)) {
|
if (should_log_str(str)) {
|
||||||
stderr.printf("%sXMPP %s [%s]%s\n%s\n", use_ansi ? ANSI_COLOR_WHITE : "", what, ident, use_ansi ? ANSI_COLOR_END : "", str);
|
stderr.printf("%sXMPP %s [%s %p %s]%s\n%s\n", use_ansi ? ANSI_COLOR_WHITE : "", what, ident, stream, new DateTime.now_local().to_string(), use_ansi ? ANSI_COLOR_END : "", str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class XmppStream {
|
||||||
if (writer == null || reader == null || stream == null) {
|
if (writer == null || reader == null || stream == null) {
|
||||||
throw new IOStreamError.DISCONNECT("trying to disconnect, but no stream open");
|
throw new IOStreamError.DISCONNECT("trying to disconnect, but no stream open");
|
||||||
}
|
}
|
||||||
log.str("OUT", "</stream:stream>");
|
log.str("OUT", "</stream:stream>", this);
|
||||||
yield writer.write("</stream:stream>");
|
yield writer.write("</stream:stream>");
|
||||||
reader.cancel();
|
reader.cancel();
|
||||||
yield stream.close_async();
|
yield stream.close_async();
|
||||||
|
@ -107,22 +107,25 @@ public class XmppStream {
|
||||||
if (reader == null) throw new IOStreamError.READ("trying to read, but no stream open");
|
if (reader == null) throw new IOStreamError.READ("trying to read, but no stream open");
|
||||||
try {
|
try {
|
||||||
StanzaNode node = yield ((!)reader).read_node();
|
StanzaNode node = yield ((!)reader).read_node();
|
||||||
log.node("IN", node);
|
log.node("IN", node, this);
|
||||||
return node;
|
return node;
|
||||||
} catch (XmlError e) {
|
} catch (XmlError e) {
|
||||||
throw new IOStreamError.READ(e.message);
|
throw new IOStreamError.READ(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Version (deprecated = true, deprecated_since = "0.1", replacement = "write_async")]
|
||||||
public void write(StanzaNode node) {
|
public void write(StanzaNode node) {
|
||||||
write_async.begin(node);
|
write_async.begin(node, (obj, res) => {
|
||||||
|
write_async.end(res);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void write_async(StanzaNode node) throws IOStreamError {
|
public async void write_async(StanzaNode node) throws IOStreamError {
|
||||||
StanzaWriter? writer = this.writer;
|
StanzaWriter? writer = this.writer;
|
||||||
if (writer == null) throw new IOStreamError.WRITE("trying to write, but no stream open");
|
if (writer == null) throw new IOStreamError.WRITE("trying to write, but no stream open");
|
||||||
try {
|
try {
|
||||||
log.node("OUT", node);
|
log.node("OUT", node, this);
|
||||||
yield ((!)writer).write_node(node);
|
yield ((!)writer).write_node(node);
|
||||||
} catch (XmlError e) {
|
} catch (XmlError e) {
|
||||||
throw new IOStreamError.WRITE(e.message);
|
throw new IOStreamError.WRITE(e.message);
|
||||||
|
@ -201,7 +204,7 @@ public class XmppStream {
|
||||||
.put_attribute("xmlns", "jabber:client")
|
.put_attribute("xmlns", "jabber:client")
|
||||||
.put_attribute("stream", "http://etherx.jabber.org/streams", XMLNS_URI);
|
.put_attribute("stream", "http://etherx.jabber.org/streams", XMLNS_URI);
|
||||||
outs.has_nodes = true;
|
outs.has_nodes = true;
|
||||||
log.node("OUT ROOT", outs);
|
log.node("OUT ROOT", outs, this);
|
||||||
write(outs);
|
write(outs);
|
||||||
received_root_node(this, yield read_root());
|
received_root_node(this, yield read_root());
|
||||||
}
|
}
|
||||||
|
@ -293,7 +296,7 @@ public class XmppStream {
|
||||||
if (reader == null) throw new IOStreamError.READ("trying to read, but no stream open");
|
if (reader == null) throw new IOStreamError.READ("trying to read, but no stream open");
|
||||||
try {
|
try {
|
||||||
StanzaNode node = yield ((!)reader).read_root_node();
|
StanzaNode node = yield ((!)reader).read_root_node();
|
||||||
log.node("IN ROOT", node);
|
log.node("IN ROOT", node, this);
|
||||||
return node;
|
return node;
|
||||||
} catch (XmlError.TLS e) {
|
} catch (XmlError.TLS e) {
|
||||||
throw new IOStreamError.TLS(e.message);
|
throw new IOStreamError.TLS(e.message);
|
||||||
|
|
|
@ -60,8 +60,6 @@ public class Module : XmppStreamModule {
|
||||||
query_node.put_node(create_set_rsm_node(end_id));
|
query_node.put_node(create_set_rsm_node(end_id));
|
||||||
Iq.Stanza iq = new Iq.Stanza.set(query_node);
|
Iq.Stanza iq = new Iq.Stanza.set(query_node);
|
||||||
|
|
||||||
debug(@"OUT INIT: %s", iq.stanza.to_string());
|
|
||||||
|
|
||||||
Iq.Stanza? result_iq = null;
|
Iq.Stanza? result_iq = null;
|
||||||
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
|
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
|
||||||
result_iq = iq;
|
result_iq = iq;
|
||||||
|
|
Loading…
Reference in a new issue