0

我正在尝试调试一个名为crowbar的 DOM 抓取。无论如何,当我跑步时,我得到:

错误:[异常...“组件返回失败代码:0xc1f30001(NS_ERROR_NOT_INITIALIZED)[nsIServerSocket.asyncListen]”nsresult:“0xc1f30001(NS_ERROR_NOT_INITIALIZED)”位置:“JS 框架 :: chrome://crowbar/content/crowbar.js : :onLoad ::第375行“数据:否]
源文件:chrome://crowbar/content/crowbar.js
行:375

基本上,asyncListen()就是投掷NS_ERROR_NOT_INITIALIZED。这很奇怪,因为紧接在此之前的代码行是对init()! 我试过添加:

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

就在调用之前asyncListen(),它没有任何效果。这是一个安全问题吗?(顺便说一句,如果重要的话,这是在 Fedora 机器上,以 root 身份运行,禁用 selinux)......我还尝试了一些不同的端口号......

4

2 回答 2

1

Here's the source code: http://mxr.mozilla.org/mozilla-central/source/netwerk/base/src/nsServerSocket.cpp#369

Are you sure init() doesn't fail (that's what initializes mFD)? Maybe something closes it before your call?

I would build a debug XULRunner to build a debug version and/or try to get logging output from the app. Unfortunately, I can't figure out what the LOG() macro in that code resolves to, usually it's NSPR logging, but you have to guess the module name in order to enable logging for this module.

Boris Zbarsky (one mozilla core developers) 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?
于 2009-10-26T13:06:20.127 回答
0

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

当我与网络断开连接时,我遇到了问题。如果我在网络上,它可以工作。我确实有多个线程[多个 xul 元素]。但我相信我在主线程上运行它(虽然我不确定如何找到当前线程),所以线程不监听不应该是问题。

我还注意到在 nsSocketTransportService2.cpp 线程变为空,所以鲍里斯可能是对的。

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;
}

希望这有助于解决问题。

谢谢哈文德

于 2009-12-08T12:43:44.430 回答