Glitch in luaw_channel.c

Somewhere around line 240 in channel.c

w_bytes = wip_write( c, buf + offset, buflen - offset);
if( w_bytes < buflen) break;

wip does not guarantee to send all (or no) requested data. It returns number of accepted bytes. This may solve the problem:

w_bytes = wip_write( c, buf + offset, buflen - offset);
if( w_bytes < buflen - offset) {
     offset += w_bytes;
     break;
}

I’ve also had problems with stric.lua when lua_setglobal. This link has solution that worked for me:
http://lua-users.org/lists/lua-l/2006-11/msg00116.html

The issue is even nastier than that, and can end up with write operations looping forever if you’re unlucky with the sizes of what you want to send and the size of TCP buffers.

I’ve written a (non-trivial) fix but haven’t committed it in the SVN yet, because I’m considering some source code organization refactoring. If I don’t update the svn within the next couple of days I’ll at least post a patch to channel_lua.lua and luaw_channel.c, as both files are affected by the fix.