Re: [gtk-vnc-devel] PATCH: Fix co-routine shutdown / release



Daniel P. Berrange wrote:
When the co-routine shuts down we never call coroutine_release, so its
stack never gets unmapped. We also don't restore the 'current' pointer
to be the system coroutine. So if you later start a 2nd coroutine we're
switching state making the return state point to a now deleted coroutine.
All this makes the whole system very crash happy.

So this patch does a couple of things:

  - When the coroutine exits we call coroutine_release
  - When the coroutine exits we make the current context point to the
    system context
  - Ensures errors from swapcontext are passed back correctly, rather
    than return zero which indicates success.

With this patch in place, I can now successfully connect to a VNC server,
disconnect, and then re-connect again without megadeath.

Nice catch!

Regards,

Anthony Liguori

Dan.
------------------------------------------------------------------------

diff -r 7d6bc4441dc1 src/continuation.c
--- a/src/continuation.c	Fri Jul 06 14:39:12 2007 -0400
+++ b/src/continuation.c	Fri Jul 06 17:35:48 2007 -0400
@@ -43,9 +43,7 @@ int cc_swap(struct continuation *from, s
 	else if (to->exited == 1)
 		return 1;
- swapcontext(&from->uc, &to->uc);
-
-	return 0;
+	return swapcontext(&from->uc, &to->uc);
 }
 /*
  * Local variables:
diff -r 7d6bc4441dc1 src/coroutine.c
--- a/src/coroutine.c	Fri Jul 06 14:39:12 2007 -0400
+++ b/src/coroutine.c	Fri Jul 06 17:37:21 2007 -0400
@@ -66,7 +66,7 @@ static struct coroutine *current;
struct coroutine *coroutine_self(void)
 {
-	if (current == 0)
+	if (current == NULL)
 		current = &system;
 	return current;
 }
@@ -82,11 +82,13 @@ void *coroutine_swap(struct coroutine *f
 	if (ret == 0)
 		return from->data;
 	else if (ret == 1) {
+		coroutine_release(to);
+		current = &system;
 		to->exited = 1;
 		return to->data;
 	}
- return 0;
+	return NULL;
 }
void *yieldto(struct coroutine *to, void *arg) ------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
------------------------------------------------------------------------

_______________________________________________
Gtk-vnc-devel mailing list
Gtk-vnc-devel lists sourceforge net
https://lists.sourceforge.net/lists/listinfo/gtk-vnc-devel





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]