Hi,

Currently, you can destroy RT_PIPE while a non-rt application is
connected. If that happens the pipe won't be fully closed but
some parts will be leftover for cleanup when closing the RT_PIPE
from the non-rt application (lingering close).

For us it would be very convenient if we didn't have to close
the non-rt side before restarting the rt-side (currently, the 
rt-side complains bc the non-rt side didn't resolve the lingering
close).

Here is a patch where the rt-side resolves the lingering close
when connecting to the RT_PIPE. I tested it and it seems to work 
fine. Do you have any concerns?

Andreas


--- pipe.orig.c	2009-09-09 17:23:10.000000000 -0400
+++ pipe.c	2009-09-09 17:32:48.000000000 -0400
@@ -309,17 +309,35 @@
 int xnpipe_connect(int minor, struct xnpipe_operations *ops, void *xstate)
 {
 	struct xnpipe_state *state;
-	int need_sched = 0, ret;
+	int need_sched = 0, test_lclose = 0, ret;
 	spl_t s;
 
-	minor = xnpipe_minor_alloc(minor);
-	if (minor < 0)
+	ret = xnpipe_minor_alloc(minor);
+	if (ret >= 0)
+		minor = ret;
+	else 
+	if(ret == -EBUSY)
+		test_lclose = 1;
+	else 
 		return minor;
 
 	state = &xnpipe_states[minor];
 
 	xnlock_get_irqsave(&nklock, s);
 
+	if(test_lclose) {
+		if(testbits(state->status, XNPIPE_KERN_LCLOSE)) {
+			clrbits(state->status, XNPIPE_KERN_LCLOSE);
+			xnlock_put_irqrestore(&nklock, s);
+			state->ops.release(state->xstate);
+		} else {
+			xnlock_put_irqrestore(&nklock, s);
+			return -EBUSY;
+		}
+	}
+			
+	xnlock_get_irqsave(&nklock, s);
+
 	ret = xnpipe_set_ops(state, ops);
 	if (ret) {
 		xnlock_put_irqrestore(&nklock, s);
_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to