Re: Asynchronous sock_sendmbuf
Re: Asynchronous sock_sendmbuf
- Subject: Re: Asynchronous sock_sendmbuf
- From: Rick Macklem <email@hidden>
- Date: Tue, 20 May 2008 12:06:55 -0400 (EDT)
On Tue, 20 May 2008, Josh Graessley wrote:
When using sockets in the kernel or in user space, there is no way to know,
without polling, when the data has been sent. The send/sendmbuf calls enqueue
As Josh notes, you can only tell when the data has been sent via polling.
There is also the issue of what you mean by "sent". Do you only care that
the data has been sent on the wire, or that it has been successfully
received at the other end? (For my nfsd for TCP sockets, I wanted to know
the latter, so that I could decide when cached replies could be discarded.
I use the following routine on FreeBSD7 (not XNU code!) to poll to see if
the receiver has acknowledged receipt of the data. That still doesn't
mean that the App has read it, just that it has made it into the socket's
receive queue at the other end.
I do not recommend doing this, but if you have to, here's an example of
how it can be done on FreeBSD7. You'll need to dig into xnu kernel
sources, to see what locking is required for XNU. (Also note that this is
TCP specific and violates network layering, etc.)
rick
/*
* Check the tcp socket sequence number has been acknowledged.
* (This should really be a socket operation. Maybe someday...)
*/
int
nfsrv_checksockseqnum(struct socket *so, u_int32_t tcpseq)
{
struct inpcb *inp;
struct tcpcb *tp;
int ret = 0;
INP_INFO_RLOCK(&tcbinfo);
inp = sotoinpcb(so);
if (inp == NULL) {
INP_INFO_RUNLOCK(&tcbinfo);
return (ret);
}
INP_LOCK(inp);
INP_INFO_RUNLOCK(&tcbinfo);
tp = intotcpcb(inp);
if (tp) {
if (tp->t_state == TCPS_ESTABLISHED &&
SEQ_GEQ(tp->snd_una, tcpseq))
ret = 1;
}
INP_UNLOCK(inp);
return (ret);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden