当前位置: 技术问答>linux和unix
linux内核tcp_sendmsg函数的struct kiocb *iocb的作用和,相关打印信息的问题(分值有点少,就这么点了,等赚了再加分)
来源: 互联网 发布时间:2017-03-13
本文导语: 各位linux内核高手们:晚辈想请教个问题,(分值有点少,给不出来了,等赚了再加分)用tcp发送数据最终是要到 int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,size_t size)函数里面,但是我在函数代码...
各位linux内核高手们:晚辈想请教个问题,(分值有点少,给不出来了,等赚了再加分)用tcp发送数据最终是要到
int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,size_t size)函数里面,但是我在函数代码里面没有看到参数struct kiocb *iocb的用处,这是何解?我准备在这种加一个压缩算法,对tcp的数据部分进行压缩。但是有些问题,我用ftp发送了3M的文件文件,copied是计算发送了多少数据,copy表示每一次从用户空间复制的数据
int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
size_t size)
{
。。。。。
clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
mss_now = tcp_send_mss(sk, &size_goal, flags);
/* Ok commence sending. */
iovlen = msg->msg_iovlen;
iov = msg->msg_iov;
copied = 0;
err = -EPIPE;
if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
goto out_err;
sg = sk->sk_route_caps & NETIF_F_SG;
printk(KERN_INFO " tcp_sendmsg mss_now=%dn",mss_now);
printk(KERN_INFO " tcp_sendmsg msg->msg_iovlen=%dn",iovlen);
while (--iovlen >= 0) {
size_t seglen = iov->iov_len;
unsigned char __user *from = iov->iov_base;
printk(KERN_INFO " tcp_sendmsg iov->iov_len=%dn",iov->iov_len);
printk(KERN_INFO " tcp_sendmsg max = size_goal==%dn",size_goal);
iov++;
while (seglen > 0) {
int copy = 0;
int max = size_goal;
结果显示::
Sep 7 14:57:42 ubuntu kernel: [ 2908.250091] tcp_sendmsg mss_now=1448
Sep 7 14:57:42 ubuntu kernel: [ 2908.250094] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:42 ubuntu kernel: [ 2908.250097] tcp_sendmsg iov->iov_len=51056
Sep 7 14:57:42 ubuntu kernel: [ 2908.250099] tcp_sendmsg max = size_goal==2896
Sep 7 14:57:42 ubuntu kernel: [ 2908.250135] tcp_sendmsg mss_now=1448
Sep 7 14:57:42 ubuntu kernel: [ 2908.250137] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:42 ubuntu kernel: [ 2908.250140] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:42 ubuntu kernel: [ 2908.250142] tcp_sendmsg max = size_goal==2896
Sep 7 14:57:42 ubuntu kernel: [ 2908.250152] tcp_sendmsg mss_now=1448
Sep 7 14:57:42 ubuntu kernel: [ 2908.250154] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:42 ubuntu kernel: [ 2908.250156] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:42 ubuntu kernel: [ 2908.250158] tcp_sendmsg max = size_goal==2896
Sep 7 14:57:43 ubuntu kernel: [ 2908.301186] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.301191] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.301194] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.301197] tcp_sendmsg max = size_goal==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301201] tcp_sendmsg copy==1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.301207] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301211] tcp_sendmsg copy==3888
Sep 7 14:57:43 ubuntu kernel: [ 2908.301218] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301222] tcp_sendmsg copy==4136
Sep 7 14:57:43 ubuntu kernel: [ 2908.301228] tcp_sendmsg copy==40
Sep 7 14:57:43 ubuntu kernel: [ 2908.301233] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301238] tcp_sendmsg copy==288
Sep 7 14:57:43 ubuntu kernel: [ 2908.301243] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301248] tcp_sendmsg copy==536
Sep 7 14:57:43 ubuntu kernel: [ 2908.301253] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301258] tcp_sendmsg copy==784
Sep 7 14:57:43 ubuntu kernel: [ 2908.301264] tcp_sendmsg copied==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.301319] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.301323] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.301326] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.301329] tcp_sendmsg max = size_goal==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301343] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.301346] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.301349] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.301352] tcp_sendmsg max = size_goal==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.354858] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.354862] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.354866] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.354869] tcp_sendmsg max = size_goal==11584
Sep 7 14:57:43 ubuntu kernel: [ 2908.354872] tcp_sendmsg copy==7240
Sep 7 14:57:43 ubuntu kernel: [ 2908.354878] tcp_sendmsg copy==3928
Sep 7 14:57:43 ubuntu kernel: [ 2908.354886] tcp_sendmsg copy==11584
Sep 7 14:57:43 ubuntu kernel: [ 2908.354889] tcp_sendmsg copy==11416
Sep 7 14:57:43 ubuntu kernel: [ 2908.354895] tcp_sendmsg copy==7320
Sep 7 14:57:43 ubuntu kernel: [ 2908.354901] tcp_sendmsg copy==3224
Sep 7 14:57:43 ubuntu kernel: [ 2908.354908] tcp_sendmsg copied==18824
Sep 7 14:57:43 ubuntu kernel: [ 2908.354960] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.354963] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.354966] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.354969] tcp_sendmsg max = size_goal==11584
Sep 7 14:57:43 ubuntu kernel: [ 2908.354983] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.354986] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.354989] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.354992] tcp_sendmsg max = size_goal==11584
Sep 7 14:57:43 ubuntu kernel: [ 2908.364413] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364417] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364420] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.364423] tcp_sendmsg max = size_goal==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364434] tcp_sendmsg copy==11584
Sep 7 14:57:43 ubuntu kernel: [ 2908.364438] tcp_sendmsg copy==10712
Sep 7 14:57:43 ubuntu kernel: [ 2908.364445] tcp_sendmsg copy==6616
Sep 7 14:57:43 ubuntu kernel: [ 2908.364450] tcp_sendmsg copy==2520
Sep 7 14:57:43 ubuntu kernel: [ 2908.364462] tcp_sendmsg copy==5792
Sep 7 14:57:43 ubuntu kernel: [ 2908.364467] tcp_sendmsg copy==4216
Sep 7 14:57:43 ubuntu kernel: [ 2908.364473] tcp_sendmsg copy==120
Sep 7 14:57:43 ubuntu kernel: [ 2908.364477] tcp_sendmsg copy==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364483] tcp_sendmsg copy==19192
Sep 7 14:57:43 ubuntu kernel: [ 2908.364489] tcp_sendmsg copy==15096
Sep 7 14:57:43 ubuntu kernel: [ 2908.364494] tcp_sendmsg copy==11000
Sep 7 14:57:43 ubuntu kernel: [ 2908.364499] tcp_sendmsg copy==6904
Sep 7 14:57:43 ubuntu kernel: [ 2908.364505] tcp_sendmsg copy==2808
Sep 7 14:57:43 ubuntu kernel: [ 2908.364515] tcp_sendmsg copied==40544
Sep 7 14:57:43 ubuntu kernel: [ 2908.364564] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364567] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364569] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.364571] tcp_sendmsg max = size_goal==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364630] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364632] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364635] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.364637] tcp_sendmsg max = size_goal==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364770] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364773] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364775] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.364778] tcp_sendmsg max = size_goal==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364800] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364802] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364804] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.364807] tcp_sendmsg max = size_goal==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364817] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364819] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364822] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.364824] tcp_sendmsg max = size_goal==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364832] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364834] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364837] tcp_sendmsg iov->iov_len=6553
结果显示copied的和是和文件大小一样的,copy的数据我觉得有点无法解释,而且顺序也不完全按照我们平时程序的规则,copy之和应该和iov->iov_len长度一样。
打印顺序应该是 mss_now,msg->msg_iovlen,iov->iov_len,max = size_goal,copy,和copied,怎么顺序乱了
也许我没有理解到linux内核的运作,也许是struct kiocb *iocb的原因了....
各种不懂
忘高手解答!
谢谢大家了!!
int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,size_t size)函数里面,但是我在函数代码里面没有看到参数struct kiocb *iocb的用处,这是何解?我准备在这种加一个压缩算法,对tcp的数据部分进行压缩。但是有些问题,我用ftp发送了3M的文件文件,copied是计算发送了多少数据,copy表示每一次从用户空间复制的数据
int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
size_t size)
{
。。。。。
clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
mss_now = tcp_send_mss(sk, &size_goal, flags);
/* Ok commence sending. */
iovlen = msg->msg_iovlen;
iov = msg->msg_iov;
copied = 0;
err = -EPIPE;
if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
goto out_err;
sg = sk->sk_route_caps & NETIF_F_SG;
printk(KERN_INFO " tcp_sendmsg mss_now=%dn",mss_now);
printk(KERN_INFO " tcp_sendmsg msg->msg_iovlen=%dn",iovlen);
while (--iovlen >= 0) {
size_t seglen = iov->iov_len;
unsigned char __user *from = iov->iov_base;
printk(KERN_INFO " tcp_sendmsg iov->iov_len=%dn",iov->iov_len);
printk(KERN_INFO " tcp_sendmsg max = size_goal==%dn",size_goal);
iov++;
while (seglen > 0) {
int copy = 0;
int max = size_goal;
结果显示::
Sep 7 14:57:42 ubuntu kernel: [ 2908.250091] tcp_sendmsg mss_now=1448
Sep 7 14:57:42 ubuntu kernel: [ 2908.250094] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:42 ubuntu kernel: [ 2908.250097] tcp_sendmsg iov->iov_len=51056
Sep 7 14:57:42 ubuntu kernel: [ 2908.250099] tcp_sendmsg max = size_goal==2896
Sep 7 14:57:42 ubuntu kernel: [ 2908.250135] tcp_sendmsg mss_now=1448
Sep 7 14:57:42 ubuntu kernel: [ 2908.250137] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:42 ubuntu kernel: [ 2908.250140] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:42 ubuntu kernel: [ 2908.250142] tcp_sendmsg max = size_goal==2896
Sep 7 14:57:42 ubuntu kernel: [ 2908.250152] tcp_sendmsg mss_now=1448
Sep 7 14:57:42 ubuntu kernel: [ 2908.250154] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:42 ubuntu kernel: [ 2908.250156] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:42 ubuntu kernel: [ 2908.250158] tcp_sendmsg max = size_goal==2896
Sep 7 14:57:43 ubuntu kernel: [ 2908.301186] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.301191] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.301194] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.301197] tcp_sendmsg max = size_goal==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301201] tcp_sendmsg copy==1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.301207] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301211] tcp_sendmsg copy==3888
Sep 7 14:57:43 ubuntu kernel: [ 2908.301218] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301222] tcp_sendmsg copy==4136
Sep 7 14:57:43 ubuntu kernel: [ 2908.301228] tcp_sendmsg copy==40
Sep 7 14:57:43 ubuntu kernel: [ 2908.301233] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301238] tcp_sendmsg copy==288
Sep 7 14:57:43 ubuntu kernel: [ 2908.301243] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301248] tcp_sendmsg copy==536
Sep 7 14:57:43 ubuntu kernel: [ 2908.301253] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301258] tcp_sendmsg copy==784
Sep 7 14:57:43 ubuntu kernel: [ 2908.301264] tcp_sendmsg copied==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.301319] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.301323] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.301326] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.301329] tcp_sendmsg max = size_goal==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301343] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.301346] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.301349] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.301352] tcp_sendmsg max = size_goal==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.354858] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.354862] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.354866] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.354869] tcp_sendmsg max = size_goal==11584
Sep 7 14:57:43 ubuntu kernel: [ 2908.354872] tcp_sendmsg copy==7240
Sep 7 14:57:43 ubuntu kernel: [ 2908.354878] tcp_sendmsg copy==3928
Sep 7 14:57:43 ubuntu kernel: [ 2908.354886] tcp_sendmsg copy==11584
Sep 7 14:57:43 ubuntu kernel: [ 2908.354889] tcp_sendmsg copy==11416
Sep 7 14:57:43 ubuntu kernel: [ 2908.354895] tcp_sendmsg copy==7320
Sep 7 14:57:43 ubuntu kernel: [ 2908.354901] tcp_sendmsg copy==3224
Sep 7 14:57:43 ubuntu kernel: [ 2908.354908] tcp_sendmsg copied==18824
Sep 7 14:57:43 ubuntu kernel: [ 2908.354960] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.354963] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.354966] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.354969] tcp_sendmsg max = size_goal==11584
Sep 7 14:57:43 ubuntu kernel: [ 2908.354983] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.354986] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.354989] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.354992] tcp_sendmsg max = size_goal==11584
Sep 7 14:57:43 ubuntu kernel: [ 2908.364413] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364417] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364420] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.364423] tcp_sendmsg max = size_goal==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364434] tcp_sendmsg copy==11584
Sep 7 14:57:43 ubuntu kernel: [ 2908.364438] tcp_sendmsg copy==10712
Sep 7 14:57:43 ubuntu kernel: [ 2908.364445] tcp_sendmsg copy==6616
Sep 7 14:57:43 ubuntu kernel: [ 2908.364450] tcp_sendmsg copy==2520
Sep 7 14:57:43 ubuntu kernel: [ 2908.364462] tcp_sendmsg copy==5792
Sep 7 14:57:43 ubuntu kernel: [ 2908.364467] tcp_sendmsg copy==4216
Sep 7 14:57:43 ubuntu kernel: [ 2908.364473] tcp_sendmsg copy==120
Sep 7 14:57:43 ubuntu kernel: [ 2908.364477] tcp_sendmsg copy==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364483] tcp_sendmsg copy==19192
Sep 7 14:57:43 ubuntu kernel: [ 2908.364489] tcp_sendmsg copy==15096
Sep 7 14:57:43 ubuntu kernel: [ 2908.364494] tcp_sendmsg copy==11000
Sep 7 14:57:43 ubuntu kernel: [ 2908.364499] tcp_sendmsg copy==6904
Sep 7 14:57:43 ubuntu kernel: [ 2908.364505] tcp_sendmsg copy==2808
Sep 7 14:57:43 ubuntu kernel: [ 2908.364515] tcp_sendmsg copied==40544
Sep 7 14:57:43 ubuntu kernel: [ 2908.364564] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364567] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364569] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.364571] tcp_sendmsg max = size_goal==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364630] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364632] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364635] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.364637] tcp_sendmsg max = size_goal==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364770] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364773] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364775] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.364778] tcp_sendmsg max = size_goal==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364800] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364802] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364804] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.364807] tcp_sendmsg max = size_goal==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364817] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364819] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364822] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.364824] tcp_sendmsg max = size_goal==23168
Sep 7 14:57:43 ubuntu kernel: [ 2908.364832] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.364834] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.364837] tcp_sendmsg iov->iov_len=6553
结果显示copied的和是和文件大小一样的,copy的数据我觉得有点无法解释,而且顺序也不完全按照我们平时程序的规则,copy之和应该和iov->iov_len长度一样。
打印顺序应该是 mss_now,msg->msg_iovlen,iov->iov_len,max = size_goal,copy,和copied,怎么顺序乱了
也许我没有理解到linux内核的运作,也许是struct kiocb *iocb的原因了....
各种不懂
忘高手解答!
谢谢大家了!!
|
iocb 应该是用来实现异步调用aio的,看上去Linux socket还没有支持aio,那个参数也就用不上了。
你那个 printk 我是看不懂啦。流程分支很多,你自己仔细检查一下吧。
你那个 printk 我是看不懂啦。流程分支很多,你自己仔细检查一下吧。