[Freeswitch-svn] [commit] r5002 - in freeswitch/trunk: libs/js/src src src/include src/mod/languages/mod_spidermonkey

Freeswitch SVN mikej at freeswitch.org
Mon Apr 23 11:33:26 EDT 2007


Author: mikej
Date: Mon Apr 23 11:33:25 2007
New Revision: 5002

Modified:
   freeswitch/trunk/libs/js/src/jspubtd.h
   freeswitch/trunk/src/include/switch_apr.h
   freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
   freeswitch/trunk/src/switch_apr.c

Log:
Fix 2 errors in mod_spidermonkey on windows.
1. We need a pool for apr_stat.  Expand api and create a pool when necessary.
2. Don't use -1 value in enum for no reason as they can be signed or unsigned (compiler defined) so there is an int overflow.  This fixes an incorrect assert in the spidermonkey exception handling caused by an unsigned int overflow.

resolve http://jira.freeswitch.org/browse/MODLANG-7. 


Modified: freeswitch/trunk/libs/js/src/jspubtd.h
==============================================================================
--- freeswitch/trunk/libs/js/src/jspubtd.h	(original)
+++ freeswitch/trunk/libs/js/src/jspubtd.h	Mon Apr 23 11:33:25 2007
@@ -552,7 +552,7 @@
  * JSEXN_NONE marks an unthrowable error.
  */
 typedef enum JSExnType {
-    JSEXN_NONE = -1,
+    JSEXN_NONE,
       JSEXN_ERR,
         JSEXN_INTERNALERR,
         JSEXN_EVALERR,

Modified: freeswitch/trunk/src/include/switch_apr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_apr.h	(original)
+++ freeswitch/trunk/src/include/switch_apr.h	Mon Apr 23 11:33:25 2007
@@ -733,7 +733,7 @@
  */
 SWITCH_DECLARE(switch_status_t) switch_file_write(switch_file_t * thefile, const void *buf, switch_size_t *nbytes);
 
-SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename);
+SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename, switch_memory_pool_t *pool);
 
 /** @} */
 

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Mon Apr 23 11:33:25 2007
@@ -2771,7 +2771,7 @@
 		path  = switch_mprintf("%s%smwi.js", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR);
 		assert(path != NULL);
 
-		if (switch_file_exists(path) == SWITCH_STATUS_SUCCESS) {
+		if (switch_file_exists(path, NULL) == SWITCH_STATUS_SUCCESS) {
 			cmd = switch_mprintf("%s %s", path, account);
 			assert(cmd != NULL);
 			js_thread_launch(cmd);

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h	Mon Apr 23 11:33:25 2007
@@ -91,7 +91,7 @@
 			script_name = path;
 		}
 		if (script_name) {
-			if (switch_file_exists(script_name) == SWITCH_STATUS_SUCCESS) {
+			if (switch_file_exists(script_name, NULL) == SWITCH_STATUS_SUCCESS) {
 				script = JS_CompileFile(cx, obj, script_name);
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Open File: %s\n", script_name);

Modified: freeswitch/trunk/src/switch_apr.c
==============================================================================
--- freeswitch/trunk/src/switch_apr.c	(original)
+++ freeswitch/trunk/src/switch_apr.c	Mon Apr 23 11:33:25 2007
@@ -335,17 +335,31 @@
 	return apr_file_write(thefile, buf, nbytes);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename)
+SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename, switch_memory_pool_t *pool)
 {
 	int32_t wanted = APR_FINFO_TYPE;
+	switch_memory_pool_t *our_pool = NULL;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 	apr_finfo_t info = { 0 };
+
+	if (!pool) {
+		if ((apr_pool_create(&our_pool, NULL)) != SWITCH_STATUS_SUCCESS) {
+			return SWITCH_STATUS_MEMERR;
+		}
+	}
+
 	if (filename) {
-		apr_stat(&info, filename, wanted, NULL);
+		apr_stat(&info, filename, wanted, pool ? pool : our_pool);
 		if (info.filetype != APR_NOFILE) {
-			return SWITCH_STATUS_SUCCESS;
+			status =  SWITCH_STATUS_SUCCESS;
 		}
 	}
-	return SWITCH_STATUS_FALSE;
+
+	if (our_pool) {
+		apr_pool_destroy(our_pool);
+	}
+
+	return status;
 }
 
 /* thread stubs */



More information about the Freeswitch-svn mailing list