[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-lib/master] Fix blocking in descriptor reader, found by iwakeh.
commit 8badff7a5bfd049a7bec4349e598ed89525ae84c
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Tue Jan 13 18:17:52 2015 +0100
Fix blocking in descriptor reader, found by iwakeh.
Fixes #14071.
---
.../descriptor/impl/DescriptorReaderImpl.java | 24 +++++++++++++++-----
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java b/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java
index 0811273..94c1d2e 100644
--- a/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java
+++ b/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java
@@ -150,12 +150,24 @@ public class DescriptorReaderImpl implements DescriptorReader {
failUnrecognizedDescriptorLines);
}
public void run() {
- this.readOldHistory();
- this.readDescriptors();
- this.readTarballs();
- this.hasFinishedReading = true;
- this.descriptorQueue.setOutOfDescriptors();
- this.writeNewHistory();
+ try {
+ this.readOldHistory();
+ this.readDescriptors();
+ this.readTarballs();
+ this.hasFinishedReading = true;
+ } catch (Throwable t) {
+ /* We're usually not writing to stdout or stderr, but we shouldn't
+ * stay quiet about this potential bug. If we were to switch to a
+ * logging API, this would qualify as ERROR. */
+ System.err.println("Bug: uncaught exception or error while "
+ + "reading descriptors:");
+ t.printStackTrace();
+ } finally {
+ this.descriptorQueue.setOutOfDescriptors();
+ }
+ if (this.hasFinishedReading) {
+ this.writeNewHistory();
+ }
}
private void readOldHistory() {
if (this.historyFile == null) {
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits