X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/e91caa6011949f45790cd131883b2b3b26d6a0a2..dbf312256d8a8c731dadaf27c1260832a3796350:/src/process.c diff --git a/src/process.c b/src/process.c index 058ad5f871..05c4be2755 100644 --- a/src/process.c +++ b/src/process.c @@ -54,16 +54,16 @@ along with GNU Emacs. If not, see . */ #endif #include -#if defined(HAVE_NET_IF_H) +#if defined (HAVE_NET_IF_H) #include #endif /* HAVE_NET_IF_H */ -#if defined(HAVE_IFADDRS_H) +#if defined (HAVE_IFADDRS_H) /* Must be after net/if.h */ #include /* We only use structs from this header when we use getifaddrs. */ -#if defined(HAVE_NET_IF_DL_H) +#if defined (HAVE_NET_IF_DL_H) #include #endif @@ -256,7 +256,7 @@ static void create_pty (Lisp_Object); /* If we support a window system, turn on the code to poll periodically to detect C-g. It isn't actually used when doing interrupt input. */ -#if defined(HAVE_WINDOW_SYSTEM) && !defined(USE_ASYNC_EVENTS) +#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS) #define POLL_FOR_INPUT #endif @@ -642,6 +642,9 @@ make_process (Lisp_Object name) p->gnutls_initstage = GNUTLS_STAGE_EMPTY; p->gnutls_log_level = 0; p->gnutls_p = 0; + p->gnutls_state = NULL; + p->gnutls_x509_cred = NULL; + p->gnutls_anon_cred = NULL; #endif /* If name is already in use, modify it until it is unused. */ @@ -1411,7 +1414,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) val = XCDR (Vdefault_process_coding_system); } XPROCESS (proc)->encode_coding_system = val; - /* Note: At this momemnt, the above coding system may leave + /* Note: At this moment, the above coding system may leave text-conversion or eol-conversion unspecified. They will be decided after we read output from the process and decode it by some coding system, or just before we actually send a text to @@ -2921,7 +2924,7 @@ usage: (make-network-process &rest ARGS) */) { /* Don't support network sockets when non-blocking mode is not available, since a blocked Emacs is not useful. */ -#if !defined(O_NONBLOCK) && !defined(O_NDELAY) +#if !defined (O_NONBLOCK) && !defined (O_NDELAY) error ("Network servers not supported"); #else is_server = 1; @@ -2975,7 +2978,7 @@ usage: (make-network-process &rest ARGS) */) tem = Fplist_get (contact, QCfamily); if (NILP (tem)) { -#if defined(HAVE_GETADDRINFO) && defined(AF_INET6) +#if defined (HAVE_GETADDRINFO) && defined (AF_INET6) family = AF_UNSPEC; #else family = AF_INET; @@ -3117,7 +3120,7 @@ usage: (make-network-process &rest ARGS) */) { struct hostent *host_info_ptr; - /* gethostbyname may fail with TRY_AGAIN, but we don't honour that, + /* gethostbyname may fail with TRY_AGAIN, but we don't honor that, as it may `hang' Emacs for a very long time. */ immediate_quit = 1; QUIT; @@ -3471,7 +3474,7 @@ usage: (make-network-process &rest ARGS) */) { /* Setup coding systems for communicating with the network stream. */ - struct gcpro inner_gcpro1; + struct gcpro gcpro1; /* Qt denotes we have not yet called Ffind_operation_coding_system. */ Lisp_Object coding_systems = Qt; Lisp_Object fargs[5], val; @@ -3499,9 +3502,9 @@ usage: (make-network-process &rest ARGS) */) { fargs[0] = Qopen_network_stream, fargs[1] = name, fargs[2] = buffer, fargs[3] = host, fargs[4] = service; - GCPRO1_VAR (proc, inner_gcpro); + GCPRO1 (proc); coding_systems = Ffind_operation_coding_system (5, fargs); - UNGCPRO_VAR (inner_gcpro); + UNGCPRO; } if (CONSP (coding_systems)) val = XCAR (coding_systems); @@ -3532,9 +3535,9 @@ usage: (make-network-process &rest ARGS) */) { fargs[0] = Qopen_network_stream, fargs[1] = name, fargs[2] = buffer, fargs[3] = host, fargs[4] = service; - GCPRO1_VAR (proc, inner_gcpro); + GCPRO1 (proc); coding_systems = Ffind_operation_coding_system (5, fargs); - UNGCPRO_VAR (inner_gcpro); + UNGCPRO; } } if (CONSP (coding_systems)) @@ -3560,7 +3563,7 @@ usage: (make-network-process &rest ARGS) */) } -#if defined(HAVE_NET_IF_H) +#if defined (HAVE_NET_IF_H) #ifdef SIOCGIFCONF DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 0, 0, @@ -3631,7 +3634,7 @@ format; see the description of ADDRESS in `make-network-process'. */) } #endif /* SIOCGIFCONF */ -#if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS) +#if defined (SIOCGIFADDR) || defined (SIOCGIFHWADDR) || defined (SIOCGIFFLAGS) struct ifflag_def { int flag_bit; @@ -3714,7 +3717,7 @@ DEFUN ("network-interface-info", Fnetwork_interface_info, Snetwork_interface_inf doc: /* Return information about network interface named IFNAME. The return value is a list (ADDR BCAST NETMASK HWADDR FLAGS), where ADDR is the layer 3 address, BCAST is the layer 3 broadcast address, -NETMASK is the layer 3 network mask, HWADDR is the layer 2 addres, and +NETMASK is the layer 3 network mask, HWADDR is the layer 2 address, and FLAGS is the current flags of the interface. */) (Lisp_Object ifname) { @@ -3738,7 +3741,7 @@ FLAGS is the current flags of the interface. */) return Qnil; elt = Qnil; -#if defined(SIOCGIFFLAGS) && defined(HAVE_STRUCT_IFREQ_IFR_FLAGS) +#if defined (SIOCGIFFLAGS) && defined (HAVE_STRUCT_IFREQ_IFR_FLAGS) if (ioctl (s, SIOCGIFFLAGS, &rq) == 0) { int flags = rq.ifr_flags; @@ -3772,7 +3775,7 @@ FLAGS is the current flags of the interface. */) res = Fcons (elt, res); elt = Qnil; -#if defined(SIOCGIFHWADDR) && defined(HAVE_STRUCT_IFREQ_IFR_HWADDR) +#if defined (SIOCGIFHWADDR) && defined (HAVE_STRUCT_IFREQ_IFR_HWADDR) if (ioctl (s, SIOCGIFHWADDR, &rq) == 0) { Lisp_Object hwaddr = Fmake_vector (make_number (6), Qnil); @@ -3784,7 +3787,7 @@ FLAGS is the current flags of the interface. */) p->contents[n] = make_number (((unsigned char *)&rq.ifr_hwaddr.sa_data[0])[n]); elt = Fcons (make_number (rq.ifr_hwaddr.sa_family), hwaddr); } -#elif defined(HAVE_GETIFADDRS) && defined(LLADDR) +#elif defined (HAVE_GETIFADDRS) && defined (LLADDR) if (getifaddrs (&ifap) != -1) { Lisp_Object hwaddr = Fmake_vector (make_number (6), Qnil); @@ -3802,7 +3805,7 @@ FLAGS is the current flags of the interface. */) || sdl->sdl_alen != 6) continue; - memcpy (linkaddr, LLADDR(sdl), sdl->sdl_alen); + memcpy (linkaddr, LLADDR (sdl), sdl->sdl_alen); for (n = 0; n < 6; n++) p->contents[n] = make_number (linkaddr[n]); @@ -3819,7 +3822,7 @@ FLAGS is the current flags of the interface. */) res = Fcons (elt, res); elt = Qnil; -#if defined(SIOCGIFNETMASK) && (defined(HAVE_STRUCT_IFREQ_IFR_NETMASK) || defined(HAVE_STRUCT_IFREQ_IFR_ADDR)) +#if defined (SIOCGIFNETMASK) && (defined (HAVE_STRUCT_IFREQ_IFR_NETMASK) || defined (HAVE_STRUCT_IFREQ_IFR_ADDR)) if (ioctl (s, SIOCGIFNETMASK, &rq) == 0) { any = 1; @@ -3833,7 +3836,7 @@ FLAGS is the current flags of the interface. */) res = Fcons (elt, res); elt = Qnil; -#if defined(SIOCGIFBRDADDR) && defined(HAVE_STRUCT_IFREQ_IFR_BROADADDR) +#if defined (SIOCGIFBRDADDR) && defined (HAVE_STRUCT_IFREQ_IFR_BROADADDR) if (ioctl (s, SIOCGIFBRDADDR, &rq) == 0) { any = 1; @@ -3843,7 +3846,7 @@ FLAGS is the current flags of the interface. */) res = Fcons (elt, res); elt = Qnil; -#if defined(SIOCGIFADDR) && defined(HAVE_STRUCT_IFREQ_IFR_ADDR) +#if defined (SIOCGIFADDR) && defined (HAVE_STRUCT_IFREQ_IFR_ADDR) if (ioctl (s, SIOCGIFADDR, &rq) == 0) { any = 1; @@ -3857,7 +3860,7 @@ FLAGS is the current flags of the interface. */) return any ? res : Qnil; } #endif -#endif /* defined(HAVE_NET_IF_H) */ +#endif /* defined (HAVE_NET_IF_H) */ /* Turn off input and output for process PROC. */ @@ -3867,6 +3870,11 @@ deactivate_process (Lisp_Object proc) register int inchannel, outchannel; register struct Lisp_Process *p = XPROCESS (proc); +#ifdef HAVE_GNUTLS + /* Delete GnuTLS structures in PROC, if any. */ + emacs_gnutls_deinit (proc); +#endif /* HAVE_GNUTLS */ + inchannel = p->infd; outchannel = p->outfd; @@ -4612,15 +4620,46 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd, some data in the TCP buffers so that select works, but with custom pull/push functions we need to check if some data is available in the buffers manually. */ - if (nfds == 0 && - wait_proc && wait_proc->gnutls_p /* Check for valid process. */ - /* Do we have pending data? */ - && emacs_gnutls_record_check_pending (wait_proc->gnutls_state) > 0) - { - nfds = 1; - /* Set to Available. */ - FD_SET (wait_proc->infd, &Available); - } + if (nfds == 0) + { + if (! wait_proc) + { + /* We're not waiting on a specific process, so loop + through all the channels and check for data. + This is a workaround needed for some versions of + the gnutls library -- 2.12.14 has been confirmed + to need it. See + http://comments.gmane.org/gmane.emacs.devel/145074 */ + for (channel = 0; channel < MAXDESC; ++channel) + if (! NILP (chan_process[channel])) + { + struct Lisp_Process *p = + XPROCESS (chan_process[channel]); + if (p && p->gnutls_p && p->infd + && ((emacs_gnutls_record_check_pending + (p->gnutls_state)) + > 0)) + { + nfds++; + FD_SET (p->infd, &Available); + } + } + } + else + { + /* Check this specific channel. */ + if (wait_proc->gnutls_p /* Check for valid process. */ + /* Do we have pending data? */ + && ((emacs_gnutls_record_check_pending + (wait_proc->gnutls_state)) + > 0)) + { + nfds = 1; + /* Set to Available. */ + FD_SET (wait_proc->infd, &Available); + } + } + } #endif } @@ -4848,16 +4887,11 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd, It can't hurt. */ else if (nread == -1 && errno == EIO) { - /* Clear the descriptor now, so we only raise the - signal once. Don't do this if `process' is only - a pty. */ - if (XPROCESS (proc)->pid != -2) - { - FD_CLR (channel, &input_wait_mask); - FD_CLR (channel, &non_keyboard_wait_mask); + /* Clear the descriptor now, so we only raise the signal once. */ + FD_CLR (channel, &input_wait_mask); + FD_CLR (channel, &non_keyboard_wait_mask); - kill (getpid (), SIGCHLD); - } + kill (getpid (), SIGCHLD); } #endif /* HAVE_PTYS */ /* If we can detect process termination, don't consider the process @@ -5374,8 +5408,8 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, sending a multibyte text, thus we must encode it by the original coding system specified for the current process. - Another reason we comming here is that the coding system - was just complemented and new one was returned by + Another reason we come here is that the coding system + was just complemented and a new one was returned by complement_process_encoding_system. */ setup_coding_system (p->encode_coding_system, coding); Vlast_coding_system_used = p->encode_coding_system; @@ -5384,6 +5418,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, } else { + coding->src_multibyte = 0; /* For sending a unibyte text, character code conversion should not take place but EOL conversion should. So, setup raw-text or one of the subsidiary if we have not yet done it. */ @@ -7280,7 +7315,7 @@ init_process (void) #ifdef HAVE_GETSOCKNAME ADD_SUBFEATURE (QCservice, Qt); #endif -#if defined(O_NONBLOCK) || defined(O_NDELAY) +#if defined (O_NONBLOCK) || defined (O_NDELAY) ADD_SUBFEATURE (QCserver, Qt); #endif @@ -7472,14 +7507,14 @@ The variable takes effect when `start-process' is called. */); defsubr (&Sset_network_process_option); defsubr (&Smake_network_process); defsubr (&Sformat_network_address); -#if defined(HAVE_NET_IF_H) +#if defined (HAVE_NET_IF_H) #ifdef SIOCGIFCONF defsubr (&Snetwork_interface_list); #endif -#if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS) +#if defined (SIOCGIFADDR) || defined (SIOCGIFHWADDR) || defined (SIOCGIFFLAGS) defsubr (&Snetwork_interface_info); #endif -#endif /* defined(HAVE_NET_IF_H) */ +#endif /* defined (HAVE_NET_IF_H) */ #ifdef DATAGRAM_SOCKETS defsubr (&Sprocess_datagram_address); defsubr (&Sset_process_datagram_address);