summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2013-02-25 13:35:44 +0100
committerArne Schwabe <arne@rfc2549.org>2013-02-25 13:35:44 +0100
commitc078407422b7e10f5306b1763ba7986960e92d3a (patch)
treea1b47ac529b415d1868bf2195819cb6ca8b96ee4
parent3e9846e7f4172926b1de2e16c20d8956f4f5cf98 (diff)
Make listener methods synchronized
-rw-r--r--src/de/blinkt/openvpn/OpenVPN.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/de/blinkt/openvpn/OpenVPN.java b/src/de/blinkt/openvpn/OpenVPN.java
index 556f221d..fb759104 100644
--- a/src/de/blinkt/openvpn/OpenVPN.java
+++ b/src/de/blinkt/openvpn/OpenVPN.java
@@ -247,12 +247,12 @@ public class OpenVPN {
logListener.remove(ll);
}
- public static void addByteCountListener(ByteCountListener bcl) {
+ public synchronized static void addByteCountListener(ByteCountListener bcl) {
bcl.updateByteCount(mlastByteCount[0], mlastByteCount[1], mlastByteCount[2], mlastByteCount[3]);
byteCountListener.add(bcl);
}
- public static void removeByteCountListener(ByteCountListener bcl) {
+ public synchronized static void removeByteCountListener(ByteCountListener bcl) {
byteCountListener.remove(bcl);
}
@@ -375,7 +375,7 @@ public class OpenVPN {
newlogItem(new LogItem(LogItem.INFO, ressourceId, args));
}
- private static void newlogItem(LogItem logItem) {
+ private synchronized static void newlogItem(LogItem logItem) {
logbuffer.addLast(logItem);
if(logbuffer.size()>MAXLOGENTRIES)
logbuffer.removeFirst();
@@ -397,11 +397,13 @@ public class OpenVPN {
newlogItem(new LogItem(LogItem.ERROR, ressourceId,args));
}
- public static void updateByteCount(long in, long out) {
+ public static synchronized void updateByteCount(long in, long out) {
long lastIn = mlastByteCount[0];
long lastOut = mlastByteCount[1];
- long diffin = in - lastIn;
- long diffout = out - lastOut;
+ long diffin = mlastByteCount[2] = in - lastIn;
+ long diffout = mlastByteCount[3] = out - lastOut;
+
+
mlastByteCount = new long[] {in,out,diffin,diffout};
for(ByteCountListener bcl:byteCountListener){