On 04/14/13 16:02, Bill Trost wrote: > Below is a quick hack to eliminate the socket pair used to > pushbits in the case that file descriptor 0 really is a > socket.
Interesting -- do you have a use case where this optimization is likely to matter? It seems to me that this is only relevant if you are pushing a very large number of bits through; and even then, I'd expect the cryptographic work to overwhelm the data-copying and keep the speedup from this to a minimum. > I'm not convinced that this is the "best" way to > detect the socketness of fd 0, but at least I was able to > use the getsockopt result in a vaguely constructive way. I believe the standards-compliant way to detect if a descriptor is a socket is to fstat it and then use S_ISSOCK on the results. > [...] > /* Set up a connection. */ > - if (proto_conn_create(s[1], sas_t, 0, opt_f, K, opt_o, > + if (proto_conn_create(socket0 ? 0 : s[1], sas_t, 0, opt_f, K, opt_o, This is a bug since proto_conn_create writes incoming data back to the same socket as it's reading from -- you'll need to change it to take separate "in" and "out" sockets and then pass 0 and 1 (if they are sockets). In some cases spipe will be called with descriptors 0 and 1 being the same socket, but not always... -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid
