From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] GnuTLS support on Woe32 Date: Sat, 12 Mar 2011 14:48:35 +0200 Message-ID: <83oc5gsdwc.fsf@gnu.org> References: <87ipvwl1nx.wl%claudio.bley@gmail.com> <83oc5ogp89.fsf@gnu.org> <87ipvuwslp.wl%claudio.bley@gmail.com> <87hbbc0zi6.wl%claudio.bley@gmail.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1299934207 11302 80.91.229.12 (12 Mar 2011 12:50:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 12 Mar 2011 12:50:07 +0000 (UTC) Cc: emacs-devel@gnu.org To: claudio.bley@gmail.com (Claudio Bley) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 12 13:50:02 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PyOGg-0004d9-2O for ged-emacs-devel@m.gmane.org; Sat, 12 Mar 2011 13:50:02 +0100 Original-Received: from localhost ([127.0.0.1]:33095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PyOGf-0003bj-IH for ged-emacs-devel@m.gmane.org; Sat, 12 Mar 2011 07:50:01 -0500 Original-Received: from [140.186.70.92] (port=52049 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PyOGa-0003bV-6N for emacs-devel@gnu.org; Sat, 12 Mar 2011 07:49:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PyOGZ-0003xz-0Z for emacs-devel@gnu.org; Sat, 12 Mar 2011 07:49:56 -0500 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:44557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PyOGY-0003xf-QP for emacs-devel@gnu.org; Sat, 12 Mar 2011 07:49:54 -0500 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0LHY003003J6JJ00@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Sat, 12 Mar 2011 14:48:30 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([77.124.58.59]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LHY0000R3KTYCK0@a-mtaout22.012.net.il>; Sat, 12 Mar 2011 14:48:30 +0200 (IST) In-reply-to: <87hbbc0zi6.wl%claudio.bley@gmail.com> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.172 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:137150 Archived-At: > From: claudio.bley@gmail.com (Claudio Bley) > Date: Wed, 09 Mar 2011 22:12:33 +0100 > > > > > +static int > > > > +wsaerror_to_errno(int err) > > > > +{ > > > > + switch (err) > > > > + { > > > > + case WSAEWOULDBLOCK: > > > > + return EAGAIN; > > > > + case WSAEINTR: > > > > + return EINTR; > > > > + default: > > > > + return err; > > > > + } > > > > +} > > > > > > Why is this function needed? Can you extend w32.c:set_errno instead > > > (if it doesn't already support all the values of WSA* errors that you > > > need)? > > > > Yes, I could extend w32.c:set_errno, if I move the Windows-specific > > function to w32.c proper... > > I just had a look at this again. It's not so easy. > > For GnuTLS, I have to map WSAEWOULDBLOCK to EAGAIN. This is set in > stone. Set in stone where? I see this in gnutls.c: int emacs_gnutls_write (int fildes, struct Lisp_Process *proc, char *buf, unsigned int nbyte) { register int rtnval, bytes_written; gnutls_session_t state = proc->gnutls_state; if (proc->gnutls_initstage != GNUTLS_STAGE_READY) { #ifdef EWOULDBLOCK errno = EWOULDBLOCK; #endif #ifdef EAGAIN errno = EAGAIN; #endif return -1; } So it looks like it already is prepared to deal with EWOULDBLOCK if EAGAIN is not available. > Doing this in w32.c:set_errno would break a lot of other stuff that > checks for EWOULDBLOCK because that happens to be #define'd to > WSAEWOULDBLOCK in sys/socket.h:129 (which seems reasonable after all). If all you need is to produce EAGAIN when you have EWOULDBLOCK (the other mapping is already in set_errno), it hardly justifies a function. But I would like to understand better why you must produce EAGAIN in the first place. > It works alright when EWOULDBLOCK is #define'd to EAGAIN. In the end > it doesn't matter what EWOULDBLOCK is defined to because on Windows > MinGWs GCC doesn't define it at all, MSVC has it, but WinSock uses > it's own error codes anyway. Sorry, I don't follow. What were you trying to say or suggest here? > > > > +static ssize_t > > > > +emacs_gnutls_pull(gnutls_transport_ptr_t p, void* buf, size_t sz) > > > > > > Can we move the Windows-specific functions to w32.c, and only call > > > them from gnutls.c? I think we want to keep the Windows-related code > > > outside w32*.c to the bare minimum. > > > > OK. > > Maybe the GnuTLS specific stuff should also be kept to the bare > minimum outside of gnutls.c? What stuff did you have in mind? > Considering that these functions would have to be non-static in this > case to be accessible by gnutls.c. Sure, but I see no problem with that.