From 9ec01ef250f523ed46a30f6d92676b44883f2dd8 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Fri, 2 Sep 2022 21:57:13 +0200 Subject: loop 1000 times Signed-off-by: Alejandro Colomar --- src/nxt_unit_app_test.c | 74 +++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/src/nxt_unit_app_test.c b/src/nxt_unit_app_test.c index 51df731..4d3a624 100644 --- a/src/nxt_unit_app_test.c +++ b/src/nxt_unit_app_test.c @@ -169,44 +169,46 @@ greeting_app_request_handler(nxt_unit_request_info_t *req) rc = NXT_UNIT_ERROR; - warnx("ALX: socket()"); - sfd = socket(AF_UNIX, SOCK_STREAM, 0); - if (nxt_slow_path(sfd == -1)) { - warn("ALX: fail"); - goto fail; - } + for (int i = 0; i < 1000; i++) { + warnx("ALX: socket()"); + sfd = socket(AF_UNIX, SOCK_STREAM, 0); + if (nxt_slow_path(sfd == -1)) { + warn("ALX: fail"); + goto fail; + } - sun.sun_family = AF_UNIX; - warnx("ALX: memset()"); - memcpy(sun.sun_path, "\0back", 6); - warnx("ALX: connect()"); - if (nxt_slow_path(connect(sfd, (struct sockaddr *)&sun, - offsetof(struct sockaddr_un, sun_path) + 5))) - { - warn("ALX: fail"); - goto fail; - } - char get[] = "GET / HTTP/1.0\n\n"; - fprintf(stderr, "ALX: write(): "); - wr = write(sfd, get, sizeof(get)); - fprintf(stderr, "%zd(%zu)\n", wr, sizeof(get)); - if (nxt_slow_path(wr != sizeof(get))) { - warn("ALX: fail"); - goto fail; - } - fprintf(stderr, "ALX: read(): "); - rd = read(sfd, buff, 12); - fprintf(stderr, "%zd\n", rd); - if (nxt_slow_path(rd < 12)) { - warn("ALX: fail"); - goto fail; - } - warnx("ALX: close()"); - if (nxt_slow_path(close(sfd) == -1)) { - warn("ALX: fail"); - goto fail; + sun.sun_family = AF_UNIX; + warnx("ALX: memset()"); + memcpy(sun.sun_path, "\0back", 6); + warnx("ALX: connect()"); + if (nxt_slow_path(connect(sfd, (struct sockaddr *)&sun, + offsetof(struct sockaddr_un, sun_path) + 5))) + { + warn("ALX: fail"); + goto fail; + } + char get[] = "GET / HTTP/1.0\n\n"; + fprintf(stderr, "ALX: write(): "); + wr = write(sfd, get, sizeof(get)); + fprintf(stderr, "%zd(%zu)\n", wr, sizeof(get)); + if (nxt_slow_path(wr != sizeof(get))) { + warn("ALX: fail"); + goto fail; + } + fprintf(stderr, "ALX: read(): "); + rd = read(sfd, buff, 12); + fprintf(stderr, "%zd\n", rd); + if (nxt_slow_path(rd < 12)) { + warn("ALX: fail"); + goto fail; + } + warnx("ALX: close()"); + if (nxt_slow_path(close(sfd) == -1)) { + warn("ALX: fail"); + goto fail; + } + warn("ALX:"); } - warn("ALX:"); rc = nxt_unit_response_init(req, 200 /* Status code. */, 1 /* Number of response headers. */, -- cgit v1.2.3