Embedthis Ejscript Forum

Support for Ejscript -- Javascript Language
It is currently Thu Sep 09, 2010 3:04 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Problems when running under Appweb
PostPosted: Thu Dec 10, 2009 5:42 pm 
Offline

Joined: Thu Dec 10, 2009 5:27 pm
Posts: 2
I have a problem when loading my module in a controller under appweb.

The first time I do a request, everything works ok. But the second time, I get an error:

InternalError Exception: Native function "Client" is not defined Stack: [00] controllers/Api.es, ApiController.ApiController, line 9 -> this._client = new Client();
To have it work correctly I had to comment these line in ejsLib.c on line 30070:

Code:
// if (mprLookupModule(ejs, mp->name) != 0) {
//    mprLog(ejs, 1, "Native module \"%s\" is already loaded", path);
//    return 0;
//}


I had also another problem where the line 29122

Code:
mprGetPathDir(ejs, path);


does returns the ejs application path instead of the module path (say /htdocs/app instead of /lib/appweb) so the loadNativeLibrary function fails and the module is not loaded.


Top
 Profile  
 
 Post subject: Re: Problems when running under Appweb
PostPosted: Fri Dec 11, 2009 10:47 am 
Offline

Joined: Thu Dec 10, 2009 5:27 pm
Posts: 2
Also, there seems to be a problem related with multi-threading. When the module initializations routine are run both at the same time. Note that even without the comment there are crashes. I suppose there might be a race condition between the check
Code:
if (mprLookupModule(ejs, mp->name) != 0)

and the call to
Code:
mprLoadModule(ejs, path, initName).


Top
 Profile  
 
 Post subject: Re: Problems when running under Appweb
PostPosted: Fri Dec 11, 2009 8:27 pm 
Offline

Joined: Mon Feb 09, 2009 3:25 am
Posts: 21
Each request has its own interpreter. But native code is shared through the entire process.

I think u could be right that locks are needed there when loading the native library.

Peter


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[ Time : 0.130s | 10 Queries | GZIP : Off ]