10static int leftstatus = 0;
11static char leftbuf[16 * 1024];
15static int rightstatus = 0;
16static char rightbuf[16 * 1024];
34 rfd = SSL_get_fd(ssl);
36 close(fdleft); close(fdright);
39 wfd = SSL_get_fd(ssl);
41 close(fdleft); close(fdright);
48 if (leftstatus == -1 && rightstatus == -1)
52 if (leftstatus == 0 && rightstatus != 1) {
55 io0->events = IOPAUSE_READ;
59 if (leftstatus == 1) {
62 ioleft->events = IOPAUSE_WRITE;
66 if (rightstatus == 0) {
68 ioright->fd = fdright;
69 ioright->events = IOPAUSE_READ;
73 if (rightstatus == 1) {
76 io1->events = IOPAUSE_WRITE;
79 if (taia_now(&now) == -1) {
85 taia_add(&deadline,&now,&deadline);
86 iopause(x,xlen,&deadline,&now);
88 for (r = 0; r < xlen; ++r)
89 if (x[r].revents)
goto EVENTS;
102 if (io0 && io0->revents) {
103 r = SSL_read(ssl,leftbuf,
sizeof(leftbuf));
111 case SSL_ERROR_WANT_READ:
112 case SSL_ERROR_WANT_WRITE:
113 case SSL_ERROR_WANT_X509_LOOKUP:
115 case SSL_ERROR_ZERO_RETURN:
116 if (rightstatus == -1)
goto DONE;
120 case SSL_ERROR_SYSCALL:
121 if (errno == EAGAIN || errno == EINTR)
break;
126 if (errno == ECONNRESET && rightstatus == -1)
goto DONE;
140 if (rightstatus == 1)
break;
146 if (ioleft && ioleft->revents) {
147 r = buffer_unixwrite(fdleft,leftbuf + leftpos,leftlen - leftpos);
149 if (errno == EINTR || errno == EWOULDBLOCK) {
152 else if (errno == EPIPE || errno == EAGAIN) {
153 if (rightstatus == -1)
goto DONE;
163 if (leftpos == leftlen) {
166 if (r >
sizeof(leftbuf)) r =
sizeof(leftbuf);
167 r = SSL_read(ssl,leftbuf,r);
175 case SSL_ERROR_WANT_READ:
176 case SSL_ERROR_WANT_WRITE:
177 case SSL_ERROR_WANT_X509_LOOKUP:
179 case SSL_ERROR_ZERO_RETURN:
180 if (rightstatus == -1)
goto DONE;
193 if (ioright && ioright->revents) {
194 r = buffer_unixread(fdright,rightbuf,
sizeof(rightbuf));
196 if (errno == EINTR || errno == EWOULDBLOCK) {
207 if (leftstatus == -1)
goto DONE;
216 if (io1 && io1->revents) {
217 r = SSL_write(ssl,rightbuf + rightpos,rightlen - rightpos);
222 if (rightpos == rightlen) rightstatus = 0;
224 case SSL_ERROR_WANT_READ:
225 case SSL_ERROR_WANT_WRITE:
226 case SSL_ERROR_WANT_X509_LOOKUP:
228 case SSL_ERROR_ZERO_RETURN:
231 if (leftstatus == -1)
goto DONE;
234 case SSL_ERROR_SYSCALL:
235 if (errno == EAGAIN || errno == EINTR)
break;
236 if (errno == EPIPE) {
239 if (leftstatus == -1)
goto DONE;
253 if (leftstatus != -1) close(fdleft);
254 if (rightstatus != -1) close(fdright);
266 if (leftstatus != -1) close(fdleft);
267 if (rightstatus != -1) close(fdright);
int ssl_io(SSL *ssl, int fdleft, int fdright, unsigned int timeout)
Header file to be used with sqmail; previously called ssl.h. (name clash)
#define ssl_shutdown_sent(ssl)
#define ssl_shutdown(ssl)
#define ssl_shutdown_pending(ssl)