在 chroot 中执行服务(openoffice headless)很慢

发布于 2024-09-03 04:51:00 字数 2156 浏览 14 评论 0原文

我创建了一个 ubuntu chroot 环境(使用 debootstrap)并启动 openoffice 作为服务来使用 unoconv 转换文件。它可以工作,但它花费大约 20 秒来进行转换,而在 chroot 监狱之外则低于 1 秒。通过分析,我可以看到这些额外的时间花费在一些超时到期的套接字操作上,这些操作在没有 chroot 环境的情况下也能正常工作。然而,类似的操作效果很好。

有什么建议吗?


启动服务器(chrooted):

soffice -invisible -headless -nologo -nodefault "-accept=socket,host=localhost,port=8301;urp;StarOffice.ComponentContext" -env:UserInstallation=ootest2

调用它(也chrooted):

strace unoconv -f pdf -p 8300 simple_test.docx

超时跟踪:

socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)
fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
poll([{fd=4, events=POLLOUT}], 1, 0)    = 1 ([{fd=4, revents=POLLOUT}])
sendto(4, "M#\1\0\0\1\0\0\0\0\0\0\tlocalhost\6(none)\10mo"..., 47, MSG_NOSIGNAL, NULL, 0) = 47
poll([{fd=4, events=POLLIN}], 1, 5000)  = 0 (Timeout)
close(4)                                = 0

类似的跟踪,没有超时(相同的unoconv操作):

socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)
fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
poll([{fd=4, events=POLLOUT}], 1, 0)    = 1 ([{fd=4, revents=POLLOUT}])
sendto(4, "M#\1\0\0\1\0\0\0\0\0\0\tlocalhost\6(none)\10mo"..., 47, MSG_NOSIGNAL, NULL, 0) = 47
poll([{fd=4, events=POLLIN}], 1, 5000)  = 1 ([{fd=4, revents=POLLIN}])
ioctl(4, FIONREAD, [47])                = 0
recvfrom(4, "M#\201\202\0\1\0\0\0\0\0\0\tlocalhost\6(none)\10mo"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, [16]) = 47
close(4)                                = 0

chroot详细信息:

  • 使用dchroot将其用作普通用户
  • 挂载的dev,proc等(fstab ):

    /tmp /var/local/chrootest/tmp
    /dev /var/local/chrootest/dev
    /sys /var/local/chrootest/sys
    proc-chroot /var/local/chrootest/proc
    devpts-chroot /var/local/chrootest/dev/pts

I created an ubuntu chroot environment (using debootstrap) and started openoffice as a service to convert files using unoconv. It works but it spends about 20s to do conversions which are below 1s outside chroot jail. Stracing it I can see that this extra time is spent in some socket operations whose timeout expires, the same operations that work well without a chroot environment. However, similar operations works fine.

Any suggestion?


starting server (chrooted):

soffice -invisible -headless -nologo -nodefault "-accept=socket,host=localhost,port=8301;urp;StarOffice.ComponentContext" -env:UserInstallation=ootest2

calling it (chrooted too):

strace unoconv -f pdf -p 8300 simple_test.docx

timeout trace:

socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)
fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
poll([{fd=4, events=POLLOUT}], 1, 0)    = 1 ([{fd=4, revents=POLLOUT}])
sendto(4, "M#\1\0\0\1\0\0\0\0\0\0\tlocalhost\6(none)\10mo"..., 47, MSG_NOSIGNAL, NULL, 0) = 47
poll([{fd=4, events=POLLIN}], 1, 5000)  = 0 (Timeout)
close(4)                                = 0

similar trace without timeout (same unoconv operation):

socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)
fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
poll([{fd=4, events=POLLOUT}], 1, 0)    = 1 ([{fd=4, revents=POLLOUT}])
sendto(4, "M#\1\0\0\1\0\0\0\0\0\0\tlocalhost\6(none)\10mo"..., 47, MSG_NOSIGNAL, NULL, 0) = 47
poll([{fd=4, events=POLLIN}], 1, 5000)  = 1 ([{fd=4, revents=POLLIN}])
ioctl(4, FIONREAD, [47])                = 0
recvfrom(4, "M#\201\202\0\1\0\0\0\0\0\0\tlocalhost\6(none)\10mo"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, [16]) = 47
close(4)                                = 0

chroot details:

  • using dchroot to use it as a normal user
  • mounted dev, proc, etc as (fstab):

    /tmp /var/local/chrootest/tmp
    /dev /var/local/chrootest/dev
    /sys /var/local/chrootest/sys
    proc-chroot /var/local/chrootest/proc
    devpts-chroot /var/local/chrootest/dev/pts

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

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

发布评论

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

评论(1

傲娇萝莉攻 2024-09-10 04:51:00

unoconv 会进行一些奇怪的 DNS 查找。我将其添加到我的 /etc/hosts 中:

127.0.0.1 localhost localhost.(none)

它使事情变得明显更好。

unoconv does some wack DNS lookups. I added this to my /etc/hosts:

127.0.0.1 localhost localhost.(none)

And it made things significantly better.

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