* pcmcia-cs: ifuser times out in gethostbyname for empty route tables
@ 2003-05-14 9:54 Alex Riesen
0 siblings, 0 replies; only message in thread
From: Alex Riesen @ 2003-05-14 9:54 UTC (permalink / raw)
To: David Hinds; +Cc: linux-kernel, brian
Hello, David!
[lkml: sorry for off-topic, but David is very slow on responses, and
the fix could be useful to someone
Brian: the sources are downloaded from debian-unstable]
If I try to stop pcmcia services without actually connecting to the network,
if user will hang for annoyngly long time. I narrowed the problem down
to ifuser tryng to resolve the word "Destination" (first word of the
last line of "netstat -rn" output for empty route table).
That are the second and the third hunks in the attached patch.
The first doesn't start netstat at all if there is nothing to do anyway,
and the last adds check for looopback network.
--- pcmcia-cs-3.2.2/cardmgr/ifuser.c 2001-08-24 14:19:20.000000000 +0200
+++ pcmcia-cs-3.2.2-fix/cardmgr/ifuser.c 2003-05-14 10:16:55.000000000 +0200
@@ -108,6 +108,8 @@ int main(int argc, char *argv[])
}
if ((*argv[i] == '-') || (argc < i+1)) usage(argv[0]);
dev = argv[i]; i++;
+ if ( i >= argc )
+ return (!busy);
/* Get routing table */
f = popen("netstat -nr", "r");
@@ -122,6 +124,8 @@ int main(int argc, char *argv[])
} while (!feof(f) && !isdigit(s[0]));
tail = &tbl;
+ if ( !isdigit(s[0]) )
+ goto rt_end;
do {
r = malloc(sizeof(route_t));
if (r == NULL) {
@@ -134,6 +138,7 @@ int main(int argc, char *argv[])
r->match = (strcmp(iface, dev) == 0);
*tail = r; tail = &(r->next);
} while (fgets(s, 128, f) != NULL);
+rt_end:
*tail = NULL;
pclose(f);
@@ -147,6 +152,8 @@ int main(int argc, char *argv[])
}
for (r = tbl; r; r = r->next) {
+ if ((a & 0xff000000) == 0x7f000000) /* loopback network */
+ continue;
if ((a & r->mask) == r->dest) {
if (r->match) {
if (verbose) {
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-05-14 9:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-14 9:54 pcmcia-cs: ifuser times out in gethostbyname for empty route tables Alex Riesen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox