免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1872 | 回复: 0

[系统] ppp-2.4.x的源代码疑似问题(全局变量编译会不会有 [复制链接]

论坛徽章:
0
发表于 2016-06-14 19:21 |显示全部楼层
main.c

主loop里面有
handle_events()
{
    struct timeval timo;

    kill_link = open_ccp_flag = 0;
    if (sigsetjmp(sigjmp, 1) == 0) {
        sigprocmask(SIG_BLOCK, &signals_handled, NULL);
        if (got_sighup || got_sigterm || got_sigusr2 || got_sigchld) {
            sigprocmask(SIG_UNBLOCK, &signals_handled, NULL);
        } else {
            waiting = 1;
            sigprocmask(SIG_UNBLOCK, &signals_handled, NULL);
            wait_input(timeleft(&timo));
        }
    }
    waiting = 0;
    calltimeout();
    if (got_sighup) {
        info("Hangup (SIGHUP)");
        kill_link = 1;
        got_sighup = 0;
        if (status != EXIT_HANGUP)
            status = EXIT_USER_REQUEST;
    }
    if (got_sigterm) {
        info("Terminating on signal %d", got_sigterm);
        kill_link = 1;
        asked_to_quit = 1;
        persist = 0;

信号处理里面是
static void
term(sig)
    int sig;
{
    /* can't log a message here, it can deadlock */
    got_sigterm = sig;
    if (conn_running)
        /* Send the signal to the [dis]connector process(es) also */
        kill_my_pg(sig);
    notify(sigreceived, sig);
    if (waiting)
        siglongjmp(sigjmp, 1);
}

而got_sigterm是全局变量,没有声明成volatile

我的想法是有没有可能在主循环里面got_sigterm被编译优化到寄存器里面,这样的话就有话就算信号处理里面改掉,主循环感知不到呢。

但目前来讲从来没发生这种情况。我的问题就是全局变量编译一般会不会有寄存器变量。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP