1
0
mirror of https://github.com/wg/wrk synced 2025-01-08 23:32:54 +08:00

more robust socket error handling

This commit is contained in:
Will 2013-02-16 17:20:40 +09:00
parent c00e9470e0
commit a1a46c4e0d
2 changed files with 4 additions and 2 deletions

View File

@ -14,6 +14,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include <sys/socket.h>
@ -119,6 +120,7 @@ int main(int argc, char **argv) {
exit(1);
}
signal(SIGPIPE, SIG_IGN);
cfg.addr = *addr;
request.buf = format_request(host, port, path, headers);
request.size = strlen(request.buf);
@ -340,7 +342,7 @@ static void socket_readable(aeEventLoop *loop, int fd, void *data, int mask) {
connection *c = data;
ssize_t n;
if ((n = read(fd, c->buf, sizeof(c->buf))) == -1) goto error;
if ((n = read(fd, c->buf, sizeof(c->buf))) <= 0) goto error;
if (http_parser_execute(&c->parser, &parser_settings, c->buf, n) != n) goto error;
c->thread->bytes += n;

View File

@ -11,7 +11,7 @@
#include "http_parser.h"
#include "tinymt64.h"
#define VERSION "1.0.0"
#define VERSION "1.1.0"
#define RECVBUF 8192
#define SAMPLES 100000