XULRunner 下的 javascript 服务器失败

发布于 2024-07-22 07:23:11 字数 808 浏览 7 评论 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)...我还尝试了一些不同的端口号...

I'm trying to debug a DOM scraping packaged called crowbar. Anyhow, when I run I get:

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

Basically, asyncListen() is throwing NS_ERROR_NOT_INITIALIZED. This is weird because the line of code immediately before this is a call to init()! I've tried adding:

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

just before the call to asyncListen() and it had no effect. Is this a security issue? (btw, in case it matters, this is on a Fedora box, running as root, with selinux disabled)... I've also tried a few different port numbers...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清浅ˋ旧时光 2024-07-29 07:23:11

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

你确定 init() 不会失败吗(这就是初始化 mFD )? 也许在你打电话之前有什么事情关闭

我会 构建一个调试 XULRunner 来构建调试版本和/或尝试获取日志记录应用程序的输出。 不幸的是,我无法弄清楚该代码中的 LOG() 宏解析为什么,通常是 NSPR 日志记录,但您必须猜测模块名称才能启用此模块的日志记录。

Boris Zbarsky(mozilla 核心开发人员之一)

既然你正在调用 init(),我认为获得一个的唯一其他方法
asyncListen 中的 NS_ERROR_NOT_INITIALIZED 适用于您正在运行的线程
不再接受事件...

所以奇怪的事情正在发生。 实际上是否涉及多个线程?

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?

泪是无色的血 2024-07-29 07:23:11

我也面临这个问题。 我从 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;
}

希望这有助于确定问题。

谢谢
哈温德

I am too facing this problem. I have derived my code from CrowBar and running it through xulrunner 1.9.1 on Win 7.

I get the problem when I am diconnected from the net. If I am on a network it works. I do have multiple threads [multiple xul elements ]. But I belive I am running it on main thread (I am not sure how I can find current thread though), so thread not listening should not be the issue.

Also I have noted that in nsSocketTransportService2.cpp thread becomes null, so Boris maybe right.

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

Hope this helps pin down the problem.

thanks
harvinder

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文