Tags: meox/procket
Tags
mktmp: fix off by one Reported in: msantos#41 Thanks @tduccuong!
README: fix example When passing in an fd to gen_udp:open/2, the port must be set to 0. The examples were fixed way back in b5c16f. msantos#26 Thanks @philipcristiano!
Return number of bytes for partial writes The write functions (sendto/4, sendmsg/5, write/2, writev/2) have had a long standing bug where failure to write the complete buffer was silently ignored. Return a tuple containing the number of bytes written if the complete buffer could not be sent. Writes can be continued using something like: write_exact(FD, Buf) -> case procket:write(FD, Buf) of ok -> ok; {ok, N} - > {_:N/bytes, Rest/binary} = Buf, write_exact(FD, Rest); Error -> Error end. Successful writes of the entire buffer still return 'ok'.
Fix compilation on Solaris So errno is not thread local on Solaris and is set to 0 by default on error. Really Solaris? On Solaris, compile using POSIX mode which requires c99 mode which fixes errno, uses void* instead of c_addr_t* for iovec and various other errors. Add solaris constants for dgram, stream and raw which differ from other unix platforms. Make the send/recvmsg example work on Solaris. Platform dependent constants need to be fixed in the future. This could be done either by adding a lookup table to the NIF or writing a small program in C to generate an erlang module at compile time. Bump version to 0.6.1.
Use local file operations for slave nodes Opening a socket on a slave node using the procket setuid helper would fail, due to file operations being performed on the master: 1> slave:start('bar', 'n', "-env ERL_LIBS /path/to/erlang"). (n@foo)3> rpc:call('n@bar', procket, open, [58, [{protocol,tcp},{family,inet},{type,stream}]]). {badrpc,{'EXIT',{{badmatch,{error,enoent}}, [{procket,fdopen,1,[{file,"src/procket.erl"},{line,258}]}, {procket,open,2,[{file,"src/procket.erl"},{line,191}]}, {rpc,'-handle_call_call/6-fun-0-',5, [{file,"rpc.erl"},{line,205}]}]}}} The failure happens because procket creates a temporary directory to store the unix socket used to pass the fd from the helper into the NIF. Because slave nodes defer file operations to the master, the temp directory would be created on the master but would be attempted to be used on the slave. The work around was to manually specify the location of the unix socket using the 'pipe' option: rpc:call('n@bar', procket, open, [58, [{pipe, "/tmp/procket.s"}, {protocol,tcp},{family,inet},{type,stream}]]). Fix by bypassing the file server using the prim_file module directly. Slave nodes now should work without any other setup: (n@foo)3> rpc:call('n@bar', procket, open, [58, [{protocol,tcp},{family,inet},{type,stream}]]). {ok,14} (n@foo)4> rpc:call('n@bar', gen_tcp, listen, [0, [{fd,14}]]). {ok,#Port<7189.783>} Checking the remote mode, the socket is listening: bar$ sudo netstat -ptnl | grep 58 tcp 0 0 0.0.0.0:58 0.0.0.0:* LISTEN 23902/beam.smp Thanks to xingang shi for reporting and debugging this problem!