免费注册 查看新帖 |

Chinaunix

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

阅读 netkit-tftp-0.17 源码时 有不解之处,请指教。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-12-27 22:44 |只看该作者 |倒序浏览
/*
* Send the requested file.
*/
void
sendfile(int fd, char *name, char *mode)
{
        register struct tftphdr *ap;       /* data and ack packets */
        struct tftphdr *dp;
        volatile int size = 0;
        volatile u_int16_t block = 0;

        int n;
        volatile unsigned long amount = 0;
        struct sockaddr_in from;
        socklen_t fromlen;
        volatile int convert;            /* true if doing nl->;crlf conversion */
        FILE *file;
        volatile int firsttrip = 1;

        startclock();           /* start stat's clock */
        dp = r_init();          /* reset fillbuf/read-ahead code */
        ap = (struct tftphdr *)ackbuf;
        file = fdopen(fd, "r";
        convert = !strcmp(mode, "netascii";

        mysignal(SIGALRM, timer);
        do {
                if (firsttrip) {
                        size = makerequest(WRQ, name, dp, mode) - 4;
                }
                else {
                /*      size = read(fd, dp->;th_data, SEGSIZE);   */
                        size = readit(file, &dp, convert);
                        if (size < 0) {
                                nak(errno + 100);
                                break;
                        }
                        dp->;th_opcode = htons((u_short)DATA);
                        dp->;th_block = htons((u_short)block);
                }
                timeout = 0;
                (void) sigsetjmp(timeoutbuf, 1);
send_data:


我不解的是,为什么需要加volatile 限定?因为我觉得没有发现其他地方对这
几个变量做了修改啊,还是我眼睛花了。
这个是netkit-tftp包的 tftp.c文件
apt-get source tftp 得到的。
请高手指教
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP