mirror of
https://repo.or.cz/socat.git
synced 2025-07-14 07:23:23 +00:00
handle partial write()'s without data loss
This commit is contained in:
parent
3881c794a7
commit
6a8f6c0734
9 changed files with 114 additions and 47 deletions
26
xiowrite.c
26
xiowrite.c
|
@ -1,5 +1,5 @@
|
|||
/* source: xiowrite.c */
|
||||
/* Copyright Gerhard Rieger 2001-2008 */
|
||||
/* Copyright Gerhard Rieger 2001-2011 */
|
||||
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||
|
||||
/* this is the source of the extended write function */
|
||||
|
@ -49,9 +49,7 @@ ssize_t xiowrite(xiofile_t *file, const void *buff, size_t bytes) {
|
|||
switch (pipe->dtype & XIODATA_WRITEMASK) {
|
||||
|
||||
case XIOWRITE_STREAM:
|
||||
do {
|
||||
writt = Write(pipe->fd, buff, bytes);
|
||||
} while (writt < 0 && errno == EINTR);
|
||||
writt = writefull(pipe->fd, buff, bytes);
|
||||
if (writt < 0) {
|
||||
_errno = errno;
|
||||
switch (_errno) {
|
||||
|
@ -70,10 +68,6 @@ ssize_t xiowrite(xiofile_t *file, const void *buff, size_t bytes) {
|
|||
errno = _errno;
|
||||
return -1;
|
||||
}
|
||||
if ((size_t)writt < bytes) {
|
||||
Warn2("write() only wrote "F_Zu" of "F_Zu" bytes",
|
||||
writt, bytes);
|
||||
}
|
||||
break;
|
||||
|
||||
#if _WITH_SOCKET
|
||||
|
@ -120,9 +114,7 @@ ssize_t xiowrite(xiofile_t *file, const void *buff, size_t bytes) {
|
|||
#endif /* _WITH_SOCKET */
|
||||
|
||||
case XIOWRITE_PIPE:
|
||||
do {
|
||||
writt = Write(pipe->para.bipipe.fdout, buff, bytes);
|
||||
} while (writt < 0 && errno == EINTR);
|
||||
writt = Write(pipe->para.bipipe.fdout, buff, bytes);
|
||||
_errno = errno;
|
||||
if (writt < 0) {
|
||||
Error4("write(%d, %p, "F_Zu"): %s",
|
||||
|
@ -130,16 +122,10 @@ ssize_t xiowrite(xiofile_t *file, const void *buff, size_t bytes) {
|
|||
errno = _errno;
|
||||
return -1;
|
||||
}
|
||||
if ((size_t)writt < bytes) {
|
||||
Warn2("write() only wrote "F_Zu" of "F_Zu" bytes",
|
||||
writt, bytes);
|
||||
}
|
||||
break;
|
||||
|
||||
case XIOWRITE_2PIPE:
|
||||
do {
|
||||
writt = Write(pipe->para.exec.fdout, buff, bytes);
|
||||
} while (writt < 0 && errno == EINTR);
|
||||
writt = Write(pipe->para.exec.fdout, buff, bytes);
|
||||
_errno = errno;
|
||||
if (writt < 0) {
|
||||
Error4("write(%d, %p, "F_Zu"): %s",
|
||||
|
@ -147,10 +133,6 @@ ssize_t xiowrite(xiofile_t *file, const void *buff, size_t bytes) {
|
|||
errno = _errno;
|
||||
return -1;
|
||||
}
|
||||
if ((size_t)writt < bytes) {
|
||||
Warn2("write() only processed "F_Zu" of "F_Zu" bytes",
|
||||
writt, bytes);
|
||||
}
|
||||
break;
|
||||
|
||||
#if WITH_OPENSSL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue