2009-05-27 38 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