please use max 80 chars/line, see README.Coding. And there is more obvious wrong at two places:
"if(errno != EINTR || errno != EAGAIN || errno != EWOULDBLOCK)" is always true. Can you fix those things and try to explain your code changes so that reviewing is better possible? Finally, please send the patch to the samba-technical mailing list because github is not working well with the samba community for communication and discussion.
Thank you - BjÃ¶rn