Handle EINTR more in handshaker.cc.

Some of our calls handled it and others didn't.

Change-Id: I09f15d3db679954599bcf987d86357b6e12e9b9b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/46532
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
grpc-202302
David Benjamin 4 years ago committed by CQ bot account: commit-bot@chromium.org
parent 084064becc
commit 6b9c012b7b
  1. 41
      ssl/test/handshaker.cc

@ -29,6 +29,22 @@ using namespace bssl;
namespace { namespace {
ssize_t read_eintr(int fd, void *out, size_t len) {
ssize_t ret;
do {
ret = read(fd, out, len);
} while (ret < 0 && errno == EINTR);
return ret;
}
ssize_t write_eintr(int fd, const void *in, size_t len) {
ssize_t ret;
do {
ret = write(fd, in, len);
} while (ret < 0 && errno == EINTR);
return ret;
}
bool HandbackReady(SSL *ssl, int ret) { bool HandbackReady(SSL *ssl, int ret) {
return ret < 0 && SSL_get_error(ssl, ret) == SSL_ERROR_HANDBACK; return ret < 0 && SSL_get_error(ssl, ret) == SSL_ERROR_HANDBACK;
} }
@ -71,8 +87,8 @@ bool Handshaker(const TestConfig *config, int rfd, int wfd,
// Synchronize with the proxy, i.e. don't let the handshake continue until // Synchronize with the proxy, i.e. don't let the handshake continue until
// the proxy has sent more data. // the proxy has sent more data.
char msg = kControlMsgWantRead; char msg = kControlMsgWantRead;
if (write(control, &msg, 1) != 1 || if (write_eintr(control, &msg, 1) != 1 ||
read(control, &msg, 1) != 1 || read_eintr(control, &msg, 1) != 1 ||
msg != kControlMsgWriteCompleted) { msg != kControlMsgWriteCompleted) {
fprintf(stderr, "read via proxy failed\n"); fprintf(stderr, "read via proxy failed\n");
return false; return false;
@ -100,30 +116,15 @@ bool Handshaker(const TestConfig *config, int rfd, int wfd,
} }
char msg = kControlMsgHandback; char msg = kControlMsgHandback;
if (write(control, &msg, 1) == -1 || if (write_eintr(control, &msg, 1) == -1 ||
write(control, CBB_data(output.get()), CBB_len(output.get())) == -1) { write_eintr(control, CBB_data(output.get()), CBB_len(output.get())) ==
-1) {
perror("write"); perror("write");
return false; return false;
} }
return true; return true;
} }
ssize_t read_eintr(int fd, void *out, size_t len) {
ssize_t ret;
do {
ret = read(fd, out, len);
} while (ret < 0 && errno == EINTR);
return ret;
}
ssize_t write_eintr(int fd, const void *in, size_t len) {
ssize_t ret;
do {
ret = write(fd, in, len);
} while (ret < 0 && errno == EINTR);
return ret;
}
int SignalError() { int SignalError() {
const char msg = kControlMsgError; const char msg = kControlMsgError;
if (write_eintr(kFdControl, &msg, 1) != 1) { if (write_eintr(kFdControl, &msg, 1) != 1) {

Loading…
Cancel
Save