struct timeval tv;
int retval;
+
+#ifdef HAVE_OPENSSL
+ if (is_https) {
+ return(client_read_ssl(buf, bytes, timeout));
+ }
+#endif
+
len = 0;
while (len < bytes) {
FD_ZERO(&rfds);
if (FD_ISSET(sock, &rfds) == 0) {
return (0);
}
+
rlen = read(sock, &buf[len], bytes - len);
+
if (rlen < 1) {
lprintf(2, "client_read() failed: %s\n",
strerror(errno));
return (1);
}
+
+ssize_t client_write(const void *buf, size_t count) {
+#ifdef HAVE_OPENSSL
+ if (is_https) {
+ client_write_ssl((char *)buf, count);
+ return(count);
+ }
+#endif
+ return(write(WC->http_sock, buf, count));
+}
+
+
/*
* Read data from the client socket with default timeout.
* (This is implemented in terms of client_read_to() and could be
lprintf(1, "Can't create TSD key: %s\n", strerror(errno));
}
+ /*
+ * Set up a place to put thread-specific SSL data.
+ * We don't stick this in the wcsession struct because SSL starts
+ * up before the session is bound, and it gets torn down between
+ * transactions.
+ */
+#ifdef HAVE_OPENSSL
+ if (pthread_key_create(&ThreadSSL, NULL) != 0) {
+ lprintf(1, "Can't create TSD key: %s\n", strerror(errno));
+ }
+#endif
+
/*
* Bind the server to our favorite port.
* There is no need to check for errors, because ig_tcp_server()
/* If we are an HTTPS server, go crypto now. */
#ifdef HAVE_OPENSSL
if (is_https) {
- if (starttls() != 0) {
+ if (starttls(ssock) != 0) {
fail_this_transaction = 1;
}
}