summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-09-19 22:03:16 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-09-19 22:03:16 +0000
commitf5ae149338dc34566c7e6f9374358e01c1d69340 (patch)
treeb866c7cf5b0ef2c7b686fe24c6911338de9c3fa6
parent3fe531196771c8e81f917eebca4a06e062ab3a19 (diff)
downloadgnurl-f5ae149338dc34566c7e6f9374358e01c1d69340.tar.gz
gnurl-f5ae149338dc34566c7e6f9374358e01c1d69340.tar.bz2
gnurl-f5ae149338dc34566c7e6f9374358e01c1d69340.zip
seems to work for test 271 on Linux now!
-rw-r--r--tests/server/tftpd.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c
index dcf6addd2..eb57a1405 100644
--- a/tests/server/tftpd.c
+++ b/tests/server/tftpd.c
@@ -98,6 +98,9 @@
#include "getpart.h"
#include "util.h"
+/* include memdebug.h last */
+#include "memdebug.h"
+
struct testcase {
char *buffer; /* holds the file data to send to the client */
size_t bufsize; /* size of the data in buffer */
@@ -509,10 +512,6 @@ int main(int argc, char **argv)
do {
FILE *server;
- server = fopen(REQUEST_DUMP, "ab");
- if(!server)
- break;
-
fromlen = sizeof(from);
n = recvfrom(sock, buf, sizeof (buf), 0,
(struct sockaddr *)&from, &fromlen);
@@ -533,13 +532,19 @@ int main(int argc, char **argv)
logmsg("connect: fail\n");
return 1;
}
+ maxtimeout = 5*TIMEOUT;
tp = (struct tftphdr *)buf;
tp->th_opcode = ntohs(tp->th_opcode);
if (tp->th_opcode == RRQ || tp->th_opcode == WRQ) {
memset(&test, 0, sizeof(test));
+ server = fopen(REQUEST_DUMP, "ab");
+ if(!server)
+ break;
test.server = server;
tftp(&test, tp, n);
+ if(test.buffer)
+ free(test.buffer);
}
fclose(server);
sclose(peer);
@@ -612,6 +617,7 @@ again:
recvtftp(test, pf);
else
sendtftp(test, pf);
+
return 0;
}
@@ -697,6 +703,8 @@ static void timer(int signum)
{
(void)signum;
+ logmsg("alarm!");
+
timeout += rexmtval;
if (timeout >= maxtimeout)
exit(1);
@@ -720,7 +728,7 @@ static void sendtftp(struct testcase *test, struct formats *pf)
size = readit(test, &dp, pf->f_convert);
if (size < 0) {
nak(errno + 100);
- goto abort;
+ return;
}
dp->th_opcode = htons((u_short)DATA);
dp->th_block = htons((u_short)block);
@@ -730,7 +738,7 @@ static void sendtftp(struct testcase *test, struct formats *pf)
send_data:
if (send(peer, dp, size + 4, 0) != size + 4) {
logmsg("write\n");
- goto abort;
+ return;
}
read_ahead(test, pf->f_convert);
for ( ; ; ) {
@@ -739,13 +747,15 @@ static void sendtftp(struct testcase *test, struct formats *pf)
alarm(0);
if (n < 0) {
logmsg("read: fail\n");
- goto abort;
+ return;
}
ap->th_opcode = ntohs((u_short)ap->th_opcode);
ap->th_block = ntohs((u_short)ap->th_block);
- if (ap->th_opcode == ERROR)
- goto abort;
+ if (ap->th_opcode == ERROR) {
+ logmsg("got ERROR");
+ return;
+ }
if (ap->th_opcode == ACK) {
if (ap->th_block == block) {
@@ -761,8 +771,6 @@ static void sendtftp(struct testcase *test, struct formats *pf)
}
block++;
} while (size == SEGSIZE);
- abort:
- ;
}
static void justquit(int signum)