diff options
author | he <he@pkgsrc.org> | 2004-07-07 14:39:33 +0000 |
---|---|---|
committer | he <he@pkgsrc.org> | 2004-07-07 14:39:33 +0000 |
commit | 0efe4873bb7f7e49bd9509b162373672aeb31bc3 (patch) | |
tree | 4ac469115b095674c4c5057ee1143d4047d1fcf3 /net/tcl-scotty | |
parent | d81157dcc9a1e1876ae8495d6f855313ba531f26 (diff) | |
download | pkgsrc-0efe4873bb7f7e49bd9509b162373672aeb31bc3.tar.gz |
Add a patch to fix a race condition in the straps program. If
traps arrive in a steady stream, straps will exit before the client
(scotty) manages to connect, because traps are handled before new
client connections in straps. Adds a sleep(3) first, and rearranges
the order of handling of these events, so that scotty can get around
to connecting as a client before the first trap is handled by straps.
Bump pkgrevision to 3.
Diffstat (limited to 'net/tcl-scotty')
-rw-r--r-- | net/tcl-scotty/Makefile | 4 | ||||
-rw-r--r-- | net/tcl-scotty/distinfo | 3 | ||||
-rw-r--r-- | net/tcl-scotty/patches/patch-ag | 74 |
3 files changed, 78 insertions, 3 deletions
diff --git a/net/tcl-scotty/Makefile b/net/tcl-scotty/Makefile index 04399cbf67a..e649a16eb52 100644 --- a/net/tcl-scotty/Makefile +++ b/net/tcl-scotty/Makefile @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.14 2004/06/04 14:48:59 minskim Exp $ +# $NetBSD: Makefile,v 1.15 2004/07/07 14:39:33 he Exp $ # DISTNAME= scotty-${DIST_VERS} PKGNAME= tcl-scotty-${DIST_VERS} -PKGREVISION= 2 +PKGREVISION= 3 CATEGORIES= net tcl MASTER_SITES= ftp://ftp.ibr.cs.tu-bs.de/pub/local/tkined/ diff --git a/net/tcl-scotty/distinfo b/net/tcl-scotty/distinfo index 1edeb048681..f1d1596e230 100644 --- a/net/tcl-scotty/distinfo +++ b/net/tcl-scotty/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.5 2004/06/05 04:30:44 minskim Exp $ +$NetBSD: distinfo,v 1.6 2004/07/07 14:39:33 he Exp $ SHA1 (scotty-2.1.11.tar.gz) = 819011f908c57e4591d6f50e51677c01eb55dc13 Size (scotty-2.1.11.tar.gz) = 1381059 bytes @@ -7,3 +7,4 @@ SHA1 (patch-ab) = 19cfe3674601e639095cd26605684114a40c6aac SHA1 (patch-ac) = 5414110cb56026e77dc96316e33ee07d1331b85f SHA1 (patch-ad) = 64c2f53c0eb0e32af144ec6c4e2b0f55edc9b60a SHA1 (patch-af) = 8915bfd1912e9255e39d2c3b5b49e0b5c518bb9c +SHA1 (patch-ag) = 83b5f0cbc677338afc9e3c3b8565b2a1d47faad0 diff --git a/net/tcl-scotty/patches/patch-ag b/net/tcl-scotty/patches/patch-ag new file mode 100644 index 00000000000..717f15bb34f --- /dev/null +++ b/net/tcl-scotty/patches/patch-ag @@ -0,0 +1,74 @@ +$NetBSD: patch-ag,v 1.1 2004/07/07 14:39:33 he Exp $ + +--- ../tnm/snmp/straps.c.orig Tue Mar 9 18:06:10 1999 ++++ ../tnm/snmp/straps.c +@@ -246,6 +246,17 @@ main(argc, argv) + #endif + + /* ++ * If there is a steady stream of traps bound for this ++ * host, we need to allow some time for the client (scotty) ++ * to connect to us. Otherwise, straps will just exit when ++ * the first trap message arrives. The client does 5 retries ++ * with 1 second in-between, so sleeping for 3 should be enough ++ * to let the client connect. There really ought to be a better ++ * way to do this. ++ */ ++ sleep(3); ++ ++ /* + * Fine everything is ready; lets listen for events: + * the for(;;) loop aborts, if the last client went away. + */ +@@ -271,7 +282,25 @@ main(argc, argv) + perror("straps: select failed"); + } + +- if (FD_ISSET(trap_s, &fds)) { ++ /* ++ * Check for new clients before handling any traps. ++ * If a trap arrived while we were sleeping above, ++ * we would set go_on to zero before the first client ++ * had a chance to connect. ++ */ ++ if (FD_ISSET(serv_s, &fds)) { ++ /* accept a new client: */ ++ memset((char *) &daddr, 0, sizeof(daddr)); ++ dlen = sizeof(daddr); ++ ++ rc = accept(serv_s, (struct sockaddr *) &daddr, &dlen); ++ if (rc < 0) { ++ perror("straps: accept failed"); ++ continue; ++ } ++ cl_addr [rc] = 1; ++ ++ } else if (FD_ISSET(trap_s, &fds)) { + /* read trap message and forward to clients: */ + llen = sizeof(laddr); + if ((rc = recvfrom(trap_s, buf, sizeof(buf), 0, +@@ -328,24 +357,6 @@ main(argc, argv) + for (go_on = 0, i = 0; i < FD_SETSIZE; i++) { + go_on += cl_addr [i] > 0; + } +- +- } else if (FD_ISSET(serv_s, &fds)) { +- memset((char *) &daddr, 0, sizeof(daddr)); +- dlen = sizeof(daddr); +- +- rc = accept(serv_s, (struct sockaddr *) &daddr, &dlen); +- if (rc < 0) { +- perror("straps: accept failed"); +- continue; +- } +- /* Check for a potential buffer overflow if the accept() +- call returns a file descriptor larger than FD_SETSIZE */ +- if (rc >= FD_SETSIZE) { +- fprintf(stderr, "straps: too many clients\n"); +- close(rc); +- continue; +- } +- cl_addr [rc] = 1; + + } else { + /* fd's connected from clients. (XXX: should check for EOF): */ |