File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
main/java/net/openhft/affinity
test/java/net/openhft/affinity Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,9 @@ private synchronized static boolean isLockFree(int id) {
78
78
}
79
79
80
80
public static int getProcessForCpu (int core ) throws IOException {
81
+ if (!canOSSupportOperation ())
82
+ return EMPTY_PID ;
83
+
81
84
String meta = lockChecker .getMetaInfo (core );
82
85
83
86
if (meta != null && !meta .isEmpty ()) {
Original file line number Diff line number Diff line change @@ -96,4 +96,12 @@ public void lockFileDeletedWhileHeld() throws Exception {
96
96
lockFile = lockChecker .doToFile (cpu );
97
97
Assert .assertTrue ("Lock file should be recreated" , lockFile .exists ());
98
98
}
99
+
100
+ @ Test
101
+ public void getProcessForCpuReturnsEmptyPidWhenNoFile () throws IOException {
102
+ int freeCpu = 99 ;
103
+ File lockFile = lockChecker .doToFile (freeCpu );
104
+ Assert .assertFalse (lockFile .exists ());
105
+ Assert .assertEquals (Integer .MIN_VALUE , LockCheck .getProcessForCpu (freeCpu ));
106
+ }
99
107
}
You can’t perform that action at this time.
0 commit comments