From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kyotaro HORIGUCHI Newsgroups: gmane.emacs.devel Subject: make-network-process(:nowait t) on MS-Windows Date: Fri, 25 Nov 2005 00:26:40 +0900 (JST) Message-ID: <20051125.002640.103856392.horiguti@horiguti.meadowy.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1132851330 31711 80.91.229.2 (24 Nov 2005 16:55:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 24 Nov 2005 16:55:30 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 24 17:55:21 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EfKMi-0001G9-UG for ged-emacs-devel@m.gmane.org; Thu, 24 Nov 2005 17:54:33 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EfKMh-0000df-RO for ged-emacs-devel@m.gmane.org; Thu, 24 Nov 2005 11:54:32 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EfJ0O-0002aQ-FI for emacs-devel@gnu.org; Thu, 24 Nov 2005 10:27:24 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EfJ0M-0002UB-B4 for emacs-devel@gnu.org; Thu, 24 Nov 2005 10:27:23 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EfJ0L-0002RM-Bx for emacs-devel@gnu.org; Thu, 24 Nov 2005 10:27:21 -0500 Original-Received: from [202.224.39.197] (helo=mail.asahi-net.or.jp) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EfJ0L-0007co-5Z for emacs-devel@gnu.org; Thu, 24 Nov 2005 10:27:21 -0500 Original-Received: from localhost (g052188.ppp.asahi-net.or.jp [211.132.52.188]) by mail.asahi-net.or.jp (Postfix) with ESMTP id D86BE258AB; Fri, 25 Nov 2005 00:26:42 +0900 (JST) Original-To: emacs-devel@gnu.org 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:46518 Archived-At: make-network-process with parameter `:nowait t' returns nil instead of process when evaluating the sample lisp code below on MS-Windows. It seems to have worked once, but does not now. http://lists.gnu.org/archive/html/emacs-devel/2002-05/msg00147.html The following patch make this work again. -- Kyotaro HORIGUCHI ==== sample lisp code (defun my-filter (pro string) (goto-char (point-max)) (insert "FIL: " string)) (defun my-sentinel (pro string) (goto-char (point-max)) (insert "SEN: " string)) (make-network-process :name "foo" :buffer (current-buffer) :host "localhost" :service "smtp" :nowait t :filter 'my-filter :sentinel 'my-sentinel) ==== patch to make make-network-process work. Index: w32.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/w32.c,v retrieving revision 1.97 diff -r1.97 w32.c 154a155,160 > typedef struct { > unsigned int fd_count; > SOCKET fd_array[FD_SETSIZE]; > } pfn_fd_set; > > 2697a2704 > int (PASCAL *pfn_select) (int nfds, pfn_fd_set *readfds, pfn_fd_set *writefds, pfn_fd_set *excepfds, const struct timeval *timeout); 2779a2787 > LOAD_PROC( select ); 2853a2862 > case WSAEWOULDBLOCK: h_errno = EINPROGRESS; break; 3137a3147,3211 > } > > int > sys_select_socket (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) > { > int i, j, k, rc, cfds; > pfn_fd_set *fds[3]; > fd_set *efds[3]; > > if (winsock_lib == NULL) > { > h_errno = ENOTSOCK; > return SOCKET_ERROR; > } > > check_errno (); > > cfds = 0; > efds[0] = readfds; > efds[1] = writefds; > efds[2] = exceptfds; > > for (i = 0 ; i < 3 ; i++) > { > fds[i] = NULL; > if (efds[i]) > { > fds[i] = (pfn_fd_set*)alloca (sizeof (pfn_fd_set)); > fds[i]->fd_count = 0; > for (j = 0 ; j < nfds ; j++) > if (FD_ISSET (j, efds[i])) > { > if (! (fd_info[j].flags & FILE_SOCKET)) > { > h_errno = ENOTSOCK; > return SOCKET_ERROR; > } > > fds[i]->fd_array[fds[i]->fd_count++] = SOCK_HANDLE (j); > cfds++; > } > FD_ZERO (efds[i]); > } > } > > if (cfds == 0) > return 0; > > rc = pfn_select (nfds, fds[0], fds[1], fds[2], timeout); > > if (rc > 0) > for (i = 0 ; i < 3 ; i++) > if (fds[i]) > for (j = 0 ; j < fds[i]->fd_count ; j++) > { > for (k = 0 ; > k < nfds && fds[i]->fd_array [j] != SOCK_HANDLE (k) ; > k++); > if (k < nfds) > FD_SET (k, efds[i]); > } > > if (rc == SOCKET_ERROR) > set_errno (); > return rc; Index: w32proc.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/w32proc.c,v retrieving revision 1.65 diff -r1.65 w32proc.c 1058c1058 < int i, nh, nc, nr; --- > int i, nh, nc, nr, nw; 1074c1074 < if (rfds == NULL || wfds != NULL || efds != NULL) --- > if ((rfds == NULL && wfds == NULL) || efds != NULL) 1082a1083 > nw = 0; 1186a1188,1198 > if (wfds) > { > /* Assume this socket is waiting for connection of > non-blocking socket. */ > struct timeval tm = {0, 0}; > nw = sys_select_socket (nfds, NULL, wfds, NULL, &tm); > > if (nw < 0) > return nw; > } > 1327a1340 > nr += nw;