From 1c21d58cbb9f85a3d7334b84383ab9506b5457a7 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Thu, 2 Dec 2004 03:20:23 +0000
Subject: [PATCH] Use js_GenericBranchCallback() for majority of work.

---
 src/sbbs3/services.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/src/sbbs3/services.c b/src/sbbs3/services.c
index 75676fe4f5..9b974b1389 100644
--- a/src/sbbs3/services.c
+++ b/src/sbbs3/services.c
@@ -900,28 +900,14 @@ js_BranchCallback(JSContext *cx, JSScript *script)
 	if((client=(service_client_t*)JS_GetContextPrivate(cx))==NULL)
 		return(JS_FALSE);
 
-	client->branch.counter++;
-
 	/* Terminated? */ 
-	if(client->branch.auto_terminate && terminated) {
+	if(terminated) {
 		JS_ReportError(cx,"Terminated");
 		client->branch.counter=0;
 		return(JS_FALSE);
 	}
-	/* Infinite loop? */
-	if(client->branch.limit && client->branch.counter > client->branch.limit) {
-		JS_ReportError(cx,"Infinite loop (%lu branches) detected",client->branch.counter);
-		client->branch.counter=0;
-		return(JS_FALSE);
-	}
-	/* Give up timeslices every once in a while */
-	if(client->branch.yield_interval && (client->branch.counter%client->branch.yield_interval)==0)
-		YIELD();
-
-	if(client->branch.gc_interval && (client->branch.counter%client->branch.gc_interval)==0)
-		JS_MaybeGC(cx), client->branch.gc_attempts++;
 
-    return(JS_TRUE);
+	return js_GenericBranchCallback(cx,&client->branch);
 }
 
 static void js_init_args(JSContext* js_cx, JSObject* js_obj, const char* cmdline)
-- 
GitLab