Skip to content

Commit 4974481

Browse files
committed
CM Processor: change to daemon thread
Some application (e.g. Spark) rely on the application exiting when the main method returns. This requires all threads still active at the return of main to be daemon threads otherwise the application will wait for the threads to exit. This fix changes the RdmaCmProcessor thread to be a daemon thread. Signed-off-by: Jonas Pfefferle <pepperjo@japf.ch>
1 parent cfcee63 commit 4974481

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/main/java/com/ibm/disni/RdmaCmProcessor.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,33 @@
3333
import com.ibm.disni.util.DiSNILogger;
3434

3535
/**
36-
* Responsible for processing communication events.
36+
* Responsible for processing communication events.
3737
*/
3838
public class RdmaCmProcessor implements Runnable {
3939
private static final Logger logger = DiSNILogger.getLogger();
40-
40+
4141
private RdmaEventChannel cmChannel;
4242
private RdmaEndpointGroup<? extends RdmaEndpoint> cmConsumer;
4343
private Thread thread;
4444
private AtomicBoolean closed;
4545
private int timeout;
46-
46+
4747
public RdmaCmProcessor(RdmaEndpointGroup<? extends RdmaEndpoint> cmConsumer, int timeout) throws IOException {
4848
this.cmChannel = RdmaEventChannel.createEventChannel();
4949
if (cmChannel == null){
5050
throw new IOException("No RDMA device configured!");
5151
}
52-
this.cmConsumer = cmConsumer;
52+
this.cmConsumer = cmConsumer;
5353
this.thread = new Thread(this);
54+
this.thread.setDaemon(true);
5455
closed = new AtomicBoolean(true);
5556
this.timeout = timeout;
5657
}
57-
58+
5859
public synchronized void start(){
5960
closed.set(false);
6061
thread.start();
61-
}
62+
}
6263

6364
public void run() {
6465
logger.info("launching cm processor, cmChannel " + cmChannel.getFd());
@@ -93,7 +94,7 @@ public synchronized void close() throws IOException, InterruptedException {
9394
if (closed.get()){
9495
return;
9596
}
96-
97+
9798
closed.set(true);
9899
thread.join();
99100
logger.info("cm processor down");

0 commit comments

Comments
 (0)