chiark
/
gitweb
/
~mdw
/
fwd
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Release 1.3.9.
[fwd]
/
blast.c
diff --git
a/blast.c
b/blast.c
index fdad3dd868b133e8c4f8291d76e1c838a4b582df..cda534658a6fb6df1661ad0ab1d1459a0ef90068 100644
(file)
--- a/
blast.c
+++ b/
blast.c
@@
-1,6
+1,7
@@
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@
-15,6
+16,7
@@
#include <mLib/alloc.h>
#include <mLib/conn.h>
#include <mLib/alloc.h>
#include <mLib/conn.h>
+#include <mLib/macros.h>
#include <mLib/mdwopt.h>
#include <mLib/quis.h>
#include <mLib/report.h>
#include <mLib/mdwopt.h>
#include <mLib/quis.h>
#include <mLib/report.h>
@@
-26,13
+28,14
@@
typedef struct blast {
sel_timer t;
} blast;
sel_timer t;
} blast;
+#define sin saddrin
static struct sockaddr_in sin;
static sel_state sel;
static struct timeval ctv = { 0, 500000 };
static sel_timer sec;
static unsigned count = 0;
static struct sockaddr_in sin;
static sel_state sel;
static struct timeval ctv = { 0, 500000 };
static sel_timer sec;
static unsigned count = 0;
-static void timers(void);
+static void
IGNORABLE
timers(void);
static void stats(struct timeval *tv, void *p)
{
static void stats(struct timeval *tv, void *p)
{
@@
-75,8
+78,8
@@
static void connected(int fd, void *p)
else {
count++;
close(fd);
else {
count++;
close(fd);
- newconn(b);
}
}
+ newconn(b);
}
static void timeout(struct timeval *tv, void *p)
}
static void timeout(struct timeval *tv, void *p)
@@
-94,14
+97,14
@@
static void timers(void)
sel_timer *t = sel.timers;
while (t) {
struct tab *q; for (q = tab; q->func != t->func; q++) ;
sel_timer *t = sel.timers;
while (t) {
struct tab *q; for (q = tab; q->func != t->func; q++) ;
- assert(t->prev->next == t);
- printf("%
i.%06i
%p %s\n", t->tv.tv_sec, t->tv.tv_usec, t->p, q->name);
+/* assert(t->prev->next == t); */
+ printf("%
lu.%06lu
%p %s\n", t->tv.tv_sec, t->tv.tv_usec, t->p, q->name);
assert(t != t->next);
t = t->next;
}
puts("");
}
assert(t != t->next);
t = t->next;
}
puts("");
}
-
+
static void newconn(blast *b)
{
int fd = socket(PF_INET, SOCK_STREAM, 0);
static void newconn(blast *b)
{
int fd = socket(PF_INET, SOCK_STREAM, 0);
@@
-111,11
+114,13
@@
static void newconn(blast *b)
gettimeofday(&tv, 0);
TV_ADD(&tv, &tv, &ctv);
sel_addtimer(&sel, &b->t, &tv, timeout, b);
gettimeofday(&tv, 0);
TV_ADD(&tv, &tv, &ctv);
sel_addtimer(&sel, &b->t, &tv, timeout, b);
- conn_init(&b->c, &sel, fd, (struct sockaddr *)&sin, sizeof(sin),
- connected, b);
+ if (conn_init(&b->c, &sel, fd, (struct sockaddr *)&sin, sizeof(sin),
+ connected, b))
+ goto fail;
return;
fail:
return;
fail:
+ sel_rmtimer(&b->t);
backoff(b);
}
backoff(b);
}
@@
-148,7
+153,7
@@
int main(int argc, char *argv[])
argv += optind;
argc -= optind;
if (argc != 2) {
argv += optind;
argc -= optind;
if (argc != 2) {
- pquis(stderr, "Usage: $ [-t
time] [-n count] host port
\n");
+ pquis(stderr, "Usage: $ [-t
TIME] [-n COUNT] HOST PORT
\n");
exit(1);
}
exit(1);
}