2009-05-27 43 views
0

我试图调试一个DOM包装打包叫crowbar。总之,当我运行我得到:XULRunner下的javascript服务器失败

Error: [Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIServerSocket.asyncListen]" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: chrome://crowbar/content/crowbar.js :: onLoad :: line 375" data: no]
Source File: chrome://crowbar/content/crowbar.js
Line: 375

基本上,asyncListen()抛出NS_ERROR_NOT_INITIALIZED。这很奇怪,因为在此之前的代码行是对init()的调用!我试着加入:它没有任何效果

netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 

调用asyncListen()之前和。这是一个安全问题吗? (顺便说一句,如果它的问题,这是在一个Fedora框,以root身份运行,selinux禁用)...我也尝试了几个不同的端口号...

+0

(只是要清楚,UniversalXPConnect东西来自于谷歌的结果:。这很奇怪,不应该被需要。) – Nickolay 2009-10-26 12:59:25

回答

1

这里是源代码:http://mxr.mozilla.org/mozilla-central/source/netwerk/base/src/nsServerSocket.cpp#369

你确定init()没有失败(这是什么初始化mFD)?在你打电话之前可能有些东西是close

我会build a debug XULRunner构建一个调试版本和/或尝试从应用程序获取日志输出。不幸的是,我无法弄清楚代码中的LOG()宏是怎么解决的,通常是NSPR logging,但是你必须猜测模块的名字才能启用这个模块的日志记录功能。

鲍里斯Zbarsky(一个Mozilla的核心开发人员)says

Since you're calling init(), the only other way I see to get an NS_ERROR_NOT_INITIALIZED out of asyncListen is for the thread you're running on to no longer be accepting events... So something odd is happening. Are there in fact multiple threads involved?
0

我也面临这个问题。我从CrowBar派生出我的代码,并在Win 7上通过xulrunner 1.9.1运行它。

我从网络连接时遇到问题。如果我在网络上工作。我确实有多个线程[多个xul元素]。但我相信我在主线程上运行它(我不确定我怎么能找到当前线程),所以线程不听不应该成为问题。

另外我注意到在nsSocketTransportService2.cpp线程变为null,所以Boris也许是对的。

NS_IMETHODIMP 
nsSocketTransportService::Dispatch (nsIRunnable *event, PRUint32 flags) 
{ 

    LOG(("STS dispatch [%p]\n", event)); 
    nsCOMPtr<nsIThread> thread = GetThreadSafely(); 
    NS_ENSURE_TRUE(thread, NS_ERROR_NOT_INITIALIZED); 
    nsresult rv = thread->Dispatch(event, flags); 
    if (rv == NS_ERROR_UNEXPECTED) { 
     // Thread is no longer accepting events. We must have just shut it 
     // down on the main thread. Pretend we never saw it. 
     rv = NS_ERROR_NOT_INITIALIZED; 
    } 
    return rv; 
} 

希望这有助于确定问题。

感谢 harvinder