* Underlying OS socket
*/
int fd;
+
+ /**
+ * Whether the socket returned EOF
+ */
+ bool eof;
};
METHOD(tls_application_t, process, status_t,
}
if (in == 0)
{ /* EOF */
+ this->eof = TRUE;
return TRUE;
}
switch (this->tls->process(this->tls, buf, in))
}
return cache;
}
+ if (this->eof)
+ {
+ return 0;
+ }
this->app.in.ptr = buf;
this->app.in.len = len;
this->app.in_done = 0;
if (exchange(this, FALSE, block))
{
+ if (!this->app.in_done && !this->eof)
+ {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
return this->app.in_done;
}
return -1;
{
char buf[PLAIN_BUF_SIZE], *pos;
ssize_t in, out;
- bool old, plain_eof = FALSE, crypto_eof = FALSE;
+ bool old, crypto_eof = FALSE;
struct pollfd pfd[] = {
{ .fd = this->fd, .events = POLLIN, },
{ .fd = rfd, .events = POLLIN, },
};
- while (!plain_eof && !crypto_eof)
+ while (!this->eof && !crypto_eof)
{
old = thread_cancelability(TRUE);
in = poll(pfd, countof(pfd), -1);
DBG1(DBG_TLS, "TLS select error: %s", strerror(errno));
return FALSE;
}
- while (!plain_eof && pfd[0].revents & (POLLIN | POLLHUP | POLLNVAL))
+ while (!this->eof && pfd[0].revents & (POLLIN | POLLHUP | POLLNVAL))
{
in = read_(this, buf, sizeof(buf), FALSE);
switch (in)
{
- case 0:
- plain_eof = TRUE;
- break;
case -1:
if (errno != EWOULDBLOCK)
{