mirror of
https://github.com/proxytunnel/proxytunnel.git
synced 2026-01-23 02:34:59 +00:00
Apply debian patch 003_socket_write_loop.patch
This commit is contained in:
parent
0c530acaf4
commit
cb336cab71
1 changed files with 23 additions and 9 deletions
32
ptstream.c
32
ptstream.c
|
|
@ -98,21 +98,35 @@ int stream_read(PTSTREAM *pts, void *buf, size_t len) {
|
|||
int stream_write(PTSTREAM *pts, void *buf, size_t len) {
|
||||
/* Write the specified number of bytes from the buffer */
|
||||
int bytes_written;
|
||||
int total_bytes_written = 0;
|
||||
|
||||
if (!pts->ssl) {
|
||||
/* For a non-SSL stream... */
|
||||
bytes_written = write(pts->outgoing_fd, buf, len);
|
||||
} else {
|
||||
while (total_bytes_written < len) {
|
||||
if (!pts->ssl) {
|
||||
/* For a non-SSL stream... */
|
||||
bytes_written = write(pts->outgoing_fd,
|
||||
buf + total_bytes_written,
|
||||
len - total_bytes_written);
|
||||
} else {
|
||||
#ifdef USE_SSL
|
||||
/* For an SSL stream... */
|
||||
bytes_written = SSL_write(pts->ssl, buf, len);
|
||||
/* For an SSL stream... */
|
||||
bytes_written = SSL_write(pts->ssl,
|
||||
buf + total_bytes_written,
|
||||
len - total_bytes_written);
|
||||
#else
|
||||
/* No SSL support, so must use a non-SSL stream */
|
||||
bytes_written = write(pts->outgoing_fd, buf, len);
|
||||
/* No SSL support, so must use a non-SSL stream */
|
||||
bytes_written = write(pts->outgoing_fd,
|
||||
buf + total_bytes_written,
|
||||
len - total_bytes_written);
|
||||
#endif /* USE_SSL */
|
||||
}
|
||||
|
||||
if (bytes_written <= 0) {
|
||||
break;
|
||||
}
|
||||
total_bytes_written += bytes_written;
|
||||
}
|
||||
|
||||
return bytes_written;
|
||||
return total_bytes_written;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue