]> granicus.if.org Git - libevent/commitdiff
http-connect: exit on error
authorAzat Khuzhin <a3at.mail@gmail.com>
Sun, 28 May 2017 13:38:20 +0000 (16:38 +0300)
committerAzat Khuzhin <azat@libevent.org>
Sat, 2 Feb 2019 12:13:51 +0000 (15:13 +0300)
(cherry picked from commit d22e12eefa11aab34b95e8b07b823f3ad0597239)

sample/http-connect.c

index a44d001ac71fa4ac50e90951b1276e179eb1a9ed..af2c86a8db9539c3f8202a81cda24527647265b0 100644 (file)
@@ -11,6 +11,7 @@
 #define VERIFY(cond) do {                       \
        if (!(cond)) {                              \
                fprintf(stderr, "[error] %s\n", #cond); \
+               exit(EXIT_FAILURE);                     \
        }                                           \
 } while (0);                                    \
 
@@ -26,8 +27,11 @@ static void get_cb(struct evhttp_request *req, void *arg)
 {
        ev_ssize_t len;
        struct evbuffer *evbuf;
+       struct evhttp_connection *evcon;
 
        VERIFY(req);
+       evcon = evhttp_request_get_connection(req);
+       VERIFY(evcon);
 
        evbuf = evhttp_request_get_input_buffer(req);
        len = evbuffer_get_length(evbuf);
@@ -72,7 +76,7 @@ int main(int argc, const char **argv)
        }
 
        {
-               proxy = evhttp_uri_parse(argv[1]);
+               VERIFY(proxy = evhttp_uri_parse(argv[1]));
                VERIFY(evhttp_uri_get_host(proxy));
                VERIFY(evhttp_uri_get_port(proxy) > 0);
        }