11/20/2007 12:27 AM
post2777
|
Okay, sorry for the delay. This has been a while so I have to dig a little bit to find out what is happening.
First of all, the attached program showes a simple sending fd through unix domain socket.
The good news is, it works. The "not so good news" is, while doing this, I also found a bug. If read_fd() pass in a
smaller control message, it may crash io-pkt. PR53331 is filed for this.
To answer your question for recvmsg(). The "dupmsg" is pointing to a buffer that received from the stack (either in
cmptr, or in extra tmpbuf). So the detail of the dupmsg is all filled by the stack before it passed to receiver side.
So the idea is, when sendmsg(), the stack queued all the information, when another process comes for recvmsg(), a "
dupmsg()" is returned in control message. The recvmsg() function will then send the _IO_DUP to the real resmgr, to dup
the fd, and return it.
The only caveat (suppose to be documented somewhere, but I can't find it) is, the sender should not close the fd, before
the receiver got it (dupped it).
Does these all make sense now?
|
Attachment: |
fds.c
4.28 KB
|
|
|