美文网首页
wifidog源码分析Lighttpd1.4.20源码分析之插件

wifidog源码分析Lighttpd1.4.20源码分析之插件

作者: 3c937c88e6c0 | 来源:发表于2015-04-17 09:15 被阅读123次

    前面讲了lighttpd插件系统的加载和初始化,这一篇中,将介绍一下plugin.c中的宏PLUGIN_TO_SLOT。

    在将PLUGIN_TO_SLOT宏之前,我们先来看看lighttpd中插件系统的对外接口。这个接口所对的“外”指的是lighttpd服务器。前面已经提到,在运行的过程中,lighttpd不知道所加载的插件都是干什么用的,只知道这些插件所实现的接口,也就是在plugin结构体中那些函数指针有哪些对于某个插件是NULL,哪些是具体的函数地址。

    既然lighttpd只知道这些,那么它又是怎样调用这些插件的呢?

    答案就在plugin.h文件中的下面一系列函数声明:

    handler_t plugins_call_handle_uri_raw(server * srv, connection * con);

    handler_t plugins_call_handle_uri_clean(server * srv,connection * con);

    handler_t plugins_call_handle_subrequest_start(server * srv,connection * con);

    handler_t plugins_call_handle_subrequest(server * srv,connection * con);

    handler_t plugins_call_handle_request_done(server * srv,connection * con);

    handler_t plugins_call_handle_docroot(server * srv,connection * con);

    handler_t plugins_call_handle_physical(server * srv,connection * con);

    handler_t plugins_call_handle_connection_close(server * srv,connection * con);

    handler_t plugins_call_handle_joblist(server * srv,connection * con);

    handler_t plugins_call_connection_reset(server * srv,connection * con);

    handler_t plugins_call_handle_trigger(server * srv);

    handler_t plugins_call_handle_sighup(server * srv);

    handler_t plugins_call_init(server * srv);

    handler_t plugins_call_set_defaults(server * srv);

    handler_t plugins_call_cleanup(server * srv);

    这些函数就是插件系统对外的接口。在运行过程中,lighttpd靠调用上面的这些函数调用插件。比如:在server.c的main函数中,就调用了plugins_call_set_defaults函数:

    if (HANDLER_GO_ON != plugins_call_set_defaults(srv))

    {

    log_error_write(srv, __FILE__, __LINE__, "s",

    "Configuration of plugins failed. Going down.");

    plugins_free(srv);

    network_close(srv);

    server_free(srv);

    return -1;

    }

    ......本站只呈现部分内容,查看完整文章请到WiFiDog官网社区 http://www.wifidog.pro/2015/04/17/wifidog%E6%BA%90%E7%A0%81%E5%88%86%E6%9E%90lighttpd%E6%8F%92%E4%BB%B6%E5%AE%8F%E5%AE%9A%E4%B9%89.html,转载请注明出处

    相关文章

      网友评论

          本文标题:wifidog源码分析Lighttpd1.4.20源码分析之插件

          本文链接:https://www.haomeiwen.com/subject/bwkefttx.html