mirror of
https://repo.or.cz/socat.git
synced 2025-06-08 19:06:50 +00:00
Correct undesired logging of complete write()
This commit is contained in:
parent
29f9e4db92
commit
2dd1452f25
2 changed files with 13 additions and 5 deletions
2
CHANGES
2
CHANGES
|
@ -18,6 +18,8 @@ Corrections:
|
|||
addresses the explicit socksport (2nd address parameter) was ignored.
|
||||
Thanks to Jakub Fišer for reporting this bug.
|
||||
|
||||
Do not log simple successful write with NOTICE level.
|
||||
|
||||
Building:
|
||||
Disabling certain features during configure could break build process.
|
||||
|
||||
|
|
16
sysutils.c
16
sysutils.c
|
@ -27,6 +27,11 @@ const int one = 1;
|
|||
Returns <0 on unhandled error, errno valid
|
||||
Will only return <0 or bytes
|
||||
*/
|
||||
/* Assuming your pipe size is 65536 - find out with:
|
||||
filan -i 1 |grep F_GETPIPE_SZ |sed 's|.*\(F_GETPIPE_SZ=[1-9][0-9]*\).*|\1|'
|
||||
Then we can test partial write with something like:
|
||||
socat -d4 -lu -b 262144 -u /dev/zero,readbytes=262144 -,o-nonblock |{ sleep 3; wc -c; }
|
||||
*/
|
||||
ssize_t writefull(int fd, const void *buff, size_t bytes) {
|
||||
size_t writt = 0;
|
||||
ssize_t chk;
|
||||
|
@ -40,16 +45,17 @@ ssize_t writefull(int fd, const void *buff, size_t bytes) {
|
|||
case EWOULDBLOCK:
|
||||
#endif
|
||||
Warn4("write(%d, %p, "F_Zu"): %s", fd, (const char *)buff+writt, bytes-writt, strerror(errno));
|
||||
Sleep(1); continue;
|
||||
Sleep(1);
|
||||
continue;
|
||||
default: return -1;
|
||||
}
|
||||
} else if (writt+chk < bytes) {
|
||||
Warn4("write(%d, %p, "F_Zu"): only wrote "F_Zu" bytes, trying to continue (rev.direction is blocked)",
|
||||
Warn4("write(%d, %p, "F_Zu"): only wrote "F_Zu" bytes, trying to continue (meanwhile, other direction is blocked)",
|
||||
fd, (const char *)buff+writt, bytes-writt, chk);
|
||||
writt += chk;
|
||||
} else {
|
||||
writt = bytes;
|
||||
break;
|
||||
} else if (writt == 0) {
|
||||
/* First attempt, write complete - no extra message */
|
||||
return chk;
|
||||
}
|
||||
}
|
||||
Notice3("write(%d, %p, "F_Zu") completed", fd, (const char *)buff, bytes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue