Websh与Apache

风行水上 @ 2015-03-29 14:10:14
标签:

    Websh通过mod_websh可以作为Apache的一个模块使用。但Apache的多线程模型也带来一些编译和使用上的问题。

    这些问题在单独使用libwebsh或者websh的时候则不存在。

    Issues of Websh with Tcl8.5

    > [error] web::interpmap: out of stack space (infinite loop?)
    >
    > [error] [client 172.17.164.111] mod_websh - nointerp!
    

    Some suggestion: "recompiled Tcl with -DTCL_NO_STACK_CHECK"

    Thread Support

    对于Apache 2,需要Tcl编译时--enable-thread选项支持。

    检查"tclConfig.sh"可以查看相关编译选项。

    Build Websh With Tcl8.6

    tclAppInit.o: In function `Tcl_AppInit': /.../websh-3.6.0b5/src/unix/../generic/tclAppInit.c:173:
     undefined reference to `Websh_Init'
    

    .hidden 符号表

    objdump输出符号表里, 'Websh_Init'被标记为".hidden"。

    Your Tcl 8.6 'tclConfig.sh' comes with a "-fvisibility=hidden" 编译选项。

      TCL_EXTRA_CFLAGS=' -pipe -fvisibility=hidden '
    

    去掉该选项后顺利编译成功。

    mod_websh Thread ID check with Tcl8.6

    Websh 3.6.0b5 中的 mod_websh 与 Tcl8.6 一起使用时,使用时碰到以下错误:

    Tcl_AsyncDelete: async handler deleted by the wrong thread
    

    导致Apache进程退出。

    经过调试,实际上这是由于Tcl8.6在删除解释器(Tcl_DeleteInterp)时会调用Tcl_AsyncDelete以对应创建解释器(Tcl_CreateInterp)时的Tcl_AsyncCreate。而Tcl_AsyncDelete会检查Tcl_AsyncCreate时保存的线程ID,不一致则直接Tcl_Panic退出。

    解决办法:

    1. 或者:去掉Tcl_AsyncDelete中的线程ID检查(副作用还不清楚)
    2. 或者:修改Websh代码以避免删除其他进程创建的解释器。(问题:是否可能线程意外退出导致资源无法清除)

    自己修改过的Websh代码:https://github.com/noyesno/tcl-websh

    标签:

      分享到:
      comments powered by Disqus

      34/38ms