aboutsummaryrefslogtreecommitdiff
path: root/tests/server
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2007-10-02 10:13:37 +0000
committerDaniel Stenberg <daniel@haxx.se>2007-10-02 10:13:37 +0000
commit8d1239c091ef61725e6ce3c53b92b45a71f6f927 (patch)
tree71e6b3169fad6bcc6114b66c333dd09f48cd0633 /tests/server
parent30a39fe8773a4063d87c0352593275ebd8a0fe64 (diff)
Disable the Nagle algorithm and send back responses in small chunks in an
attempt to force smaller bits to get read by clients.
Diffstat (limited to 'tests/server')
-rw-r--r--tests/server/sws.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/server/sws.c b/tests/server/sws.c
index edf42d098..1391bf93f 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -55,6 +55,9 @@
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
+#ifdef HAVE_NETINET_TCP_H
+#include <netinet/tcp.h> /* for TCP_NODELAY */
+#endif
#define ENABLE_CURLX_PRINTF
/* make the curlx header define all printf() functions to use the curlx_*
@@ -705,11 +708,20 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
responsesize = count;
do {
- written = swrite(sock, buffer, count);
+ /* Ok, we send no more than 200 bytes at a time, just to make sure that
+ larger chunks are split up so that the client will need to do multiple
+ recv() calls to get it and thus we exercise that code better */
+ int num = count;
+ if(num > 200)
+ num = 200;
+ written = swrite(sock, buffer, num);
if (written < 0) {
logmsg("Sending response failed and we bailed out!");
return -1;
}
+ else {
+ logmsg("Sent off %d bytes", written);
+ }
/* write to file as well */
fwrite(buffer, 1, written, dump);
@@ -776,6 +788,7 @@ int main(int argc, char *argv[])
#ifdef CURL_SWS_FORK_ENABLED
bool use_fork = FALSE;
#endif
+ int opt;
while(argc>arg) {
if(!strcmp("--version", argv[arg])) {
@@ -938,7 +951,17 @@ int main(int argc, char *argv[])
#endif
logmsg("====> Client connect");
- do {
+ /*
+ * Disable the Nagle algorithm to make it easier to send out a large
+ * response in many small segments to torture the clients more.
+ */
+ opt = 1;
+ if (setsockopt(msgsock, IPPROTO_TCP, TCP_NODELAY,
+ (void *)&opt, sizeof(opt)) == -1) {
+ logmsg("====> TCP_NODELAY failed");
+ }
+
+ do {
if(get_request(msgsock, &req))
/* non-zero means error, break out of loop */
break;