emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: smtpmail on Windows native Emacs with gnutls-cli from Cygwin freeze.


From: Oleksandr Gavenko
Subject: Re: smtpmail on Windows native Emacs with gnutls-cli from Cygwin freeze.
Date: Mon, 24 Oct 2011 01:40:30 +0300
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1

24.10.2011 0:53, Oleksandr Gavenko пишет:
I like use native Emacs with Cygwin toolset. It does not
hard to friend then. But from time to time I discover some issues.

Now time I finally try setup Emacs to work with mail.

GMail SMTP require TLS connection. As usual this done by
'gnus/starttls.el'.

After configuring smtpmail (send-mail-function==smtpmail-send-it)
I try compose mail:

C-x m bla-bla-bla C-c C-c

Emacs freeze! Try same in Cygwin Emacs and all OK!

After debug I found root of evil:

(defun starttls-open-stream-gnutls (name buffer host port)
...
(process (apply #'start-process name buffer
starttls-gnutls-program "-s" host
"-p" (if (integerp port)
(int-to-string port)
port)
starttls-extra-arguments))
...)))))

(defun starttls-negotiate-gnutls (process)
...
;; XXX How to remove/extract the TLS negotiation junk?
(signal-process (process-id process) 'SIGALRM)
...
(save-excursion
(setq old-max (goto-char (point-max)))
(signal-process (process-id process) 'SIGALRM)
(while (and (processp process)
(eq (process-status process) 'run)
(save-excursion
(goto-char old-max)
(not (or (setq done-ok (re-search-forward
starttls-success nil t))
(setq done-bad (re-search-forward
starttls-failure nil t))))))
(accept-process-output process 1 100)
(sit-for 0.1))
...

So 'gnutls-cli' called with '-s' option. From man page:

-s, --starttls
Connect, establish a plain session and start TLS
when EOF or a SIGALRM is received.

and 'signal-process' call do nothing for SIGALRM. More correctly
return error. Look to 'src/w32proc.c':

int
sys_kill (int pid, int sig)
{
...
/* Only handle signals that will result in the process dying */
if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP)
{
errno = EINVAL;
return -1;
}

So 'gnutls-cli' don't send anything and 'while' loop can not match
'starttls-failure', 'starttls-success', etc...

I easy make workaround. Just replace 'signal-process' with Cygwin
'kill.exe':

(shell-command (format "kill.exe -s SIGALRM %d" (process-id process)))

Solution that prevent modify any existing lisp code:

(defadvice signal-process (around cygwin (process sigcode))
  "Use 'kill.exe' instead build-in Emacs 'kill'."
  (if (eq sigcode 'SIGALRM)
      (shell-command
       (format "kill.exe -s SIGALRM %d"
               (if (processp process) (process-id process) process)))
    ad-do-it
    ))
(ad-activate 'signal-process)

--
Happy hacking!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]