Messages in this thread Patch in this message | | | Date | Wed, 14 May 2003 11:54:28 +0200 | From | Alex Riesen <> | Subject | pcmcia-cs: ifuser times out in gethostbyname for empty route tables |
| |
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) { - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |