免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2329 | 回复: 4
打印 上一主题 下一主题

[网络] nginx的epoll_create的定义怎么是 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-07-29 22:34 |只看该作者 |倒序浏览
int epoll_create(int size)
{
    return -1;
}

int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
{
    return -1;
}

int epoll_wait(int epfd, struct epoll_event *events, int nevents, int timeout)
{
    return -1;
}

这是什么情况呢???

论坛徽章:
4
水瓶座
日期:2013-09-06 12:27:30摩羯座
日期:2013-09-28 14:07:46处女座
日期:2013-10-24 14:25:01酉鸡
日期:2014-04-07 11:54:15
2 [报告]
发表于 2013-07-29 23:21 |只看该作者
去哪看的源码, 这是系统接口, Nginx怎么可能自己实现, 我grep了nginx源代码也没找到.

论坛徽章:
0
3 [报告]
发表于 2013-07-30 07:15 |只看该作者
回复 2# linux_c_py_php


    从nginx的官网下了一份nginx-0.5.38.tar.gz的源码看的...,额,看有些人说nginx没有用glibc库的epoll接口,但是为什么还要实现这种接口呢?

论坛徽章:
2
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:09
4 [报告]
发表于 2013-07-30 10:41 |只看该作者
http://blog.csdn.net/lengzijian/article/details/7609388

去看这个,有一些nginx源码解读

论坛徽章:
17
处女座
日期:2013-08-27 09:59:352015亚冠之柏太阳神
日期:2015-07-30 10:16:402015亚冠之萨济拖拉机
日期:2015-07-29 18:58:182015年亚洲杯之巴勒斯坦
日期:2015-03-06 17:38:17摩羯座
日期:2014-12-11 21:31:34戌狗
日期:2014-07-20 20:57:32子鼠
日期:2014-05-15 16:25:21亥猪
日期:2014-02-11 17:32:05丑牛
日期:2014-01-20 15:45:51丑牛
日期:2013-10-22 11:12:56双子座
日期:2013-10-18 16:28:17白羊座
日期:2013-10-18 10:50:45
5 [报告]
发表于 2013-07-30 11:42 |只看该作者
回复 3# totopper


    谁说的nginx没有glibc的epoll接口的?nginx的epoll定义只是为了生成makefile时进行自动测试用的。也就说是这个代码是用在类似于./configure生成makefile进行特性的feature检测的。保证在没有epoll的系统上可以正常检测,检查过后真正使用的还是glib的接口。

下面的三个代码片段可以看明白这个关系。
  1. int epoll_create(int size)
  2. {
  3.     return -1;
  4. }
复制代码
  1. ngx_feature="epoll"
  2. ngx_feature_name="NGX_HAVE_EPOLL"
  3. ngx_feature_run=yes
  4. ngx_feature_incs="#include <sys/epoll.h>"
  5. ngx_feature_path=
  6. ngx_feature_libs=
  7. ngx_feature_test="int efd = 0;
  8.                   struct epoll_event ee;
  9.                   ee.events = EPOLLIN|EPOLLOUT|EPOLLET;
  10.                   ee.data.ptr = NULL;
  11.                   efd = epoll_create(100);
  12.                   if (efd == -1) return 1;"
  13. . auto/feature

  14. if [ $ngx_found = yes ]; then
  15.     have=NGX_HAVE_CLEAR_EVENT . auto/have
  16.     CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
  17.     EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE"
  18.     EVENT_FOUND=YES
  19. fi
复制代码
  1. #include <sys/types.h>
  2. $NGX_INCLUDE_UNISTD_H
  3. $ngx_feature_incs

  4. int main() {
  5.     $ngx_feature_test;
  6.     return 0;
  7. }

  8. END


  9. ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS $ngx_feature_inc_path \
  10.           -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_TEST_LD_OPT $ngx_feature_libs"

  11. ngx_feature_inc_path=

  12. eval "/bin/sh -c \"$ngx_test\" >> $NGX_AUTOCONF_ERR 2>&1"


  13. if [ -x $NGX_AUTOTEST ]; then

  14.     case "$ngx_feature_run" in

  15.         yes)
  16.             # /bin/sh is used to intercept "Killed" or "Abort trap" messages
  17.             if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
  18.                 echo " found"
  19.                 ngx_found=yes

  20.                 if test -n "$ngx_feature_name"; then
  21.                     have=$ngx_have_feature . auto/have
  22.                 fi

  23.             else
  24.                 echo " found but is not working"
  25.             fi
  26.         ;;

  27.         value)
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP