]> code.delx.au - gnu-emacs/commitdiff
Fix merge conflicts in network-stream-tests.el
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 22 Feb 2016 04:06:33 +0000 (15:06 +1100)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 22 Feb 2016 04:06:33 +0000 (15:06 +1100)
1  2 
configure.ac
lisp/net/gnutls.el
lisp/net/network-stream.el
src/Makefile.in
src/eval.c
src/lisp.h
test/lisp/net/network-stream-tests.el

diff --combined configure.ac
index 683447368fbbe7e8bfb77b14fe0d60c02c38ccc2,1d2b175eae4aaefd650a4c08acc7069d04d04c95..1cbd297f5e7f0e7687704ff816e9beb181cccd37
@@@ -33,7 -33,7 +33,7 @@@ emacs_config_options
  optsep=
  dnl This is the documented way to record the args passed to configure,
  dnl rather than $ac_configure_args.
 -for opt in ${1+"$@"} CFLAGS CPPFLAGS LDFLAGS; do
 +for opt in "$@" CFLAGS CPPFLAGS LDFLAGS; do
    case $opt in
      -n | --no-create | --no-recursion)
        continue ;;
@@@ -330,7 -330,7 +330,7 @@@ OPTION_DEFAULT_ON([tiff],[don't compil
  OPTION_DEFAULT_ON([gif],[don't compile with GIF image support])
  OPTION_DEFAULT_ON([png],[don't compile with PNG image support])
  OPTION_DEFAULT_ON([rsvg],[don't compile with SVG image support])
 -OPTION_DEFAULT_OFF([cairo],[compile with Cairo drawing])
 +OPTION_DEFAULT_OFF([cairo],[compile with Cairo drawing (experimental)])
  OPTION_DEFAULT_ON([xml2],[don't compile with XML parsing support])
  OPTION_DEFAULT_ON([imagemagick],[don't compile with ImageMagick image support])
  
@@@ -374,9 -374,6 +374,9 @@@ otherwise for the first of 'inotify', '
   ],
   [with_file_notification=$with_features])
  
 +OPTION_DEFAULT_OFF([xwidgets],
 +  [enable use of some gtk widgets in Emacs buffers (requires gtk3)])
 +
  ## For the times when you want to build Emacs but don't have
  ## a suitable makeinfo, and can live without the manuals.
  dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html
  
  dnl checks for header files
  AC_CHECK_HEADERS_ONCE(
 +  malloc.h
    sys/systeminfo.h
    sys/sysinfo.h
    coff.h pty.h
@@@ -2122,13 -2118,7 +2122,13 @@@ case "$opsys" i
    cygwin) hybrid_malloc=yes;;
  esac
  
 +if test "${system_malloc}" != yes && test "${doug_lea_malloc}" != yes \
 +   && test "${UNEXEC_OBJ}" = unexelf.o; then
 +  hybrid_malloc=yes
 +fi
 +
  GMALLOC_OBJ=
 +HYBRID_MALLOC=
  if test "${system_malloc}" = "yes"; then
    AC_DEFINE([SYSTEM_MALLOC], 1,
      [Define to 1 to use the system memory allocator, even if it is not
  elif test "$hybrid_malloc" = yes; then
    AC_DEFINE(HYBRID_MALLOC, 1,
      [Define to use gmalloc before dumping and the system malloc after.])
 +  HYBRID_MALLOC=1
    GNU_MALLOC=
    GNU_MALLOC_reason="only before dumping"
    GMALLOC_OBJ=gmalloc.o
         of the main data segment.])
    fi
  fi
 +AC_SUBST([HYBRID_MALLOC])
 +AM_CONDITIONAL([HYBRID_MALLOC_LIB], [test -n "$HYBRID_MALLOC"])
  AC_SUBST(GMALLOC_OBJ)
  AC_SUBST(VMLIMIT_OBJ)
  
 -if test "$doug_lea_malloc" = "yes" ; then
 +if test "$doug_lea_malloc" = "yes" && test "$hybrid_malloc" != yes; then
    if test "$GNU_MALLOC" = yes ; then
      GNU_MALLOC_reason="
        (Using Doug Lea's new malloc from the GNU C Library.)"
  
  use_mmap_for_buffers=no
  case "$opsys" in
 -  cygwin|mingw32|freebsd|irix6-5) use_mmap_for_buffers=yes ;;
 +  cygwin|mingw32|irix6-5) use_mmap_for_buffers=yes ;;
  esac
  
  AC_FUNC_MMAP
@@@ -2414,13 -2401,20 +2414,20 @@@ if test "${HAVE_X11}" = "yes" || test "
        OLD_LIBS=$LIBS
        CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS"
        LIBS="$IMAGEMAGICK_LIBS $LIBS"
 -      AC_CHECK_FUNCS(MagickExportImagePixels MagickMergeImageLayers)
 +      AC_CHECK_FUNCS(MagickExportImagePixels MagickMergeImageLayers MagickAutoOrientImage)
        CFLAGS=$OLD_CFLAGS
        LIBS=$OLD_LIBS
      fi
    fi
  fi
  
+ AC_CHECK_LIB(anl, getaddrinfo_a, HAVE_GETADDRINFO_A=yes)
+ if test "${HAVE_GETADDRINFO_A}" = "yes"; then
+   AC_DEFINE(HAVE_GETADDRINFO_A, 1,
+ [Define to 1 if you have getaddrinfo_a for asynchronous DNS resolution.])
+   GETADDRINFO_A_LIBS="-lanl"
+   AC_SUBST(GETADDRINFO_A_LIBS)
+ fi
  
  HAVE_GTK=no
  GTK_OBJ=
@@@ -2576,26 -2570,6 +2583,26 @@@ if test "${HAVE_GTK}" = "yes"; the
   term_header=gtkutil.h
  fi
  
 +
 +dnl Enable xwidgets if GTK3 and WebKitGTK+ are available.
 +HAVE_XWIDGETS=no
 +XWIDGETS_OBJ=
 +if test "$with_xwidgets" != "no"; then
 +  test "$USE_GTK_TOOLKIT" = "GTK3" && test "$window_system" != "none" ||
 +    AC_MSG_ERROR([xwidgets requested but gtk3 not used.])
 +
 +  WEBKIT_REQUIRED=1.4.0
 +  WEBKIT_MODULES="webkitgtk-3.0 >= $WEBKIT_REQUIRED"
 +  EMACS_CHECK_MODULES([WEBKIT], [$WEBKIT_MODULES])
 +  HAVE_XWIDGETS=$HAVE_WEBKIT
 +  test $HAVE_XWIDGETS = yes ||
 +    AC_MSG_ERROR([xwidgets requested but WebKitGTK+ not found.])
 +
 +  XWIDGETS_OBJ=xwidget.o
 +  AC_DEFINE([HAVE_XWIDGETS], 1, [Define to 1 if you have xwidgets support.])
 +fi
 +AC_SUBST(XWIDGETS_OBJ)
 +
  CFLAGS=$OLD_CFLAGS
  LIBS=$OLD_LIBS
  
@@@ -3151,13 -3125,13 +3158,13 @@@ AC_SUBST(LIBOTF_LIBS
  AC_SUBST(M17N_FLT_CFLAGS)
  AC_SUBST(M17N_FLT_LIBS)
  
 -USE_CAIRO=no
 +HAVE_CAIRO=no
  if test "${HAVE_X11}" = "yes"; then
    if test "${with_cairo}" != "no"; then
      CAIRO_REQUIRED=1.12.0
      CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
 -    PKG_CHECK_MODULES(CAIRO, $CAIRO_MODULE, USE_CAIRO=yes, :)
 -    if test $USE_CAIRO = yes; then
 +    EMACS_CHECK_MODULES(CAIRO, $CAIRO_MODULE)
 +    if test $HAVE_CAIRO = yes; then
        AC_DEFINE(USE_CAIRO, 1, [Define to 1 if using cairo.])
      else
        AC_MSG_ERROR([cairo requested but not found.])
@@@ -3370,7 -3344,7 +3377,7 @@@ if test "${with_modules}" != "no"; the
    else
      SAVE_LIBS=$LIBS
      LIBS="$LIBS $LIBMODULES"
 -    AC_CHECK_FUNCS([dlfunc])
 +    AC_CHECK_FUNCS([dladdr dlfunc])
      LIBS=$SAVE_LIBS
    fi
  fi
@@@ -3383,6 -3357,7 +3390,6 @@@ if test "${HAVE_MODULES}" = yes; the
  fi
  AC_SUBST(MODULES_OBJ)
  AC_SUBST(LIBMODULES)
 -AC_CHECK_FUNCS(dladdr)
  
  ### Use -lpng if available, unless '--with-png=no'.
  HAVE_PNG=no
@@@ -3815,9 -3790,14 +3822,9 @@@ getpwent endpwent getgrent endgrent 
  cfmakeraw cfsetspeed copysign __executable_start log2)
  LIBS=$OLD_LIBS
  
 -dnl No need to check for aligned_alloc and posix_memalign if using
 -dnl gmalloc.o, as it supplies them, unless we're using hybrid_malloc.
 -dnl Don't use these functions on Darwin as they are incompatible with
 -dnl unexmacosx.c.
 -if (test -z "$GMALLOC_OBJ" || test "$hybrid_malloc" = yes) \
 -  && test "$opsys" != darwin; then
 -  AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break])
 -fi
 +dnl No need to check for posix_memalign if aligned_alloc works.
 +AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break])
 +AC_CHECK_DECLS([aligned_alloc], [], [], [[#include <stdlib.h>]])
  
  dnl Cannot use AC_CHECK_FUNCS
  AC_CACHE_CHECK([for __builtin_unwind_init],
@@@ -4924,7 -4904,7 +4931,7 @@@ if test "${HAVE_X_WINDOWS}" = "yes" ; t
    XMENU_OBJ=xmenu.o
    XOBJ="xterm.o xfns.o xselect.o xrdb.o xsmfns.o xsettings.o"
    FONT_OBJ=xfont.o
 -  if test "$USE_CAIRO" = "yes"; then
 +  if test "$HAVE_CAIRO" = "yes"; then
      FONT_OBJ="ftfont.o ftcrfont.o"
    elif test "$HAVE_XFT" = "yes"; then
      FONT_OBJ="$FONT_OBJ ftfont.o xftfont.o ftxfont.o"
@@@ -4975,9 -4955,6 +4982,9 @@@ case "$USE_X_TOOLKIT" i
    LUCID) TOOLKIT_LIBW="$LUCID_LIBW" ;;
    none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS" ;;
  esac
 +if test "$HAVE_XWIDGETS" = "yes"; then
 +  TOOLKIT_LIBW="$TOOLKIT_LIBW -lXcomposite"
 +fi
  AC_SUBST(TOOLKIT_LIBW)
  
  if test "${opsys}" != "mingw32"; then
  AC_SUBST(RALLOC_OBJ)
  
  if test "$opsys" = "cygwin"; then
 -  CYGWIN_OBJ="sheap.o cygw32.o"
 +  CYGWIN_OBJ="cygw32.o"
    ## Cygwin differs because of its unexec().
    PRE_ALLOC_OBJ=
    POST_ALLOC_OBJ=lastfile.o
@@@ -5267,12 -5244,11 +5274,12 @@@ optsep
  emacs_config_features=
  for opt in XAW3D XPM JPEG TIFF GIF PNG RSVG CAIRO IMAGEMAGICK SOUND GPM DBUS \
    GCONF GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT \
 -  LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS X_TOOLKIT X11 NS MODULES; do
 +  LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS X_TOOLKIT X11 NS MODULES \
 +  XWIDGETS; do
  
      case $opt in
        NOTIFY|ACL) eval val=\${${opt}_SUMMARY} ;;
 -      CAIRO|TOOLKIT_SCROLL_BARS|X_TOOLKIT) eval val=\${USE_$opt} ;;
 +      TOOLKIT_SCROLL_BARS|X_TOOLKIT) eval val=\${USE_$opt} ;;
        *) eval val=\${HAVE_$opt} ;;
      esac
      case x$val in
@@@ -5299,7 -5275,7 +5306,7 @@@ AS_ECHO(["  Does Emacs use -lXaw3d
    Does Emacs use a gif library?                           ${HAVE_GIF} $LIBGIF
    Does Emacs use a png library?                           ${HAVE_PNG} $LIBPNG
    Does Emacs use -lrsvg-2?                                ${HAVE_RSVG}
 -  Does Emacs use cairo?                                   ${USE_CAIRO}
 +  Does Emacs use cairo?                                   ${HAVE_CAIRO}
    Does Emacs use imagemagick?                             ${HAVE_IMAGEMAGICK}
    Does Emacs support sound?                               ${HAVE_SOUND}
    Does Emacs use -lgpm?                                   ${HAVE_GPM}
    Does Emacs directly use zlib?                           ${HAVE_ZLIB}
    Does Emacs have dynamic modules support?                ${HAVE_MODULES}
    Does Emacs use toolkit scroll bars?                     ${USE_TOOLKIT_SCROLL_BARS}
 +  Does Emacs support Xwidgets (requires gtk3)?            ${HAVE_XWIDGETS}
  "])
  
  if test -n "${EMACSDATA}"; then
diff --combined lisp/net/gnutls.el
index 904cb313874eed1da5c9bdd81a7a7d43ff457b2e,8db3450308dd4b979f158b02a01a2584465b4c8d..0baf2e34ecd34db41a837d2382bc53b76e8b7b29
@@@ -26,7 -26,7 +26,7 @@@
  
  ;; This package provides language bindings for the GnuTLS library
  ;; using the corresponding core functions in gnutls.c.  It should NOT
 -;; be used directly, only through open-protocol-stream.
 +;; be used directly, only through open-network-stream.
  
  ;; Simple test:
  ;;
@@@ -95,7 -95,7 +95,7 @@@ A value of nil says to use the default 
                   (integer :tag "Number of bits" 512))
    :group 'gnutls)
  
- (defun open-gnutls-stream (name buffer host service)
+ (defun open-gnutls-stream (name buffer host service &optional nowait)
    "Open a SSL/TLS connection for a service to a host.
  Returns a subprocess-object to represent the connection.
  Input and output work as for subprocesses; `delete-process' closes it.
@@@ -109,6 -109,9 +109,9 @@@ BUFFER is the buffer (or `buffer-name'
  Third arg is name of the host to connect to, or its IP address.
  Fourth arg SERVICE is name of the service desired, or an integer
  specifying a port number to connect to.
+ Fifth arg NOWAIT (which is optional) means that the socket should
+ be opened asynchronously.  The connection process will be
+ returned to the caller before TLS negotiation has happened.
  
  Usage example:
  
@@@ -122,9 -125,20 +125,20 @@@ This is a very simple wrapper around `g
  documentation for the specific parameters you can use to open a
  GnuTLS connection, including specifying the credential type,
  trust and key files, and priority string."
-   (gnutls-negotiate :process (open-network-stream name buffer host service)
-                     :type 'gnutls-x509pki
-                     :hostname host))
+   (let ((process (open-network-stream
+                   name buffer host service
+                   :nowait nowait
+                   :tls-parameters
+                   (and nowait
+                        (cons 'gnutls-x509pki
+                              (gnutls-boot-parameters
+                               :type 'gnutls-x509pki
+                               :hostname host))))))
+     (if nowait
+         process
+       (gnutls-negotiate :process process
+                         :type 'gnutls-x509pki
+                         :hostname host))))
  
  (define-error 'gnutls-error "GnuTLS error")
  
             &allow-other-keys)
    "Negotiate a SSL/TLS connection.  Returns proc.  Signals gnutls-error.
  
- Note arguments are passed CL style, :type TYPE instead of just TYPE.
+ Note that arguments are passed CL style, :type TYPE instead of just TYPE.
  
- TYPE is `gnutls-x509pki' (default) or `gnutls-anon'.  Use nil for the default.
  PROCESS is a process returned by `open-network-stream'.
+ For the meaning of the rest of the parameters, see `gnutls-boot-parameters'."
+   (let* ((type (or type 'gnutls-x509pki))
+        ;; The gnutls library doesn't understand files delivered via
+        ;; the special handlers, so ignore all files found via those.
+        (file-name-handler-alist nil)
+          (params (gnutls-boot-parameters
+                   :type type
+                   :hostname hostname
+                   :priority-string priority-string
+                   :trustfiles trustfiles
+                   :crlfiles crlfiles
+                   :keylist keylist
+                   :min-prime-bits min-prime-bits
+                   :verify-flags verify-flags
+                   :verify-error verify-error
+                   :verify-hostname-error verify-hostname-error))
+          ret)
+     (gnutls-message-maybe
+      (setq ret (gnutls-boot process type params))
+      "boot: %s" params)
+     (when (gnutls-errorp ret)
+       ;; This is a error from the underlying C code.
+       (signal 'gnutls-error (list process ret)))
+     process))
+ (cl-defun gnutls-boot-parameters
+     (&rest spec
+            &key type hostname priority-string
+            trustfiles crlfiles keylist min-prime-bits
+            verify-flags verify-error verify-hostname-error
+            &allow-other-keys)
+   "Return a keyword list of parameters suitable for passing to `gnutls-boot'.
+ TYPE is `gnutls-x509pki' (default) or `gnutls-anon'.  Use nil for the default.
  HOSTNAME is the remote hostname.  It must be a valid string.
  PRIORITY-STRING is as per the GnuTLS docs, default is \"NORMAL\".
  TRUSTFILES is a list of CA bundles.  It defaults to `gnutls-trustfiles'.
@@@ -189,62 -238,47 +238,47 @@@ here's a recent version of the list
  
  It must be omitted, a number, or nil; if omitted or nil it
  defaults to GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT."
-   (let* ((type (or type 'gnutls-x509pki))
-        ;; The gnutls library doesn't understand files delivered via
-        ;; the special handlers, so ignore all files found via those.
-        (file-name-handler-alist nil)
-          (trustfiles (or trustfiles (gnutls-trustfiles)))
-          (priority-string (or priority-string
-                               (cond
-                                ((eq type 'gnutls-anon)
-                                 "NORMAL:+ANON-DH:!ARCFOUR-128")
-                                ((eq type 'gnutls-x509pki)
-                                 (if gnutls-algorithm-priority
-                                     (upcase gnutls-algorithm-priority)
-                                   "NORMAL")))))
-          (verify-error (or verify-error
-                            ;; this uses the value of `gnutls-verify-error'
-                            (cond
-                             ;; if t, pass it on
-                             ((eq gnutls-verify-error t)
-                              t)
-                             ;; if a list, look for hostname matches
-                             ((listp gnutls-verify-error)
-                              (apply 'append
-                                     (mapcar
-                                      (lambda (check)
-                                        (when (string-match (nth 0 check)
-                                                            hostname)
-                                          (nth 1 check)))
-                                      gnutls-verify-error)))
-                             ;; else it's nil
-                             (t nil))))
-          (min-prime-bits (or min-prime-bits gnutls-min-prime-bits))
-          params ret)
+   (let ((trustfiles (or trustfiles (gnutls-trustfiles)))
+         (priority-string (or priority-string
+                              (cond
+                               ((eq type 'gnutls-anon)
+                                "NORMAL:+ANON-DH:!ARCFOUR-128")
+                               ((eq type 'gnutls-x509pki)
+                                (if gnutls-algorithm-priority
+                                    (upcase gnutls-algorithm-priority)
+                                  "NORMAL")))))
+         (verify-error (or verify-error
+                           ;; this uses the value of `gnutls-verify-error'
+                           (cond
+                            ;; if t, pass it on
+                            ((eq gnutls-verify-error t)
+                             t)
+                            ;; if a list, look for hostname matches
+                            ((listp gnutls-verify-error)
+                             (apply 'append
+                                    (mapcar
+                                     (lambda (check)
+                                       (when (string-match (nth 0 check)
+                                                           hostname)
+                                         (nth 1 check)))
+                                     gnutls-verify-error)))
+                            ;; else it's nil
+                            (t nil))))
+         (min-prime-bits (or min-prime-bits gnutls-min-prime-bits)))
  
      (when verify-hostname-error
        (push :hostname verify-error))
  
-     (setq params `(:priority ,priority-string
-                              :hostname ,hostname
-                              :loglevel ,gnutls-log-level
-                              :min-prime-bits ,min-prime-bits
-                              :trustfiles ,trustfiles
-                              :crlfiles ,crlfiles
-                              :keylist ,keylist
-                              :verify-flags ,verify-flags
-                              :verify-error ,verify-error
-                              :callbacks nil))
-     (gnutls-message-maybe
-      (setq ret (gnutls-boot process type params))
-      "boot: %s" params)
-     (when (gnutls-errorp ret)
-       ;; This is a error from the underlying C code.
-       (signal 'gnutls-error (list process ret)))
-     process))
+     `(:priority ,priority-string
+                 :hostname ,hostname
+                 :loglevel ,gnutls-log-level
+                 :min-prime-bits ,min-prime-bits
+                 :trustfiles ,trustfiles
+                 :crlfiles ,crlfiles
+                 :keylist ,keylist
+                 :verify-flags ,verify-flags
+                 :verify-error ,verify-error
+                 :callbacks nil)))
  
  (defun gnutls-trustfiles ()
    "Return a list of usable trustfiles."
index e5557b8e39263a736d337efec8486c9988b032ec,1bba35ac81d295b58022a98e59ea2ee7607ed081..f919efb21974ec9c370a67b97f831f51e804217c
@@@ -136,8 -136,14 +136,14 @@@ non-nil, is used warn the user if the c
  :nogreeting is a boolean that can be used to inhibit waiting for
  a greeting from the server.
  
- :nowait is a boolean that says the connection should be made
- asynchronously, if possible."
+ :nowait, if non-nil, says the connection should be made
+ asynchronously, if possible.
+ :tls-parameters is a list that should be supplied if you're
+ opening a TLS connection.  The first element is the TLS
+ type (either `gnutls-x509pki' or `gnutls-anon'), and the
+ remaining elements should be a keyword list accepted by
+ gnutls-boot (as returned by `gnutls-boot-parameters')."
    (unless (featurep 'make-network-process)
      (error "Emacs was compiled without networking support"))
    (let ((type (plist-get parameters :type))
        ;; The simplest case: wrapper around `make-network-process'.
        (make-network-process :name name :buffer buffer
                              :host (puny-encode-domain host) :service service
-                             :nowait (plist-get parameters :nowait))
+                             :nowait (plist-get parameters :nowait)
+                               :tls-parameters
+                               (plist-get parameters :tls-parameters))
        (let ((work-buffer (or buffer
                             (generate-new-buffer " *stream buffer*")))
            (fun (cond ((and (eq type 'plain)
  
  ;;;###autoload
  (defalias 'open-protocol-stream 'open-network-stream)
 +(define-obsolete-function-alias 'open-protocol-stream 'open-network-stream
 +  "25.2")
  
  (defun network-stream-open-plain (name buffer host service parameters)
    (let ((start (with-current-buffer buffer (point)))
    (with-current-buffer buffer
      (let* ((start (point-max))
           (stream
-           (funcall (if (gnutls-available-p)
-                        'open-gnutls-stream
-                      'open-tls-stream)
-                    name buffer host service))
+             (if (gnutls-available-p)
+                 (open-gnutls-stream name buffer host service
+                                     (plist-get parameters :nowait))
+               (open-tls-stream name buffer host service)))
           (eoc (plist-get parameters :end-of-command)))
-       ;; Check certificate validity etc.
-       (when (and (gnutls-available-p) stream)
-       (setq stream (nsm-verify-connection stream host service)))
-       (if (null stream)
-         (list nil nil nil 'plain)
-       ;; If we're using tls.el, we have to delete the output from
-       ;; openssl/gnutls-cli.
-       (when (and (not (gnutls-available-p))
-                  eoc)
-         (network-stream-get-response stream start eoc)
-         (goto-char (point-min))
-         (when (re-search-forward eoc nil t)
-           (goto-char (match-beginning 0))
-           (delete-region (point-min) (line-beginning-position))))
-       (let ((capability-command (plist-get parameters :capability-command))
-             (eo-capa (or (plist-get parameters :end-of-capability)
-                          eoc)))
-         (list stream
-               (network-stream-get-response stream start eoc)
-               (network-stream-command stream capability-command eo-capa)
-               'tls))))))
+       (if (plist-get parameters :nowait)
+           (list stream nil nil 'tls)
+         ;; Check certificate validity etc.
+         (when (and (gnutls-available-p) stream)
+           (setq stream (nsm-verify-connection stream host service)))
+         (if (null stream)
+             (list nil nil nil 'plain)
+           ;; If we're using tls.el, we have to delete the output from
+           ;; openssl/gnutls-cli.
+           (when (and (not (gnutls-available-p))
+                      eoc)
+             (network-stream-get-response stream start eoc)
+             (goto-char (point-min))
+             (when (re-search-forward eoc nil t)
+               (goto-char (match-beginning 0))
+               (delete-region (point-min) (line-beginning-position))))
+           (let ((capability-command (plist-get parameters :capability-command))
+                 (eo-capa (or (plist-get parameters :end-of-capability)
+                              eoc)))
+             (list stream
+                   (network-stream-get-response stream start eoc)
+                   (network-stream-command stream capability-command eo-capa)
+                   'tls)))))))
  
  (defun network-stream-open-shell (name buffer host service parameters)
    (require 'format-spec)
diff --combined src/Makefile.in
index a14d36f3f8098a66a65e03854e0f5cfb794bc49f,233ed19e8fb9335dbded06cfffd1074b8a44e5da..99394ac57cf5be80c012ca4065500cc0290672f5
@@@ -152,9 -152,6 +152,9 @@@ DBUS_LIBS = @DBUS_LIBS
  ## dbusbind.o if HAVE_DBUS, else empty.
  DBUS_OBJ = @DBUS_OBJ@
  
 +## xwidgets.o if HAVE_XWIDGETS, else empty.
 +XWIDGETS_OBJ = @XWIDGETS_OBJ@
 +
  LIB_EXECINFO=@LIB_EXECINFO@
  
  SETTINGS_CFLAGS = @SETTINGS_CFLAGS@
@@@ -214,8 -211,8 +214,8 @@@ LIBX_OTHER=@LIBX_OTHER
  ## configure, which should set it to nil in non-X builds.
  LIBX_BASE=$(LIBXMENU) $(LD_SWITCH_X_SITE)
  
 -## Only used for GNUstep
 -LIBS_GNUSTEP=@LIBS_GNUSTEP@
 +## Used only for GNUstep.
 +LIBS_GNUSTEP=$(patsubst -specs=%-hardened-ld,,@LIBS_GNUSTEP@)
  
  LIBSOUND= @LIBSOUND@
  CFLAGS_SOUND= @CFLAGS_SOUND@
  RSVG_LIBS= @RSVG_LIBS@
  RSVG_CFLAGS= @RSVG_CFLAGS@
  
 +WEBKIT_LIBS= @WEBKIT_LIBS@
 +WEBKIT_CFLAGS= @WEBKIT_CFLAGS@
 +
  CAIRO_LIBS= @CAIRO_LIBS@
  CAIRO_CFLAGS= @CAIRO_CFLAGS@
  
@@@ -235,6 -229,8 +235,8 @@@ IMAGEMAGICK_CFLAGS= @IMAGEMAGICK_CFLAGS
  LIBXML2_LIBS = @LIBXML2_LIBS@
  LIBXML2_CFLAGS = @LIBXML2_CFLAGS@
  
+ GETADDRINFO_A_LIBS = @GETADDRINFO_A_LIBS@
  LIBZ = @LIBZ@
  
  ## system-specific libs for dynamic modules, else empty
@@@ -254,9 -250,7 +256,9 @@@ XFIXES_CFLAGS = @XFIXES_CFLAGS
  ## widget.o if USE_X_TOOLKIT, otherwise empty.
  WIDGET_OBJ=@WIDGET_OBJ@
  
 -## sheap.o if CYGWIN, otherwise empty.
 +HYBRID_MALLOC = @HYBRID_MALLOC@
 +
 +## cygw32.o if CYGWIN, otherwise empty.
  CYGWIN_OBJ=@CYGWIN_OBJ@
  
  ## fontset.o fringe.o image.o if we have any window system
@@@ -270,8 -264,8 +272,8 @@@ MSDOS_X_OBJ 
  NS_OBJ=@NS_OBJ@
  ## nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o ns_fontfile if HAVE_NS.
  NS_OBJC_OBJ=@NS_OBJC_OBJ@
 -## Only set if NS_IMPL_GNUSTEP.
 -GNU_OBJC_CFLAGS=@GNU_OBJC_CFLAGS@
 +## Used only for GNUstep.
 +GNU_OBJC_CFLAGS=$(patsubst -specs=%-hardened-cc1,,@GNU_OBJC_CFLAGS@)
  ## w32fns.o w32menu.c w32reg.o fringe.o fontset.o w32font.o w32term.o
  ## w32xfns.o w32select.o image.o w32uniscribe.o if HAVE_W32, else
  ## empty.
@@@ -367,7 -361,6 +369,7 @@@ ALL_CFLAGS=-Demacs $(MYCPPFLAGS) -I. -I
    $(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \
    $(PNG_CFLAGS) $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \
    $(XRANDR_CFLAGS) $(XINERAMA_CFLAGS) $(XFIXES_CFLAGS) \
 +  $(WEBKIT_CFLAGS) \
    $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \
    $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) \
    $(LIBGNUTLS_CFLAGS) $(NOTIFY_CFLAGS) $(CAIRO_CFLAGS) \
@@@ -397,10 -390,7 +399,10 @@@ base_obj = dispnew.o frame.o scroll.o x
        process.o gnutls.o callproc.o \
        region-cache.o sound.o atimer.o \
        doprnt.o intervals.o textprop.o composite.o xml.o $(NOTIFY_OBJ) \
 +      $(XWIDGETS_OBJ) \
        profiler.o decompress.o \
 +      $(if $(HYBRID_MALLOC),sheap.o) \
 +      $(SHEAP_OBJ) \
        $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \
        $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ)
  obj = $(base_obj) $(NS_OBJC_OBJ)
@@@ -480,13 -470,12 +482,13 @@@ lisp = $(addprefix ${lispsource}/,${sho
  LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
     $(LIBX_OTHER) $(LIBSOUND) \
     $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_ACL) $(LIB_CLOCK_GETTIME) \
 +   $(WEBKIT_LIBS) \
     $(LIB_EACCESS) $(LIB_FDATASYNC) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
     $(LIB_EXECINFO) $(XRANDR_LIBS) $(XINERAMA_LIBS) $(XFIXES_LIBS) \
     $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) $(CAIRO_LIBS) \
     $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
     $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
-    $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) \
+    $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(GETADDRINFO_A_LIBS) \
     $(NOTIFY_LIBS) $(LIB_MATH) $(LIBZ) $(LIBMODULES)
  
  $(leimdir)/leim-list.el: bootstrap-emacs$(EXEEXT)
@@@ -505,11 -494,6 +507,11 @@@ $(srcdir)/macuvs.h $(lispsource)/intern
  $(lispsource)/international/ucs-normalize.elc: | \
    $(lispsource)/international/charprop.el
  
 +## ns-win.el loads ucs-normalize, so it also needs the above-mentioned
 +## 2 uni-*.el files to exist.
 +$(lispsource)/term/ns-win.elc: | \
 +  $(lispsource)/international/charprop.el
 +
  lispintdir = ${lispsource}/international
  ${lispintdir}/cp51932.el ${lispintdir}/eucjp-ms.el: FORCE
        ${MAKE} -C ../admin/charsets $(notdir $@)
@@@ -585,9 -569,7 +587,9 @@@ globals.h: gl-stamp; @tru
  
  $(ALLOBJS): globals.h
  
 -$(lib)/libgnu.a: $(config_h)
 +LIBEGNU_ARCHIVE = $(lib)/lib$(if $(HYBRID_MALLOC),e)gnu.a
 +
 +$(LIBEGNU_ARCHIVE): $(config_h)
        $(MAKE) -C $(lib) all
  
  ## We have to create $(etc) here because init_cmdargs tests its
  ## This goes on to affect various things, and the emacs binary fails
  ## to start if Vinstallation_directory has the wrong value.
  temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) \
 -               $(lib)/libgnu.a $(EMACSRES) ${charsets} ${charscript}
 +               $(LIBEGNU_ARCHIVE) $(EMACSRES) ${charsets} ${charscript}
        $(AM_V_CCLD)$(CC) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
 -        -o temacs $(ALLOBJS) $(lib)/libgnu.a $(W32_RES_LINK) $(LIBES)
 +        -o temacs $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES)
        $(MKDIR_P) $(etc)
  ifneq ($(CANNOT_DUMP),yes)
        $(PAXCTL_if_present) -r $@
diff --combined src/eval.c
index 26104a58277137fd0988f9a3ad4b904f8f62ec51,c01dd09199f1b65884cea7c2725c05d65b8cb9f2..b6bf0e64052be7983f2d1d1fbca1373a6e5335e2
@@@ -1245,7 -1245,7 +1245,7 @@@ internal_lisp_condition_case (volatile 
      for (i = 0; i < clausenb; i++)
        {
        Lisp_Object clause = clauses[i];
 -      Lisp_Object condition = XCAR (clause);
 +      Lisp_Object condition = CONSP (clause) ? XCAR (clause) : Qnil;
        if (!CONSP (condition))
          condition = Fcons (condition, Qnil);
        struct handler *c = push_handler (condition, CONDITION_CASE);
@@@ -1751,9 -1751,9 +1751,9 @@@ find_handler_clause (Lisp_Object handle
  }
  
  
- /* Dump an error message; called like vprintf.  */
- void
- verror (const char *m, va_list ap)
+ /* Format and return a string; called like vprintf.  */
+ Lisp_Object
+ vformat_string (const char *m, va_list ap)
  {
    char buf[4000];
    ptrdiff_t size = sizeof buf;
    if (buffer != buf)
      xfree (buffer);
  
-   xsignal1 (Qerror, string);
+   return string;
+ }
+ /* Dump an error message; called like vprintf.  */
+ void
+ verror (const char *m, va_list ap)
+ {
+   xsignal1 (Qerror, vformat_string (m, ap));
  }
  
  
diff --combined src/lisp.h
index 8aa286159d7d6c0dd3f3434c08bd51068bd86361,e87f47510f83287abb8d36db1248ad73a8b6f16a..18d986441f0bdcec7d3a50d2135089417fb18da6
@@@ -67,6 -67,19 +67,6 @@@ DEFINE_GDB_SYMBOL_BEGIN (int, GCTYPEBIT
  #define GCTYPEBITS 3
  DEFINE_GDB_SYMBOL_END (GCTYPEBITS)
  
 -/* The number of bits needed in an EMACS_INT over and above the number
 -   of bits in a pointer.  This is 0 on systems where:
 -   1.  We can specify multiple-of-8 alignment on static variables.
 -   2.  We know malloc returns a multiple of 8.  */
 -#if (defined alignas \
 -     && (defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ \
 -       || defined DARWIN_OS || defined __sun || defined __MINGW32__ \
 -       || defined CYGWIN))
 -# define NONPOINTER_BITS 0
 -#else
 -# define NONPOINTER_BITS GCTYPEBITS
 -#endif
 -
  /* EMACS_INT - signed integer wide enough to hold an Emacs value
     EMACS_INT_MAX - maximum value of EMACS_INT; can be used in #if
     pI - printf length modifier for EMACS_INT
  #ifndef EMACS_INT_MAX
  # if INTPTR_MAX <= 0
  #  error "INTPTR_MAX misconfigured"
 -# elif INTPTR_MAX <= INT_MAX >> NONPOINTER_BITS && !defined WIDE_EMACS_INT
 +# elif INTPTR_MAX <= INT_MAX && !defined WIDE_EMACS_INT
  typedef int EMACS_INT;
  typedef unsigned int EMACS_UINT;
  #  define EMACS_INT_MAX INT_MAX
  #  define pI ""
 -# elif INTPTR_MAX <= LONG_MAX >> NONPOINTER_BITS && !defined WIDE_EMACS_INT
 +# elif INTPTR_MAX <= LONG_MAX && !defined WIDE_EMACS_INT
  typedef long int EMACS_INT;
  typedef unsigned long EMACS_UINT;
  #  define EMACS_INT_MAX LONG_MAX
  #  define pI "l"
 -/* Check versus LLONG_MAX, not LLONG_MAX >> NONPOINTER_BITS.
 -   In theory this is not safe, but in practice it seems to be OK.  */
  # elif INTPTR_MAX <= LLONG_MAX
  typedef long long int EMACS_INT;
  typedef unsigned long long int EMACS_UINT;
@@@ -262,6 -277,10 +262,6 @@@ DEFINE_GDB_SYMBOL_END (USE_LSB_TAG
  error !;
  #endif
  
 -#ifndef alignas
 -# error "alignas not defined"
 -#endif
 -
  #ifdef HAVE_STRUCT_ATTRIBUTE_ALIGNED
  # define GCALIGNED __attribute__ ((aligned (GCALIGNMENT)))
  #else
@@@ -600,9 -619,7 +600,9 @@@ extern _Noreturn Lisp_Object wrong_type
  extern _Noreturn void wrong_choice (Lisp_Object, Lisp_Object);
  
  /* Defined in emacs.c.  */
 +#ifdef DOUG_LEA_MALLOC
  extern bool might_dump;
 +#endif
  /* True means Emacs has already been initialized.
     Used during startup to detect startup of dumped Emacs.  */
  extern bool initialized;
@@@ -782,9 -799,6 +782,9 @@@ enum pvec_typ
    PVEC_WINDOW_CONFIGURATION,
    PVEC_SUBR,
    PVEC_OTHER,
 +  PVEC_XWIDGET,
 +  PVEC_XWIDGET_VIEW,
 +
    /* These should be last, check internal_equal to see why.  */
    PVEC_COMPILED,
    PVEC_CHAR_TABLE,
@@@ -2073,7 -2087,7 +2073,7 @@@ struct Lisp_Marke
    /* For markers that point somewhere,
       this is used to chain of all the markers in a given buffer.  */
    /* We could remove it and use an array in buffer_text instead.
 -     That would also allow to preserve it ordered.  */
 +     That would also allow us to preserve it ordered.  */
    struct Lisp_Marker *next;
    /* This is the char position where the marker points.  */
    ptrdiff_t charpos;
@@@ -3573,7 -3587,6 +3573,7 @@@ extern void parse_str_as_multibyte (con
                                    ptrdiff_t *, ptrdiff_t *);
  
  /* Defined in alloc.c.  */
 +extern void *my_heap_start (void);
  extern void check_pure_size (void);
  extern void free_misc (Lisp_Object);
  extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT);
@@@ -3585,8 -3598,6 +3585,8 @@@ extern void mark_object (Lisp_Object)
  #if defined REL_ALLOC && !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC
  extern void refill_memory_reserve (void);
  #endif
 +extern void alloc_unexec_pre (void);
 +extern void alloc_unexec_post (void);
  extern const char *pending_malloc_warning;
  extern Lisp_Object zero_vector;
  extern Lisp_Object *stack_base;
@@@ -3752,15 -3763,6 +3752,15 @@@ extern void check_cons_list (void)
  INLINE void (check_cons_list) (void) { lisp_h_check_cons_list (); }
  #endif
  
 +/* Defined in gmalloc.c.  */
 +#if !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC && !defined SYSTEM_MALLOC
 +extern size_t __malloc_extra_blocks;
 +#endif
 +#if !HAVE_DECL_ALIGNED_ALLOC
 +extern void *aligned_alloc (size_t, size_t) ATTRIBUTE_MALLOC_SIZE ((2));
 +#endif
 +extern void malloc_enable_thread (void);
 +
  #ifdef REL_ALLOC
  /* Defined in ralloc.c.  */
  extern void *r_alloc (void **, size_t) ATTRIBUTE_ALLOC_SIZE ((2));
@@@ -3906,6 -3908,8 +3906,8 @@@ extern Lisp_Object unbind_to (ptrdiff_t
  extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
  extern _Noreturn void verror (const char *, va_list)
    ATTRIBUTE_FORMAT_PRINTF (1, 0);
+ extern Lisp_Object vformat_string (const char *, va_list)
+   ATTRIBUTE_FORMAT_PRINTF (1, 0);
  extern void un_autoload (Lisp_Object);
  extern Lisp_Object call_debugger (Lisp_Object arg);
  extern void *near_C_stack_top (void);
@@@ -4241,7 -4245,9 +4243,7 @@@ struct tty_display_info
  struct terminal;
  
  /* Defined in sysdep.c.  */
 -#ifndef HAVE_GET_CURRENT_DIR_NAME
 -extern char *get_current_dir_name (void);
 -#endif
 +extern char *emacs_get_current_dir_name (void);
  extern void stuff_char (char c);
  extern void init_foreground_group (void);
  extern void sys_subshell (void);
@@@ -4526,12 -4532,6 +4528,12 @@@ extern void *record_xmalloc (size_t) AT
     This feature is experimental and requires careful debugging.
     Build with CPPFLAGS='-DUSE_STACK_LISP_OBJECTS=0' to disable it.  */
  
 +#if (!defined USE_STACK_LISP_OBJECTS \
 +     && defined __GNUC__ && !defined __clang__ \
 +     && !(4 < __GNUC__ + (3 < __GNUC_MINOR__ + (2 <= __GNUC_PATCHLEVEL__))))
 +  /* Work around GCC bugs 36584 and 35271, which were fixed in GCC 4.3.2.  */
 +# define USE_STACK_LISP_OBJECTS false
 +#endif
  #ifndef USE_STACK_LISP_OBJECTS
  # define USE_STACK_LISP_OBJECTS true
  #endif
index a5e146f02c85af17131b340e1f40c0424775e80c,e19bd528961e6c4cb06de4432f458e24f48113ac..c6a20b09690eb0fdb26f86707f77e94566fa7a33
@@@ -4,8 -4,6 +4,8 @@@
  
  ;; Author: Lars Ingebrigtsen <larsi@gnus.org>
  
 +;; This file is part of GNU Emacs.
 +
  ;; GNU Emacs is free software: you can redistribute it and/or modify
  ;; it under the terms of the GNU General Public License as published by
  ;; the Free Software Foundation, either version 3 of the License, or
@@@ -27,7 -25,6 +27,7 @@@
  (require 'gnutls)
  
  (ert-deftest make-local-unix-server ()
 +  (skip-unless (featurep 'make-network-process '(:family local)))
    (let* ((file (make-temp-name "/tmp/server-test"))
           (server
            (make-network-process
@@@ -40,7 -37,7 +40,7 @@@
      (should (equal (process-contact server :local) file))
      (delete-file (process-contact server :local))))
  
- (ert-deftest make-local-tcp-server-with-unspecified-port ()
+ (ert-deftest make-ipv4-tcp-server-with-unspecified-port ()
    (let ((server
           (make-network-process
            :name "server"
@@@ -54,7 -51,7 +54,7 @@@
                   (> (aref (process-contact server :local) 4) 0)))
      (delete-process server)))
  
- (ert-deftest make-local-tcp-server-with-specified-port ()
+ (ert-deftest make-ipv4-tcp-server-with-specified-port ()
    (let ((server
           (make-network-process
            :name "server"
                                       :nowait t
                                       :service port)))
      (should (eq (process-status proc) 'connect))
-     (should (null (ignore-errors
-                     (process-send-string proc "echo bar")
-                     t)))
      (while (eq (process-status proc) 'connect)
        (sit-for 0.1))
      (with-current-buffer (process-buffer proc)
        (should (equal (buffer-string) "foo\n")))
      (delete-process server)))
  
- (defun make-tls-server ()
+ (defun make-tls-server (port)
    (start-process "gnutls" (generate-new-buffer "*tls*")
                   "gnutls-serv" "--http"
                   "--x509keyfile" "lisp/net/key.pem"
                   "--x509certfile" "lisp/net/cert.pem"
-                  "--port" "44330"))
+                  "--port" (format "%s" port)))
  
  (ert-deftest connect-to-tls-ipv4-wait ()
    (skip-unless (executable-find "gnutls-serv"))
    (skip-unless (gnutls-available-p))
-   (let ((server (make-tls-server))
+   (let ((server (make-tls-server 44332))
          (times 0)
          proc status)
      (sleep-for 1)
                                      :name "bar"
                                      :buffer (generate-new-buffer "*foo*")
                                      :host "localhost"
-                                     :service 44330))))
+                                     :service 44332))))
                  (< (setq times (1+ times)) 10))
        (sit-for 0.1))
      (should proc)
      (setq status (gnutls-peer-status proc))
      (should (consp status))
      (delete-process proc)
 +    ;; This sleep-for is needed for the native MS-Windows build.  If
 +    ;; it is removed, the next test mysteriously fails because the
 +    ;; initial part of the echo is not received.
 +    (sleep-for 0.1)
      (let ((issuer (plist-get (plist-get status :certificate) :issuer)))
        (should (stringp issuer))
        (setq issuer (split-string issuer ","))
        (should (equal (nth 3 issuer) "O=Emacs Test Servicess LLC")))))
  
+ (ert-deftest connect-to-tls-ipv4-nowait ()
+   (skip-unless (executable-find "gnutls-serv"))
+   (skip-unless (gnutls-available-p))
+   (let ((server (make-tls-server 44331))
+         (times 0)
+         proc status)
+     (sleep-for 1)
+     (with-current-buffer (process-buffer server)
+       (message "gnutls-serv: %s" (buffer-string)))
+     ;; It takes a while for gnutls-serv to start.
+     (while (and (null (ignore-errors
+                         (setq proc (make-network-process
+                                     :name "bar"
+                                     :buffer (generate-new-buffer "*foo*")
+                                     :nowait t
+                                     :tls-parameters
+                                     (cons 'gnutls-x509pki
+                                           (gnutls-boot-parameters
+                                            :hostname "localhost"))
+                                     :host "localhost"
+                                     :service 44331))))
+                 (< (setq times (1+ times)) 10))
+       (sit-for 0.1))
+     (should proc)
+     (while (eq (process-status proc) 'connect)
+       (sit-for 0.1))
+     (delete-process server)
+     (setq status (gnutls-peer-status proc))
+     (should (consp status))
+     (delete-process proc)
+     (let ((issuer (plist-get (plist-get status :certificate) :issuer)))
+       (should (stringp issuer))
+       (setq issuer (split-string issuer ","))
+       (should (equal (nth 3 issuer) "O=Emacs Test Servicess LLC")))))
  (ert-deftest connect-to-tls-ipv6-nowait ()
    (skip-unless (executable-find "gnutls-serv"))
    (skip-unless (gnutls-available-p))
-   (let ((server (make-tls-server))
 +  (skip-unless (not (eq system-type 'windows-nt)))
+   (let ((server (make-tls-server 44333))
          (times 0)
          proc status)
      (sleep-for 1)
                                      :buffer (generate-new-buffer "*foo*")
                                      :family 'ipv6
                                      :nowait t
+                                     :tls-parameters
+                                     (cons 'gnutls-x509pki
+                                           (gnutls-boot-parameters
+                                            :hostname "localhost"))
                                      :host "::1"
-                                     :service 44330))))
+                                     :service 44333))))
                  (< (setq times (1+ times)) 10))
        (sit-for 0.1))
      (should proc)
-     (gnutls-negotiate :process proc
-                       :type 'gnutls-x509pki
-                       :hostname "localhost")
+     (while (eq (process-status proc) 'connect)
+       (sit-for 0.1))
      (delete-process server)
      (setq status (gnutls-peer-status proc))
      (should (consp status))