aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2018-07-22 13:39:10 +0200
committerLars Ingebrigtsen2018-07-22 13:39:10 +0200
commit92ba34d89ac4f5b5bbb818e1c39a3cc12a405790 (patch)
tree0f3234e5ad986089c061a9402663b8533647db82 /src
parente23727978dbb07d68f730ffa60b22d59d065850e (diff)
downloademacs-92ba34d89ac4f5b5bbb818e1c39a3cc12a405790.tar.gz
emacs-92ba34d89ac4f5b5bbb818e1c39a3cc12a405790.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.
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 39789e55ff5..b92492c93a6 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -196,8 +196,8 @@ check_writable (const char *filename, int amode)
196 list before reporting it; this saves report_file_errno's caller the 196 list before reporting it; this saves report_file_errno's caller the
197 trouble of preserving errno before calling list1. */ 197 trouble of preserving errno before calling list1. */
198 198
199void 199Lisp_Object
200report_file_errno (char const *string, Lisp_Object name, int errorno) 200get_file_errno_data (char const *string, Lisp_Object name, int errorno)
201{ 201{
202 Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name); 202 Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
203 char *str = emacs_strerror (errorno); 203 char *str = emacs_strerror (errorno);
@@ -207,10 +207,18 @@ report_file_errno (char const *string, Lisp_Object name, int errorno)
207 Lisp_Object errdata = Fcons (errstring, data); 207 Lisp_Object errdata = Fcons (errstring, data);
208 208
209 if (errorno == EEXIST) 209 if (errorno == EEXIST)
210 xsignal (Qfile_already_exists, errdata); 210 return Fcons (Qfile_already_exists, errdata);
211 else 211 else
212 xsignal (errorno == ENOENT ? Qfile_missing : Qfile_error, 212 return Fcons (errorno == ENOENT ? Qfile_missing : Qfile_error,
213 Fcons (build_string (string), errdata)); 213 Fcons (build_string (string), errdata));
214}
215
216void
217report_file_errno (char const *string, Lisp_Object name, int errorno)
218{
219 Lisp_Object data = get_file_errno_data (string, name, errorno);
220
221 xsignal (Fcar (data), Fcdr (data));
214} 222}
215 223
216/* Signal a file-access failure that set errno. STRING describes the 224/* Signal a file-access failure that set errno. STRING describes the
diff --git a/src/lisp.h b/src/lisp.h
index 731a45da11a..8ddd363d2dd 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4015,6 +4015,7 @@ extern Lisp_Object write_region (Lisp_Object, Lisp_Object, Lisp_Object,
4015extern void close_file_unwind (int); 4015extern void close_file_unwind (int);
4016extern void fclose_unwind (void *); 4016extern void fclose_unwind (void *);
4017extern void restore_point_unwind (Lisp_Object); 4017extern void restore_point_unwind (Lisp_Object);
4018extern Lisp_Object get_file_errno_data (const char *, Lisp_Object, int);
4018extern _Noreturn void report_file_errno (const char *, Lisp_Object, int); 4019extern _Noreturn void report_file_errno (const char *, Lisp_Object, int);
4019extern _Noreturn void report_file_error (const char *, Lisp_Object); 4020extern _Noreturn void report_file_error (const char *, Lisp_Object);
4020extern _Noreturn void report_file_notify_error (const char *, Lisp_Object); 4021extern _Noreturn void report_file_notify_error (const char *, Lisp_Object);
diff --git a/src/process.c b/src/process.c
index 06324641346..aafb46c3615 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3587,17 +3587,23 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3587 3587
3588 if (s < 0) 3588 if (s < 0)
3589 { 3589 {
3590 const char *err = (p->is_server
3591 ? "make server process failed"
3592 : "make client process failed");
3593
3590 /* If non-blocking got this far - and failed - assume non-blocking is 3594 /* If non-blocking got this far - and failed - assume non-blocking is
3591 not supported after all. This is probably a wrong assumption, but 3595 not supported after all. This is probably a wrong assumption, but
3592 the normal blocking calls to open-network-stream handles this error 3596 the normal blocking calls to open-network-stream handles this error
3593 better. */ 3597 better. */
3594 if (p->is_non_blocking_client) 3598 if (p->is_non_blocking_client)
3595 return; 3599 {
3600 Lisp_Object data = get_file_errno_data (err, contact, xerrno);
3601
3602 pset_status (p, list2 (Fcar (data), Fcdr (data)));
3603 return;
3604 }
3596 3605
3597 report_file_errno ((p->is_server 3606 report_file_errno (err, contact, xerrno);
3598 ? "make server process failed"
3599 : "make client process failed"),
3600 contact, xerrno);
3601 } 3607 }
3602 3608
3603 inch = s; 3609 inch = s;