diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2016-11-06 23:10:34 +0000 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2016-11-08 15:35:34 +0000 |
commit | 5ddc9771fa4d7861d3e5bfd6ea30c054883eaf40 (patch) | |
tree | fc2bd51ab9ea6b6685ea898400d2ebdc3a0faaa7 /test | |
parent | dd7b74e90a96eaf109796d8f9499578571a1572c (diff) |
Ensure socket is nonblocking before draining. Bug 1914
Diffstat (limited to 'test')
-rw-r--r-- | test/log/0502 | 7 | ||||
-rw-r--r-- | test/scripts/0000-Basic/0502 | 18 | ||||
-rw-r--r-- | test/src/client.c | 29 | ||||
-rw-r--r-- | test/src/server.c | 2 | ||||
-rw-r--r-- | test/stderr/0502 | 2 | ||||
-rw-r--r-- | test/stdout/0502 | 20 |
6 files changed, 70 insertions, 8 deletions
diff --git a/test/log/0502 b/test/log/0502 index 37d82e43b..93673ff90 100644 --- a/test/log/0502 +++ b/test/log/0502 @@ -13,3 +13,10 @@ 1999-03-02 09:44:33 Messages accepted: 1999-03-02 09:44:33 Recipients: 1999-03-02 09:44:33 Accepted: + +******** SERVER ******** +1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port 1225 +1999-03-02 09:44:33 Messages received: +1999-03-02 09:44:33 Messages accepted: +1999-03-02 09:44:33 Recipients: +1999-03-02 09:44:33 Accepted: diff --git a/test/scripts/0000-Basic/0502 b/test/scripts/0000-Basic/0502 index d4b8f0fdb..c22205ca7 100644 --- a/test/scripts/0000-Basic/0502 +++ b/test/scripts/0000-Basic/0502 @@ -23,3 +23,21 @@ exim -bs -DLAST='' mail from:<a@b> quit **** +# +# Check the server closes conn after a quit-response +exim -DSERVER=server -DLAST=accept -bd -oX PORT_D +**** +client 127.0.0.1 PORT_D +??? 220 +EHLO test.ex +??? 250- +??? 250- +??? 250- +??? 250- +??? 250 HELP +QUIT +??? 221 +???*eof +**** +# +killdaemon diff --git a/test/src/client.c b/test/src/client.c index 5e6b6472a..2b73098f5 100644 --- a/test/src/client.c +++ b/test/src/client.c @@ -24,6 +24,7 @@ ripped from the openssl ocsp and s_client utilities. */ #include <netinet/in_systm.h> #include <netinet/in.h> #include <netinet/ip.h> +#include <netinet/tcp.h> #include <netdb.h> #include <arpa/inet.h> @@ -897,9 +898,13 @@ while (fgets(CS outbuffer, sizeof(outbuffer), stdin) != NULL) /* Expect incoming */ - if (strncmp(CS outbuffer, "??? ", 4) == 0) + if ( strncmp(CS outbuffer, "???", 3) == 0 + && (outbuffer[3] == ' ' || outbuffer[3] == '*') + ) { unsigned char *lineptr; + unsigned exp_eof = outbuffer[3] == '*'; + printf("%s\n", outbuffer); if (*inptr == 0) /* Refill input buffer */ @@ -921,15 +926,27 @@ while (fgets(CS outbuffer, sizeof(outbuffer), stdin) != NULL) } if (rc < 0) - { + { printf("Read error %s\n", strerror(errno)); - exit(81) ; - } + exit(81); + } else if (rc == 0) + if (exp_eof) + { + printf("Expected EOF read\n"); + continue; + } + else + { + printf("Enexpected EOF read\n"); + close(sock); + exit(80); + } + else if (exp_eof) { - printf("Unexpected EOF read\n"); + printf("Expected EOF not read\n"); close(sock); - exit(80); + exit(74); } else { diff --git a/test/src/server.c b/test/src/server.c index 4a48965e2..26fcaf070 100644 --- a/test/src/server.c +++ b/test/src/server.c @@ -397,7 +397,6 @@ else sin4.sin_addr.s_addr = (S_ADDR_TYPE)INADDR_ANY; sin4.sin_port = htons(port); if (bind(listen_socket[i], (struct sockaddr *)&sin4, sizeof(sin4)) < 0) - { if (listen_socket[v6n] < 0 || errno != EADDRINUSE) { printf("IPv4 socket bind() failed: %s\n", strerror(errno)); @@ -408,7 +407,6 @@ else close(listen_socket[i]); listen_socket[i] = -1; } - } } } } diff --git a/test/stderr/0502 b/test/stderr/0502 index 71afc025b..a3b308501 100644 --- a/test/stderr/0502 +++ b/test/stderr/0502 @@ -1 +1,3 @@ 1999-03-02 09:44:33 ACL for QUIT returned ERROR: QUIT or not-QUIT teplevel ACL may not fail ('deny' verb used incorrectly) + +******** SERVER ******** diff --git a/test/stdout/0502 b/test/stdout/0502 index a0fbe6b00..edb6d3156 100644 --- a/test/stdout/0502 +++ b/test/stdout/0502 @@ -19,3 +19,23 @@ 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
250 OK
221 myhost.test.ex closing connection
+Connecting to 127.0.0.1 port 1225 ... connected +??? 220 +<<< 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +>>> EHLO test.ex +??? 250- +<<< 250-myhost.test.ex Hello test.ex [127.0.0.1] +??? 250- +<<< 250-SIZE 52428800 +??? 250- +<<< 250-8BITMIME +??? 250- +<<< 250-PIPELINING +??? 250 HELP +<<< 250 HELP +>>> QUIT +??? 221 +<<< 221 myhost.test.ex closing connection +???*eof +Expected EOF read +End of script |