mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-08 08:43:52 -08:00
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 92ba34d89a)
This commit is contained in:
parent
5afbf62674
commit
18588bce36
3 changed files with 25 additions and 10 deletions
18
src/fileio.c
18
src/fileio.c
|
|
@ -195,8 +195,8 @@ check_writable (const char *filename, int amode)
|
||||||
list before reporting it; this saves report_file_errno's caller the
|
list before reporting it; this saves report_file_errno's caller the
|
||||||
trouble of preserving errno before calling list1. */
|
trouble of preserving errno before calling list1. */
|
||||||
|
|
||||||
void
|
Lisp_Object
|
||||||
report_file_errno (char const *string, Lisp_Object name, int errorno)
|
get_file_errno_data (char const *string, Lisp_Object name, int errorno)
|
||||||
{
|
{
|
||||||
Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
|
Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
|
||||||
char *str = emacs_strerror (errorno);
|
char *str = emacs_strerror (errorno);
|
||||||
|
|
@ -206,10 +206,18 @@ report_file_errno (char const *string, Lisp_Object name, int errorno)
|
||||||
Lisp_Object errdata = Fcons (errstring, data);
|
Lisp_Object errdata = Fcons (errstring, data);
|
||||||
|
|
||||||
if (errorno == EEXIST)
|
if (errorno == EEXIST)
|
||||||
xsignal (Qfile_already_exists, errdata);
|
return Fcons (Qfile_already_exists, errdata);
|
||||||
else
|
else
|
||||||
xsignal (errorno == ENOENT ? Qfile_missing : Qfile_error,
|
return Fcons (errorno == ENOENT ? Qfile_missing : Qfile_error,
|
||||||
Fcons (build_string (string), errdata));
|
Fcons (build_string (string), errdata));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
report_file_errno (char const *string, Lisp_Object name, int errorno)
|
||||||
|
{
|
||||||
|
Lisp_Object data = get_file_errno_data (string, name, errorno);
|
||||||
|
|
||||||
|
xsignal (Fcar (data), Fcdr (data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Signal a file-access failure that set errno. STRING describes the
|
/* Signal a file-access failure that set errno. STRING describes the
|
||||||
|
|
|
||||||
|
|
@ -4031,6 +4031,7 @@ extern Lisp_Object write_region (Lisp_Object, Lisp_Object, Lisp_Object,
|
||||||
extern void close_file_unwind (int);
|
extern void close_file_unwind (int);
|
||||||
extern void fclose_unwind (void *);
|
extern void fclose_unwind (void *);
|
||||||
extern void restore_point_unwind (Lisp_Object);
|
extern void restore_point_unwind (Lisp_Object);
|
||||||
|
extern Lisp_Object get_file_errno_data (const char *, Lisp_Object, int);
|
||||||
extern _Noreturn void report_file_errno (const char *, Lisp_Object, int);
|
extern _Noreturn void report_file_errno (const char *, Lisp_Object, int);
|
||||||
extern _Noreturn void report_file_error (const char *, Lisp_Object);
|
extern _Noreturn void report_file_error (const char *, Lisp_Object);
|
||||||
extern _Noreturn void report_file_notify_error (const char *, Lisp_Object);
|
extern _Noreturn void report_file_notify_error (const char *, Lisp_Object);
|
||||||
|
|
|
||||||
|
|
@ -3578,17 +3578,23 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
|
||||||
|
|
||||||
if (s < 0)
|
if (s < 0)
|
||||||
{
|
{
|
||||||
|
const char *err = (p->is_server
|
||||||
|
? "make server process failed"
|
||||||
|
: "make client process failed");
|
||||||
|
|
||||||
/* If non-blocking got this far - and failed - assume non-blocking is
|
/* If non-blocking got this far - and failed - assume non-blocking is
|
||||||
not supported after all. This is probably a wrong assumption, but
|
not supported after all. This is probably a wrong assumption, but
|
||||||
the normal blocking calls to open-network-stream handles this error
|
the normal blocking calls to open-network-stream handles this error
|
||||||
better. */
|
better. */
|
||||||
if (p->is_non_blocking_client)
|
if (p->is_non_blocking_client)
|
||||||
return;
|
{
|
||||||
|
Lisp_Object data = get_file_errno_data (err, contact, xerrno);
|
||||||
|
|
||||||
report_file_errno ((p->is_server
|
pset_status (p, list2 (Fcar (data), Fcdr (data)));
|
||||||
? "make server process failed"
|
return;
|
||||||
: "make client process failed"),
|
}
|
||||||
contact, xerrno);
|
|
||||||
|
report_file_errno (err, contact, xerrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
inch = s;
|
inch = s;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue