Martti Malmi 通信

回复:Linux 构建

中本聪 · 2009 年 11 月 6 日

SN-10089 附来源、原文与上下文。

阅读语言

现在它在 Linux 上能稳定运行了,只有一个例外:如果在 GUI 线程之外调用 wxMessageBox(),就会崩溃,因为 Linux 上的非 GUI 线程不能打开窗口。我还没来得及修复这一点。我一直在运行压力测试,功能正常。

It works reliably on Linux now, except if it uses wxMessageBox() outside the GUI thread, it'll crash because non-GUI threads can't open a window on Linux. I haven't got to fixing that yet. I've been running my stress test on it and it's functioning normally.

在 UI 线程之外使用 wxWidgets,大部分功能都不是线程安全的,但在 Windows 上,经验上凡是与 UI 无关的东西都没问题。结果在 GTK 上,不具备线程安全的地方更多。我一次替换了很多东西,所以不知道是否只是某一处导致的(可能是 Repaint),但我必须假定,任何使用 wxString 的 wx 函数,在 UI 线程之外都不安全。真糟糕,那些好用的 wxWidgets 可移植性辅助函数都不能用了。我保留了 wxThread::GetCPUCount() 之类的简单功能,我查过源码,全是数值运算;而 wxMutex 必须安全,否则就毫无用处。

Most of wxWidgets is not thread-safe to use in threads other than the UI thread, but as a rule of thumb on Windows anything not UI related is OK. It turns out its more thread-unsafe on GTK. I replaced a bunch of stuff at once so I don't know if it was just one thing (probably Repaint), but I have to assume even any wx function that uses wxString is not safe to use outside the UI thread. So dang, there goes all the nice wxWidgets portability support functions. I left a few simple things like wxThread::GetCPUCount() that I checked the source and it's all numerical, and wxMutex has to be safe or it'd be useless.

有个问题:退出后立即重新运行,无法绑定 8333 端口。大约一分钟后,端口才会释放。除非我漏了什么,否则我确实在退出前关闭了套接字,所以不知道还能做什么。也许 Linux 就是这样,要花一分钟才能释放曾绑定的端口。可能是一种安全功能,防止木马杀掉 Web 服务器后,马上顶替它,接收所有客户端的重试请求。

There's an issue that if you exit and run it again right away, it can't bind port 8333. The port frees up after about a minute. Unless I'm missing something, I am closing the socket before exit, so I don't know what else I can do. Maybe this is just something about Linux that it takes a minute to free up a port you had bound. Possibly a security feature so some trojan doesn't kill the web server and quickly jump into its place and pick up all the client retries.

还得弄清楚怎样正确制作 xpm 版本的图标。

Still gotta figure out how to do the xpm version of the icon correctly.

不知道数据库的 dat 文件能否与 Windows 互换。

I wonder if the database dat files are interchangeable with Windows.

来源

阅读字号

选择适合你的字号,之后阅读会继续使用。