summaryrefslogtreecommitdiff
blob: 87a9473ed9378d211a3bd56e469351701d78e0f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
--- src/com/onionnetworks/fec/io/FECFile.java.orig	2015-10-18 15:38:26.000000000 +0000
+++ src/com/onionnetworks/fec/io/FECFile.java	2015-10-18 16:06:51.159486000 +0000
@@ -10,7 +10,9 @@
 import com.onionnetworks.fec.FECCodeFactory;
 import com.onionnetworks.io.RAF;
 import com.onionnetworks.util.*;
-import EDU.oswego.cs.dl.util.concurrent.*;
+
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 /**
  * This class provides the necessary file IO routines to go along with the raw
@@ -129,9 +131,9 @@
         this.raf = new RAF(f,mode); // synched RandomAccessFile        
 
         // Create the locks.
-        locks = new ReadWriteLock[blockCount];
+        locks = new ReentrantReadWriteLock[blockCount];
         for (int i=0;i<locks.length;i++) {
-            locks[i] = new ReentrantWriterPreferenceReadWriteLock();
+            locks[i] = new ReentrantReadWriteLock();
         }
 
         // add the default exception handler.
@@ -258,7 +260,7 @@
         byte[] b = null;
 
         try {
-            locks[blockNum].readLock().acquire();
+            locks[blockNum].readLock().lock();
 	    try {
 
                 // This raf check then pp access is safe because all
@@ -296,9 +298,9 @@
                     return;
                 }
 	    } finally {
-                locks[blockNum].readLock().release();
+                locks[blockNum].readLock().unlock();
 	    }
-	} catch (InterruptedException e) { 
+	} catch (Exception e) { 
 	    throw new InterruptedIOException(e.toString());
 	}
         
@@ -342,13 +344,13 @@
 	
         int result = -1;
         try {
-            locks[blockNum].writeLock().acquire();
+            locks[blockNum].writeLock().lock();
 	    try {
                 result = write0(pkt,blockNum,stripeNum);
 	    } finally {
-                locks[blockNum].writeLock().release();
+                locks[blockNum].writeLock().unlock();
 	    }
-	} catch (InterruptedException e) { 
+	} catch (Exception e) { 
 	    throw new InterruptedIOException(e.toString());
 	}
 
@@ -444,16 +446,16 @@
 	}
 
 	try {
-	    locks[blockNum].writeLock().acquire();
+	    locks[blockNum].writeLock().lock();
 	    try {
 		// seek and write the decoded block.
 		raf.seekAndWrite(blockNum*blockSize,b,0,b.length);
 		// Update the placement to show decoded entries.
 		pp.setBlockDecoded(blockNum);
 	    } finally {
-		locks[blockNum].writeLock().release();
+		locks[blockNum].writeLock().unlock();
 	    }
-	} catch (InterruptedException e) { 
+	} catch (Exception e) { 
 	    throw new InterruptedIOException(e.toString());
 	}
 	 
@@ -468,7 +470,7 @@
      */
     public void acquireAllWriteLocks() throws InterruptedException {
         for (int i=0;i<locks.length;i++) {
-            locks[i].writeLock().acquire();
+            locks[i].writeLock().lock();
         }
     }
 
@@ -479,7 +481,7 @@
      */
     public void releaseAllWriteLocks() throws InterruptedException {
         for (int i=0;i<locks.length;i++) {     
-            locks[i].writeLock().release();
+            locks[i].writeLock().unlock();
         }   
     }