diff options
author | jkh <jkh@FreeBSD.org> | 1997-01-18 19:18:26 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1997-01-18 19:18:26 +0000 |
commit | 37838c93f6be5a90dc35b8fa3449218806fc0c1f (patch) | |
tree | 3f735b8eee63e6fa439e011bca14e2293b5de0cd /release | |
parent | ee10277a8bc9d2921407623da8597b7eafec720b (diff) | |
download | FreeBSD-src-37838c93f6be5a90dc35b8fa3449218806fc0c1f.zip FreeBSD-src-37838c93f6be5a90dc35b8fa3449218806fc0c1f.tar.gz |
Fix a variety of problems with my timeout handling, make it more
configurable (you can now set the timeout interval), fix a crash-bug
when no network device was attached.
Diffstat (limited to 'release')
-rw-r--r-- | release/sysinstall/dist.c | 8 | ||||
-rw-r--r-- | release/sysinstall/ftp.c | 13 | ||||
-rw-r--r-- | release/sysinstall/install.c | 1 | ||||
-rw-r--r-- | release/sysinstall/media.c | 49 | ||||
-rw-r--r-- | release/sysinstall/nfs.c | 4 | ||||
-rw-r--r-- | release/sysinstall/options.c | 3 | ||||
-rw-r--r-- | release/sysinstall/sysinstall.h | 2 |
7 files changed, 54 insertions, 26 deletions
diff --git a/release/sysinstall/dist.c b/release/sysinstall/dist.c index 7bd3795..7d05dc5 100644 --- a/release/sysinstall/dist.c +++ b/release/sysinstall/dist.c @@ -345,6 +345,10 @@ static void media_timeout(int sig) { AlarmWentOff = TRUE; + if (sig != SIGINT) + msgDebug("A media timeout occurred.\n"); + else + msgDebug("User generated interrupt.\n"); } static Boolean @@ -409,7 +413,7 @@ distExtract(char *parent, Distribution *me) new.sa_mask = 0; sigaction(SIGINT, &new, &old); - alarm_set(MEDIA_TIMEOUT, media_timeout); + alarm_set(mediaTimeout(), media_timeout); status = attr_parse(dist_attr, fp); alarm_clear(); sigaction(SIGINT, &old, NULL); /* Restore signal handler */ @@ -494,7 +498,7 @@ distExtract(char *parent, Distribution *me) while (1) { int seconds; - alarm_set(MEDIA_TIMEOUT, media_timeout); + alarm_set(mediaTimeout(), media_timeout); n = fread(buf, 1, BUFSIZ, fp); alarm_clear(); if (n <= 0 || AlarmWentOff) { diff --git a/release/sysinstall/ftp.c b/release/sysinstall/ftp.c index 07c4528..f83dfda 100644 --- a/release/sysinstall/ftp.c +++ b/release/sysinstall/ftp.c @@ -67,7 +67,7 @@ mediaInitFTP(Device *dev) } /* If we can't initialize the network, bag it! */ - if (!netdev->init(netdev)) + if (netdev && !netdev->init(netdev)) return FALSE; try: @@ -75,7 +75,8 @@ try: if (!cp) { if (DITEM_STATUS(mediaSetFTP(NULL)) == DITEM_FAILURE || (cp = variable_get(VAR_FTP_PATH)) == NULL) { msgConfirm("Unable to get proper FTP path. FTP media not initialized."); - netdev->shutdown(netdev); + if (netdev) + netdev->shutdown(netdev); return FALSE; } } @@ -84,7 +85,8 @@ try: dir = variable_get(VAR_FTP_DIR); if (!hostname || !dir) { msgConfirm("Missing FTP host or directory specification. FTP media not initialized,"); - netdev->shutdown(netdev); + if (netdev) + netdev->shutdown(netdev); return FALSE; } user = variable_get(VAR_FTP_USER); @@ -147,7 +149,8 @@ punt: fclose(OpenConn); OpenConn = NULL; } - netdev->shutdown(netdev); + if (netdev) + netdev->shutdown(netdev); variable_unset(VAR_FTP_PATH); return FALSE; } @@ -223,6 +226,6 @@ mediaShutdownFTP(Device *dev) fclose(OpenConn); OpenConn = NULL; } - /* netdev->shutdown(netdev); */ + /* if (netdev) netdev->shutdown(netdev); */ ftpInitted = FALSE; } diff --git a/release/sysinstall/install.c b/release/sysinstall/install.c index 245cdb5..27d826e 100644 --- a/release/sysinstall/install.c +++ b/release/sysinstall/install.c @@ -1004,6 +1004,7 @@ installVarDefaults(dialogMenuItem *self) variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/lynx"); variable_set2(VAR_FTP_STATE, "passive"); variable_set2(VAR_PKG_TMPDIR, "/usr/tmp"); + variable_set2(VAR_MEDIA_TIMEOUT, itoa(MEDIA_TIMEOUT)); if (getpid() != 1) variable_set2(SYSTEM_STATE, "update"); else diff --git a/release/sysinstall/media.c b/release/sysinstall/media.c index af41a2d..288508a 100644 --- a/release/sysinstall/media.c +++ b/release/sysinstall/media.c @@ -298,9 +298,8 @@ mediaSetFTP(dialogMenuItem *self) SAFE_STRCPY(ftpDevice.name, cp); dialog_clear_norefresh(); - if (RunningAsInit && - (network_init || msgYesNo("You've already done the network configuration once,\n" - "would you like to skip over it now?") != 0)) { + if (RunningAsInit && (network_init || msgYesNo("You've already done the network configuration once,\n" + "would you like to skip over it now?") != 0)) { if (mediaDevice) mediaDevice->shutdown(mediaDevice); if (!tcpDeviceSelect()) { @@ -348,7 +347,7 @@ mediaSetFTP(dialogMenuItem *self) ftpDevice.init = mediaInitFTP; ftpDevice.get = mediaGetFTP; ftpDevice.shutdown = mediaShutdownFTP; - ftpDevice.private = mediaDevice; /* Set to network device by tcpDeviceSelect() */ + ftpDevice.private = RunningAsInit ? mediaDevice : NULL; /* Set to network device by tcpDeviceSelect() */ mediaDevice = &ftpDevice; return DITEM_SUCCESS | DITEM_LEAVE_MENU | what; } @@ -392,6 +391,7 @@ int mediaSetNFS(dialogMenuItem *self) { static Device nfsDevice; + static int network_init = 1; char *cp, *idx; dialog_clear_norefresh(); @@ -406,16 +406,19 @@ mediaSetNFS(dialogMenuItem *self) return DITEM_FAILURE; } SAFE_STRCPY(nfsDevice.name, cp); - /* str == NULL means we were just called to change NFS paths, not network interfaces */ - if (!tcpDeviceSelect()) - return DITEM_FAILURE; - if (!mediaDevice || !mediaDevice->init(mediaDevice)) { - if (isDebug()) - msgDebug("mediaSetNFS: Net device init failed\n"); - return DITEM_FAILURE; - } *idx = '\0'; - if (variable_get(VAR_NAMESERVER)) { + if (RunningAsInit && (network_init || msgYesNo("You've already done the network configuration once,\n" + "would you like to skip over it now?") != 0)) { + if (!tcpDeviceSelect()) + return DITEM_FAILURE; + if (!mediaDevice || !mediaDevice->init(mediaDevice)) { + if (isDebug()) + msgDebug("mediaSetNFS: Net device init failed\n"); + return DITEM_FAILURE; + } + } + network_init = 0; + if (!RunningAsInit || variable_get(VAR_NAMESERVER)) { if ((gethostbyname(cp) == NULL) && (inet_addr(cp) == INADDR_NONE)) { msgConfirm("Cannot resolve hostname `%s'! Are you sure that your\n" "name server, gateway and network interface are correctly configured?", cp); @@ -423,14 +426,13 @@ mediaSetNFS(dialogMenuItem *self) } else msgNotify("Found DNS entry for %s successfully..", cp); - } variable_set2(VAR_NFS_HOST, cp); nfsDevice.type = DEVICE_TYPE_NFS; nfsDevice.init = mediaInitNFS; nfsDevice.get = mediaGetNFS; nfsDevice.shutdown = mediaShutdownNFS; - nfsDevice.private = mediaDevice; + nfsDevice.private = RunningAsInit ? mediaDevice : NULL; mediaDevice = &nfsDevice; return DITEM_LEAVE_MENU; } @@ -522,6 +524,19 @@ media_timeout(int sig) AlarmWentOff = TRUE; } +/* Return the timeout interval */ +int +mediaTimeout(void) +{ + char *cp; + int t; + + cp = getenv(VAR_MEDIA_TIMEOUT); + if (!cp || !(t = atoi(cp))) + t = MEDIA_TIMEOUT; + return t; +} + Boolean mediaExtractDist(char *dir, char *dist, FILE *fp) { @@ -595,7 +610,7 @@ mediaExtractDist(char *dir, char *dist, FILE *fp) new.sa_mask = 0; sigaction(SIGINT, &new, &old); - alarm_set(MEDIA_TIMEOUT, media_timeout); + alarm_set(mediaTimeout(), media_timeout); while ((i = fread(buf, 1, BUFSIZ, fp)) > 0) { alarm_clear(); if (AlarmWentOff) { @@ -619,7 +634,7 @@ mediaExtractDist(char *dir, char *dist, FILE *fp) msgInfo("%10d bytes read from %s dist @ %.1f KB/sec.", total, dist, (total / seconds) / 1024.0); } - alarm_set(MEDIA_TIMEOUT, media_timeout); + alarm_set(mediaTimeout(), media_timeout); } alarm_clear(); sigaction(SIGINT, &old, NULL); /* restore sigint */ diff --git a/release/sysinstall/nfs.c b/release/sysinstall/nfs.c index 45cce67..1a7af4f 100644 --- a/release/sysinstall/nfs.c +++ b/release/sysinstall/nfs.c @@ -51,7 +51,7 @@ mediaInitNFS(Device *dev) if (NFSMounted) return TRUE; - if (!netDevice->init(netDevice)) + if (netDevice && !netDevice->init(netDevice)) return FALSE; if (Mkdir("/dist")) @@ -101,7 +101,7 @@ mediaShutdownNFS(Device *dev) if (unmount("/dist", MNT_FORCE) != 0) msgConfirm("Could not unmount the NFS partition: %s", strerror(errno)); msgDebug("Unmount of NFS partition successful\n"); - /* netdev->shutdown(netdev); */ + /* if (netdev) netdev->shutdown(netdev); */ NFSMounted = FALSE; return; } diff --git a/release/sysinstall/options.c b/release/sysinstall/options.c index a70799e..b421f0a 100644 --- a/release/sysinstall/options.c +++ b/release/sysinstall/options.c @@ -100,6 +100,7 @@ mediaCheck(Option opt) #define EDITOR_PROMPT "Please specify the name of the text editor you wish to use:" #define PKG_PROMPT "Please specify a temporary directory with lots of free space:" #define INSTROOT_PROMPT "Please specify a root directory if installing somewhere other than /" +#define TIMEOUT_PROMPT "Please specify the number of seconds to wait for slow media:" static Option Options[] = { { "NFS Secure", "NFS server talks only on a secure port", @@ -128,6 +129,8 @@ static Option Options[] = { OPT_IS_VAR, BBIN_PROMPT, VAR_BROWSER_BINARY, varCheck }, { "Media Type", "The current installation media type.", OPT_IS_FUNC, mediaGetType, VAR_MEDIA_TYPE, mediaCheck }, +{ "Media Timeout", "Timeout value in seconds for slow media.", + OPT_IS_VAR, TIMEOUT_PROMPT, VAR_MEDIA_TIMEOUT, varCheck }, { "Package Temp", "The directory where package temporary files should go", OPT_IS_VAR, PKG_PROMPT, VAR_PKG_TMPDIR, varCheck }, { "Use Defaults", "Reset all values to startup defaults", diff --git a/release/sysinstall/sysinstall.h b/release/sysinstall/sysinstall.h index 69e400a..1494a8c 100644 --- a/release/sysinstall/sysinstall.h +++ b/release/sysinstall/sysinstall.h @@ -117,6 +117,7 @@ #define VAR_LABEL "label" #define VAR_LABEL_COUNT "labelCount" #define VAR_MEDIA_TYPE "mediaType" +#define VAR_MEDIA_TIMEOUT "MEDIA_TIMEOUT" #define VAR_NAMESERVER "nameserver" #define VAR_NETMASK "netmask" #define VAR_NFS_PATH "nfs" @@ -548,6 +549,7 @@ extern u_char default_scrnmap[]; /* media.c */ extern char *cpioVerbosity(void); +extern int mediaTimeout(void); extern int mediaSetCDROM(dialogMenuItem *self); extern int mediaSetFloppy(dialogMenuItem *self); extern int mediaSetDOS(dialogMenuItem *self); |