]> sjero.net Git - wget/blobdiff - src/gen_sslfunc.c
[svn] Remove the "rbuf" buffering layer. Provide peeking primitives instead.
[wget] / src / gen_sslfunc.c
index 4cbab6acc193a1f4fb12b1c8ba1a030eddf4c622..98e75a1dba6258d77b840a1b05b093aae79b3010 100644 (file)
@@ -300,6 +300,19 @@ ssl_poll (int fd, double timeout, int wait_for, void *ctx)
   return select_fd (fd, timeout, wait_for);
 }
 
+static int
+ssl_peek (int fd, char *buf, int bufsize, void *ctx)
+{
+  int ret;
+  SSL *ssl = (SSL *) ctx;
+  do
+    ret = SSL_peek (ssl, buf, bufsize);
+  while (ret == -1
+        && SSL_get_error (ssl, ret) == SSL_ERROR_SYSCALL
+        && errno == EINTR);
+  return ret;
+}
+
 static void
 ssl_close (int fd, void *ctx)
 {
@@ -335,9 +348,10 @@ ssl_connect (int fd)
 
   /* Register FD with Wget's transport layer, i.e. arrange that
      SSL-enabled functions are used for reading, writing, and polling.
-     That way the rest of Wget can use fd_read, fd_write, and friends
-     and not care what happens underneath.  */
-  fd_register_transport (fd, ssl_read, ssl_write, ssl_poll, ssl_close, ssl);
+     That way the rest of Wget can keep using xread, xwrite, and
+     friends and not care what happens underneath.  */
+  fd_register_transport (fd, ssl_read, ssl_write, ssl_poll, ssl_peek,
+                        ssl_close, ssl);
   DEBUGP (("Connected %d to SSL 0x%0lx\n", fd, (unsigned long) ssl));
   return ssl;