aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2018-07-22 13:39:10 +0200
committerNoam Postavsky2018-08-08 19:30:50 -0400
commit18588bce36617179cc7c8af74a6197c8e16819ea (patch)
tree68b05b7913d46d76bccdf9c19f8f42d6f5d20024 /src
parent5afbf62674e741b06c01216fe37a5439e9d42307 (diff)
downloademacs-18588bce36617179cc7c8af74a6197c8e16819ea.tar.gz
emacs-18588bce36617179cc7c8af74a6197c8e16819ea.zip
Make async :family 'local failures fail correctly again
* src/fileio.c (get_file_errno_data): Refactor out into its own function so that we can reuse the error handling from an async context (bug#31901). * src/process.c (connect_network_socket): When an async :family 'local client fails (with a file error, for instance), mark the process as failed. (cherry picked from commit 92ba34d89ac4f5b5bbb818e1c39a3cc12a405790)
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c18
-rw-r--r--src/lisp.h1
-rw-r--r--src/process.c16
3 files changed, 25 insertions, 10 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 9dbe3ad788e..e2be7fe2c69 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -195,8 +195,8 @@ check_writable (const char *filename, int amode)
195 list before reporting it; this saves report_file_errno's caller the 195 list before reporting it; this saves report_file_errno's caller the
196 trouble of preserving errno before calling list1. */ 196 trouble of preserving errno before calling list1. */
197 197
198void 198Lisp_Object
199report_file_errno (char const *string, Lisp_Object name, int errorno) 199get_file_errno_data (char const *string, Lisp_Object name, int errorno)
200{ 200{
201 Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name); 201 Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
202 char *str = emacs_strerror (errorno); 202 char *str = emacs_strerror (errorno);
@@ -206,10 +206,18 @@ report_file_errno (char const *string, Lisp_Object name, int errorno)
206 Lisp_Object errdata = Fcons (errstring, data); 206 Lisp_Object errdata = Fcons (errstring, data);
207 207
208 if (errorno == EEXIST) 208 if (errorno == EEXIST)
209 xsignal (Qfile_already_exists, errdata); 209 return Fcons (Qfile_already_exists, errdata);
210 else 210 else
211 xsignal (errorno == ENOENT ? Qfile_missing : Qfile_error, 211 return Fcons (errorno == ENOENT ? Qfile_missing : Qfile_error,
212 Fcons (build_string (string), errdata)); 212 Fcons (build_string (string), errdata));
213}
214
215void
216report_file_errno (char const *string, Lisp_Object name, int errorno)
217{
218 Lisp_Object data = get_file_errno_data (string, name, errorno);
219
220 xsignal (Fcar (data), Fcdr (data));
213} 221}
214 222
215/* Signal a file-access failure that set errno. STRING describes the 223/* Signal a file-access failure that set errno. STRING describes the
diff --git a/src/lisp.h b/src/lisp.h
index b2449cb87d3..05d1cd8201a 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4031,6 +4031,7 @@ extern Lisp_Object write_region (Lisp_Object, Lisp_Object, Lisp_Object,
4031extern void close_file_unwind (int); 4031extern void close_file_unwind (int);
4032extern void fclose_unwind (void *); 4032extern void fclose_unwind (void *);
4033extern void restore_point_unwind (Lisp_Object); 4033extern void restore_point_unwind (Lisp_Object);
4034extern Lisp_Object get_file_errno_data (const char *, Lisp_Object, int);
4034extern _Noreturn void report_file_errno (const char *, Lisp_Object, int); 4035extern _Noreturn void report_file_errno (const char *, Lisp_Object, int);
4035extern _Noreturn void report_file_error (const char *, Lisp_Object); 4036extern _Noreturn void report_file_error (const char *, Lisp_Object);
4036extern _Noreturn void report_file_notify_error (const char *, Lisp_Object); 4037extern _Noreturn void report_file_notify_error (const char *, Lisp_Object);
diff --git a/src/process.c b/src/process.c
index 8629f834e79..676f38446e4 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3578,17 +3578,23 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3578 3578
3579 if (s < 0) 3579 if (s < 0)
3580 { 3580 {
3581 const char *err = (p->is_server
3582 ? "make server process failed"
3583 : "make client process failed");
3584
3581 /* If non-blocking got this far - and failed - assume non-blocking is 3585 /* If non-blocking got this far - and failed - assume non-blocking is
3582 not supported after all. This is probably a wrong assumption, but 3586 not supported after all. This is probably a wrong assumption, but
3583 the normal blocking calls to open-network-stream handles this error 3587 the normal blocking calls to open-network-stream handles this error
3584 better. */ 3588 better. */
3585 if (p->is_non_blocking_client) 3589 if (p->is_non_blocking_client)
3586 return; 3590 {
3591 Lisp_Object data = get_file_errno_data (err, contact, xerrno);
3592
3593 pset_status (p, list2 (Fcar (data), Fcdr (data)));
3594 return;
3595 }
3587 3596
3588 report_file_errno ((p->is_server 3597 report_file_errno (err, contact, xerrno);
3589 ? "make server process failed"
3590 : "make client process failed"),
3591 contact, xerrno);
3592 } 3598 }
3593 3599
3594 inch = s; 3600 inch = s;