kernel - lwkt_token code, minor fix to last commit
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 21 Dec 2009 05:34:02 +0000 (21:34 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 21 Dec 2009 05:34:02 +0000 (21:34 -0800)
* lwkt_getalltokens() has to release any partially acquired tokens
  when it fails to get them all.  Fixes an issue with the last commit
  that could cause processes to get stuck in a Run state.

sys/kern/lwkt_token.c

index ce5c01a..143d0b5 100644 (file)
@@ -129,7 +129,8 @@ _lwkt_token_pool_lookup(void *ptr)
 
 /*
  * Obtain all the tokens required by the specified thread on the current
- * cpu, return 0 on failure and non-zero on success.
+ * cpu, return 0 on failure and non-zero on success.  If a failure occurs
+ * any partially acquired tokens will be released prior to return.
  *
  * lwkt_getalltokens is called by the LWKT scheduler to acquire all
  * tokens that the thread had acquired prior to going to sleep.
@@ -180,8 +181,10 @@ lwkt_getalltokens(thread_t td)
                         */
                        scan2 = td->td_toks;
                        for (;;) {
-                               if (scan2 == scan1)
+                               if (scan2 == scan1) {
+                                       lwkt_relalltokens(td);
                                        return(FALSE);
+                               }
                                if (scan2 == ref) {
                                        tok->t_ref = scan1;
                                        break;