dtfile: a mount no longer freezes the window; Connecting dialog, Cancel, Dtfile*connectTimeout (t0080 item 4)
mcde_sys_net_mount ran in the Xt callback and waited for sshfs/mount_afp without a limit: a server that is gone froze the window for as long as the tool lived (measured: the call returns after 20.0 s with a tool that sleeps 20 s; with one that never ends, never). McdeSys: mcde_sys_net_mount_start/_job_fd/_job_finish/_job_cancel. The tool runs under a runner process (its own process group) that writes the answer to a pipe: dtfile sets SIGCHLD to SIG_IGN (Main.c), where waitpid gives no status. mcde_sys_net_mount and _start share one plan (MountPlanFor). test_job (make check, 5 of 5 pass) covers success, failure, a missing tool, a password on stdin, and cancel with the tool AND what it started gone, with SIGCHLD default and ignored; without the group kill it fails (mutant run). dtfile: _McdeNetMount (NetView.c) for all three mounts (network view, Connect to Server, column view): a modal "Connecting ..." dialog with Cancel (also close button and Escape), the descriptor as Xt input (no timer polling), one time-out, Dtfile*connectTimeout, 20 s, 3..600 (app-defaults, man page). Measured (real dtfile on Xvfb, fake sshfs that sleeps 40 s, connectTimeout 4): the dialog shows and repaints when moved; the time-out gives "Could not connect: The server did not answer within 4 seconds.", Escape gives "Could not connect: Cancelled."; sleep processes while connecting 1, after the time-out 0, after Escape 0; no dialog left. One first run showed a 40 s stall of the whole session after Return (import blocked too); not reproduced in three further runs, cause unknown. Cross compile for NetBSD (x86_64--netbsd-gcc, the build's flags): netmount.c and NetView.c without a warning; common.c's old settimeofday declaration warning is not new. Not done: the NFS and AFP tools (only sshfs was faked), the afp://10.255.255.1/ case of the task with a real mount_afp. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
14a25a4ac2
commit
cc770d000e
14 files changed
+562
-39
No files matched your search
@@ -539,8 +539,8 @@ ColumnChosen(Widget w, XtPointer client, XtPointer call)
|
||||
(void)snprintf(mp, sizeof mp, "%s/%s/%s",
|
||||
NetRoot(), host, wins[k].col[ci].names[entry]);
|
||||
(void)mkdir(mp, 0755);
|
||||
if (mcde_sys_net_mount(url, mp, NULL) == MCDE_SYS_OK &&
|
||||
IsDir(mp)) {
|
||||
if (_McdeNetMount(rec->shell, url, mp, NULL) ==
|
||||
MCDE_SYS_OK && IsDir(mp)) {
|
||||
while (wins[k].ncol > ci + 1)
|
||||
FreeColumn(&wins[k].col[--wins[k].ncol]);
|
||||
Preview(k, mp);
|
||||
|
||||
@@ -277,7 +277,8 @@ ConnectNow(Widget w, XtPointer client, XtPointer call)
|
||||
}
|
||||
Normalise(text, url, sizeof url);
|
||||
XtFree(text);
|
||||
if (_McdeNetConnectAddress(url, mp, sizeof mp, err, sizeof err)) {
|
||||
if (_McdeNetConnectAddress(conn.shell, url, mp, sizeof mp, err,
|
||||
sizeof err)) {
|
||||
RecentAdd(url);
|
||||
XtPopdown(conn.shell);
|
||||
if (conn.rec != NULL)
|
||||
|
||||
@@ -16,8 +16,8 @@ extern void _McdeConnectShow(FileMgrRec *rec);
|
||||
|
||||
/* the address MOUNTED through the system layer: 1 with MP (the mount point)
|
||||
* and an empty ERR, 0 with ERR the reason. NetView.c knows the parse and
|
||||
* the mount. */
|
||||
extern int _McdeNetConnectAddress(const char *url, char *mp, size_t mplen,
|
||||
char *err, size_t errlen);
|
||||
* the mount; PARENT is the window the "Connecting ..." dialog stands over. */
|
||||
extern int _McdeNetConnectAddress(Widget parent, const char *url, char *mp,
|
||||
size_t mplen, char *err, size_t errlen);
|
||||
|
||||
#endif /* _Connect_h */
|
||||
@@ -25,6 +25,7 @@ Dtfile*searchPath: DT/Dtfile
|
||||
|
||||
Dtfile*promptUser: True
|
||||
Dtfile*moveThreshold: 10
|
||||
Dtfile*connectTimeout: 20
|
||||
Dtfile*showEmptySet: True
|
||||
|
||||
Dtfile*filter_files*file_name_text.columns: %|nls-13-#30#|
|
||||
|
||||
@@ -31,6 +31,12 @@ extern char *_McdeColumnsChosen(FileMgrRec *rec);
|
||||
/* the network view (NetView.c) */
|
||||
extern void _McdeNetCreate(FileMgrRec *rec, Widget parent, Widget work);
|
||||
extern void _McdeNetShow(FileMgrRec *rec, Boolean on);
|
||||
/* connect URL to the folder MP as mcde_sys_net_mount does (McdeSys), with the
|
||||
* window drawing meanwhile: a modal "Connecting ..." dialog with Cancel over
|
||||
* PARENT, ended by Cancel or Dtfile*connectTimeout; MCDE_SYS_OK or a failure
|
||||
* with mcde_sys_error() (NetView.c) */
|
||||
extern int _McdeNetMount(Widget parent, const char *url, const char *mp,
|
||||
const char *password);
|
||||
/* "Connect to Server": shows the network view with the address field, as
|
||||
* Command+K asks for it */
|
||||
extern void _McdeNetConnect(FileMgrRec *rec);
|
||||
|
||||
+151
-7
@@ -14,10 +14,14 @@
|
||||
* terminal by SSH, its NFS exports, its SMB shares (listed; this
|
||||
* computer cannot open them yet).
|
||||
*
|
||||
* Connecting mounts the share on ~/Network/HOST[/NAME] (mcde_sys_net_mount)
|
||||
* and opens that folder in the window: the view goes back to the icons and
|
||||
* Connecting mounts the share on ~/Network/HOST[/NAME] (_McdeNetMount) and
|
||||
* opens that folder in the window: the view goes back to the icons and
|
||||
* dtfile goes there (_McdeNavGoTo). When the server wants a password, a
|
||||
* dialog asks for it (the field shows stars) and the mount is tried again.
|
||||
* A server that is gone keeps the mount tool busy for minutes: the mount
|
||||
* runs as a job (McdeSys), a dialog "Connecting ..." with Cancel stands in
|
||||
* front of the window, which goes on drawing, and the time-out is the
|
||||
* resource Dtfile*connectTimeout (seconds, 20).
|
||||
* Finding the computers takes a few seconds: it runs after the view is
|
||||
* drawn.
|
||||
*
|
||||
@@ -39,6 +43,7 @@
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/List.h>
|
||||
#include <Xm/MessageB.h>
|
||||
#include <Xm/Protocols.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/SelectioB.h>
|
||||
@@ -176,6 +181,145 @@ Mounted(const char *path)
|
||||
a.st_dev != b.st_dev;
|
||||
}
|
||||
|
||||
/* ---- the mount, without freezing the window ------------------------------ */
|
||||
|
||||
#define CONNECT_SECONDS 20
|
||||
#define CONNECT_SECONDS_MIN 3
|
||||
#define CONNECT_SECONDS_MAX 600
|
||||
|
||||
typedef struct {
|
||||
Boolean done; /* leave the loop */
|
||||
Boolean ended; /* the tool has ended: its answer is there */
|
||||
Boolean cancelled; /* the user said Cancel */
|
||||
XtInputId input;
|
||||
XtIntervalId timer;
|
||||
} MountWait;
|
||||
|
||||
static void
|
||||
WaitInput(XtPointer client, int *source, XtInputId *id)
|
||||
{
|
||||
MountWait *w = (MountWait *) client;
|
||||
|
||||
(void) source;
|
||||
XtRemoveInput(*id); /* it stays readable: once is enough */
|
||||
w->input = 0;
|
||||
w->ended = True;
|
||||
w->done = True;
|
||||
}
|
||||
|
||||
static void
|
||||
WaitTimer(XtPointer client, XtIntervalId *id)
|
||||
{
|
||||
MountWait *w = (MountWait *) client;
|
||||
|
||||
(void) id;
|
||||
w->timer = 0;
|
||||
w->done = True;
|
||||
}
|
||||
|
||||
static void
|
||||
WaitCancel(Widget wid, XtPointer client, XtPointer call)
|
||||
{
|
||||
MountWait *w = (MountWait *) client;
|
||||
|
||||
(void) wid;
|
||||
(void) call;
|
||||
w->cancelled = True;
|
||||
w->done = True;
|
||||
}
|
||||
|
||||
/* Dtfile*connectTimeout, in seconds; a value that is no number or lies
|
||||
* outside 3 to 600 is the default (resources: the pattern of File.c) */
|
||||
static int
|
||||
ConnectSeconds(Widget w)
|
||||
{
|
||||
Display *dpy = XtDisplay(w);
|
||||
String name, cls;
|
||||
char nm[128], cl[128], *type, *end;
|
||||
XrmValue v;
|
||||
long n;
|
||||
|
||||
XtGetApplicationNameAndClass(dpy, &name, &cls);
|
||||
(void) snprintf(nm, sizeof nm, "%s.connectTimeout", name);
|
||||
(void) snprintf(cl, sizeof cl, "%s.ConnectTimeout", cls);
|
||||
if (!XrmGetResource(XrmGetDatabase(dpy), nm, cl, &type, &v) ||
|
||||
v.addr == NULL)
|
||||
return CONNECT_SECONDS;
|
||||
n = strtol(v.addr, &end, 10);
|
||||
if (end == v.addr || *end != '\0' || n < CONNECT_SECONDS_MIN ||
|
||||
n > CONNECT_SECONDS_MAX)
|
||||
return CONNECT_SECONDS;
|
||||
return (int) n;
|
||||
}
|
||||
|
||||
/*
|
||||
* What mcde_sys_net_mount does, with the window drawing meanwhile: the mount
|
||||
* is a job; a modal "Connecting ..." dialog with Cancel (also the close
|
||||
* button and Escape) stands over PARENT, and the events are processed until
|
||||
* the tool has ended (its descriptor is an Xt input: no timer polls it), the
|
||||
* user cancelled or Dtfile*connectTimeout has passed. Returns what
|
||||
* mcde_sys_net_mount returns, MCDE_SYS_OK or a failure with
|
||||
* mcde_sys_error(). A job that is given up is ended, the tool with it.
|
||||
*/
|
||||
int
|
||||
_McdeNetMount(Widget parent, const char *url, const char *mountpoint,
|
||||
const char *password)
|
||||
{
|
||||
McdeSysJob *job;
|
||||
MountWait w;
|
||||
Widget dialog, shell;
|
||||
XtAppContext app = XtWidgetToApplicationContext(parent);
|
||||
Display *dpy = XtDisplay(parent);
|
||||
XmString msg, title;
|
||||
char text[700];
|
||||
Atom del;
|
||||
Arg args[8];
|
||||
int n = 0, seconds = ConnectSeconds(parent);
|
||||
|
||||
if ((job = mcde_sys_net_mount_start(url, mountpoint, password)) == NULL)
|
||||
return MCDE_SYS_EFAIL; /* mcde_sys_error() says why */
|
||||
memset(&w, 0, sizeof w);
|
||||
(void) snprintf(text, sizeof text, "Connecting to %s ...", url);
|
||||
msg = XmStringCreateLocalized(text);
|
||||
title = XmStringCreateLocalized((char *) "Connecting");
|
||||
XtSetArg(args[n], XmNmessageString, msg); n++;
|
||||
XtSetArg(args[n], XmNdialogTitle, title); n++;
|
||||
XtSetArg(args[n], XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL); n++;
|
||||
XtSetArg(args[n], XmNdefaultButtonType, XmDIALOG_CANCEL_BUTTON); n++;
|
||||
XtSetArg(args[n], XmNautoUnmanage, False); n++;
|
||||
dialog = XmCreateWorkingDialog(parent, (char *) "connecting", args, n);
|
||||
XmStringFree(msg);
|
||||
XmStringFree(title);
|
||||
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON));
|
||||
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
|
||||
XtAddCallback(dialog, XmNcancelCallback, WaitCancel, &w);
|
||||
shell = XtParent(dialog);
|
||||
/* the close button of the window manager is Cancel, not a destroy */
|
||||
XtVaSetValues(shell, XmNdeleteResponse, XmDO_NOTHING, NULL);
|
||||
del = XmInternAtom(dpy, (char *) "WM_DELETE_WINDOW", False);
|
||||
XmAddWMProtocolCallback(shell, del, WaitCancel, &w);
|
||||
w.input = XtAppAddInput(app, mcde_sys_job_fd(job),
|
||||
(XtPointer) XtInputReadMask, WaitInput, &w);
|
||||
w.timer = XtAppAddTimeOut(app, (unsigned long) seconds * 1000UL,
|
||||
WaitTimer, &w);
|
||||
XtManageChild(dialog);
|
||||
while (!w.done)
|
||||
XtAppProcessEvent(app, XtIMAll);
|
||||
if (w.input != 0)
|
||||
XtRemoveInput(w.input);
|
||||
if (w.timer != 0)
|
||||
XtRemoveTimeOut(w.timer);
|
||||
XtUnmanageChild(dialog);
|
||||
XtDestroyWidget(shell);
|
||||
if (w.ended)
|
||||
return mcde_sys_job_finish(job);
|
||||
if (w.cancelled)
|
||||
return mcde_sys_job_cancel(job, "Cancelled.");
|
||||
(void) snprintf(text, sizeof text, "The server did not answer within "
|
||||
"%d seconds.", seconds);
|
||||
return mcde_sys_job_cancel(job, text);
|
||||
}
|
||||
|
||||
static void Open(const char *mountpoint);
|
||||
static void AskPassword(void);
|
||||
|
||||
@@ -190,8 +334,8 @@ Connect(const char *url, const char *mountpoint, const char *password)
|
||||
}
|
||||
snprintf(text, sizeof text, "Connecting to %s ...", url);
|
||||
Note(text);
|
||||
if (mcde_sys_net_mount(url, mountpoint, password) == MCDE_SYS_OK &&
|
||||
Mounted(mountpoint)) {
|
||||
if (_McdeNetMount(nv.rec->shell, url, mountpoint, password) ==
|
||||
MCDE_SYS_OK && Mounted(mountpoint)) {
|
||||
Note("");
|
||||
Open(mountpoint);
|
||||
return;
|
||||
@@ -608,8 +752,8 @@ _McdeNetConnect(FileMgrRec *rec)
|
||||
* MP (the mount point) and an empty ERR, 0 with ERR the reason.
|
||||
*/
|
||||
int
|
||||
_McdeNetConnectAddress(const char *url, char *mp, size_t mplen, char *err,
|
||||
size_t errlen)
|
||||
_McdeNetConnectAddress(Widget parent, const char *url, char *mp,
|
||||
size_t mplen, char *err, size_t errlen)
|
||||
{
|
||||
const char *p, *end, *path;
|
||||
char host[256];
|
||||
@@ -640,7 +784,7 @@ _McdeNetConnectAddress(const char *url, char *mp, size_t mplen, char *err,
|
||||
MountPoint(host, path, mp, mplen);
|
||||
if (Mounted(mp))
|
||||
return 1;
|
||||
if (mcde_sys_net_mount(url, mp, NULL) != MCDE_SYS_OK) {
|
||||
if (_McdeNetMount(parent, url, mp, NULL) != MCDE_SYS_OK) {
|
||||
if (err != NULL)
|
||||
(void)snprintf(err, errlen, "Could not connect: %s",
|
||||
mcde_sys_error());
|
||||
|
||||
@@ -213,6 +213,7 @@ openDir OpenDir string current
|
||||
restrictMode restrictMode XmRBoolean False
|
||||
rootTitle RootTitle string ROOT
|
||||
moveThreshold MoveThreshold XmRInt 4(pixels)
|
||||
connectTimeout ConnectTimeout XmRInt 20(seconds)
|
||||
view View string large_icon
|
||||
order Order string alphabetical
|
||||
direction Direction string ascending
|
||||
@@ -283,6 +284,11 @@ directory on the Desktop.
|
||||
.IP "\fBDtfile*moveThreshold:\fP"
|
||||
This is the number of pixels the cursor can move while a button is down
|
||||
before the drag controller recognizes the button down as a drag.
|
||||
.IP "\fBDtfile*connectTimeout:\fP"
|
||||
This is the number of seconds Connect to Server and the network view wait for
|
||||
a server to answer before they give up with "The server did not answer".
|
||||
Meanwhile a "Connecting" window with a Cancel button is shown and the file
|
||||
manager keeps drawing. Values below 3 or above 600 are ignored.
|
||||
.IP "\fBDtfile*view:\fP"
|
||||
This resource allows the user to change the default for the way the icons
|
||||
are represented within a view. The default is "large_icon". Possible
|
||||
|
||||
Reference in new issue
Block a user