Replaced write system function with wrapper gw_write. It allows for generating failures by using telnet commands, fail backendfd, fail clientfd, which are available in debug build only.

This commit is contained in:
vraatikka
2013-09-17 00:07:56 +03:00
parent db7004e6ae
commit 8bf73ea154
11 changed files with 197 additions and 42 deletions

View File

@ -73,6 +73,8 @@ int setnonblocking(int fd) {
return 0;
}
char *gw_strend(register const char *s) {
while (*s++);
return (char*) (s-1);
@ -188,3 +190,33 @@ void gw_sha1_2_str(const uint8_t *in, int in_len, const uint8_t *in2, int in2_le
memcpy(out, hash, SHA_DIGEST_LENGTH);
}
/**
* @node Gets errno corresponding to latest socket error
*
* Parameters:
* @param fd - in, use
* socket to examine
*
* @return errno
*
*
* @details (write detailed description here)
*
*/
int gw_getsockerrno(
int fd)
{
int eno = 0;
socklen_t elen = sizeof(eno);
if (fd <= 0) {
goto return_eno;
}
getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&eno, &elen);
return_eno:
return eno;
}