]> git.pld-linux.org Git - packages/libevent.git/commitdiff
- up for 1.4.14b auto/th/libevent-1_4_14b-1
authorlisu <lisu@pld-linux.org>
Thu, 24 Jun 2010 11:24:43 +0000 (11:24 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    libevent.fb-changes.diff -> 1.2

libevent.fb-changes.diff

index a7d8d97efbdfb02c8d33ccc93b7dea8db06b4e8f..3e6e1c6812d5d6442706fc4b5ebaf759258c3abe 100644 (file)
@@ -1,7 +1,9 @@
-diff -wbBdu -ur libevent-1.4.13-stable/event.c libevent-1.4.13-stable-fb-fresh/event.c
---- event.c    2009-11-17 19:39:08.000000000 -0800
-+++ event.c    2010-01-28 14:52:34.687528000 -0800
-@@ -134,10 +134,12 @@
+diff -rp -U 5 libevent-1.4.14-stable/event.c libevent-1.4.14-stable-fb/event.c
+--- libevent-1.4.14-stable/event.c     2010-06-07 14:40:35.000000000 -0700
++++ libevent-1.4.14-stable-fb/event.c  2010-06-18 16:30:57.000000000 -0700
+@@ -136,14 +136,16 @@ detect_monotonic(void)
+ }
  static int
  gettime(struct event_base *base, struct timeval *tp)
  {
@@ -14,7 +16,11 @@ diff -wbBdu -ur libevent-1.4.13-stable/event.c libevent-1.4.13-stable-fb-fresh/e
  
  #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
        if (use_monotonic) {
-@@ -471,7 +473,7 @@
+               struct timespec ts;
+@@ -479,11 +481,11 @@ event_base_loop(struct event_base *base,
+       struct timeval tv;
+       struct timeval *tv_p;
        int res, done;
  
        /* clear time cache */
@@ -23,7 +29,11 @@ diff -wbBdu -ur libevent-1.4.13-stable/event.c libevent-1.4.13-stable-fb-fresh/e
  
        if (base->sig.ev_signal_added)
                evsignal_base = base;
-@@ -511,13 +513,13 @@
+       done = 0;
+       while (!done) {
+@@ -531,17 +533,17 @@ event_base_loop(struct event_base *base,
+               /* update last old time */
                gettime(base, &base->event_tv);
  
                /* clear time cache */
@@ -39,7 +49,11 @@ diff -wbBdu -ur libevent-1.4.13-stable/event.c libevent-1.4.13-stable-fb-fresh/e
  
                timeout_process(base);
  
-@@ -530,7 +532,7 @@
+               if (base->event_count_active) {
+                       event_process_active(base);
+@@ -550,11 +552,11 @@ event_base_loop(struct event_base *base,
+               } else if (flags & EVLOOP_NONBLOCK)
+                       done = 1;
        }
  
        /* clear time cache */
@@ -48,13 +62,40 @@ diff -wbBdu -ur libevent-1.4.13-stable/event.c libevent-1.4.13-stable-fb-fresh/e
  
        event_debug(("%s: asked to terminate loop.", __func__));
        return (0);
-diff -wbBdu -ur libevent-1.4.13-stable/evhttp.h libevent-1.4.13-stable-fb-fresh/evhttp.h
---- evhttp.h   2009-04-12 15:59:30.000000000 -0700
-+++ evhttp.h   2010-01-28 14:52:34.815520000 -0800
-@@ -87,6 +87,17 @@
+ }
+Only in libevent-1.4.14-stable-fb: event.c.orig
+diff -rp -U 5 libevent-1.4.14-stable/evhttp.h libevent-1.4.14-stable-fb/evhttp.h
+--- libevent-1.4.14-stable/evhttp.h    2010-06-07 14:40:35.000000000 -0700
++++ libevent-1.4.14-stable-fb/evhttp.h 2010-06-18 16:36:24.000000000 -0700
+@@ -79,16 +79,54 @@ struct evhttp *evhttp_new(struct event_b
+  * to multiple different ports.
+  *
+  * @param http a pointer to an evhttp object
+  * @param address a string containing the IP address to listen(2) on
+  * @param port the port number to listen on
+- * @return a newly allocated evhttp struct
++ * @return 0 on success, -1 on error
+  * @see evhttp_free()
+  */
  int evhttp_bind_socket(struct evhttp *http, const char *address, u_short port);
  
  /**
++ * Binds an HTTP server on the specified address and port, using backlog.
++ *
++ * Can be called multiple times to bind the same http server
++ * to multiple different ports.
++ *
++ * @param http a pointer to an evhttp object
++ * @param address a string containing the IP address to listen(2) on
++ * @param port the port number to listen on
++ * @param backlog the backlog value for listen(2)
++ * @return 0 on success, -1 on error
++ * @see evhttp_free()
++ */
++int evhttp_bind_socket_backlog(struct evhttp *http, const char *address, u_short port, int backlog);
++
++/**
 + * Like evhttp_bind_socket(), but returns the socket file descriptor.
 + *
 + * @param http a pointer to an evhttp object
@@ -65,11 +106,27 @@ diff -wbBdu -ur libevent-1.4.13-stable/evhttp.h libevent-1.4.13-stable-fb-fresh/
 + */
 +int evhttp_bind_socket_with_fd(struct evhttp *http, const char *address, u_short port);
 +
++/**
++ * Like evhttp_bind_socket(), but returns the socket file descriptor.
++ *
++ * @param http a pointer to an evhttp object
++ * @param address a string containing the IP address to listen(2) on
++ * @param port the port number to listen on
++ * @param backlog the backlog value for listen(2)
++ * @return Socket file descriptor on success, -1 on failure
++ * @see evhttp_bind_socket()
++ */
++int evhttp_bind_socket_backlog_fd(struct evhttp *http, const char *address, u_short port, int backlog);
++
 +/**
   * Makes an HTTP server accept connections on the specified socket
   *
   * This may be useful to create a socket and then fork multiple instances
-@@ -105,6 +116,21 @@
+  * of an http server, or when a socket has been communicated via file
+  * descriptor passing in situations where an http servers does not have
+@@ -103,10 +141,25 @@ int evhttp_bind_socket(struct evhttp *ht
+  * @see evhttp_free(), evhttp_bind_socket()
+  */
  int evhttp_accept_socket(struct evhttp *http, int fd);
  
  /**
@@ -91,7 +148,37 @@ diff -wbBdu -ur libevent-1.4.13-stable/evhttp.h libevent-1.4.13-stable-fb-fresh/
   * Free the previously created HTTP server.
   *
   * Works only if no requests are currently being served.
-@@ -157,6 +183,19 @@
+  *
+  * @param http the evhttp server object to be freed
+@@ -132,10 +185,25 @@ void evhttp_set_gencb(struct evhttp *,
+  * @param http an evhttp object
+  * @param timeout_in_secs the timeout, in seconds
+  */
+ void evhttp_set_timeout(struct evhttp *, int timeout_in_secs);
++/**
++ * Limit the number of simultaneous connections via this http instance.
++ *
++ * @param http an evhttp object
++ * @param nlimit the maximum number of connections, zero is unlimited
++ */
++int evhttp_set_connection_limit(struct evhttp *http, int nlimit);
++ 
++/**
++ * Return the maximum number of connections allowed for this instance.
++ *
++ * @param http an evhttp object
++ */
++int evhttp_get_connection_limit(struct evhttp *http);
++
+ /* Request/Response functionality */
+ /**
+  * Send an HTML error message to the client.
+  *
+@@ -155,10 +223,23 @@ void evhttp_send_error(struct evhttp_req
+  * @param databuf the body of the response
+  */
  void evhttp_send_reply(struct evhttp_request *req, int code,
      const char *reason, struct evbuffer *databuf);
  
@@ -111,7 +198,11 @@ diff -wbBdu -ur libevent-1.4.13-stable/evhttp.h libevent-1.4.13-stable-fb-fresh/
  /* Low-level response interface, for streaming/chunked replies */
  void evhttp_send_reply_start(struct evhttp_request *, int, const char *);
  void evhttp_send_reply_chunk(struct evhttp_request *, struct evbuffer *);
-@@ -210,6 +249,7 @@
+ void evhttp_send_reply_end(struct evhttp_request *);
+@@ -208,10 +289,11 @@ struct {
+       char *remote_host;
+       u_short remote_port;
  
        enum evhttp_request_kind kind;
        enum evhttp_cmd_type type;
@@ -119,19 +210,62 @@ diff -wbBdu -ur libevent-1.4.13-stable/evhttp.h libevent-1.4.13-stable-fb-fresh/
  
        char *uri;                      /* uri after HTTP request was parsed */
  
-@@ -222,6 +262,7 @@
+       char major;                     /* HTTP Major number */
+       char minor;                     /* HTTP Minor number */
+@@ -222,10 +304,12 @@ struct {
        struct evbuffer *input_buffer;  /* read data */
        ev_int64_t ntoread;
-       int chunked;
-+      int referenced;
+       int chunked:1,                  /* a chunked request */
+           userdone:1;                 /* the user has sent all data */
  
++      int referenced;
++
        struct evbuffer *output_buffer; /* outgoing post or data */
  
-Only in libevent-1.4.13-stable-fb-fresh/: fb_libevent.patch.txt
-diff -wbBdu -ur libevent-1.4.13-stable/http.c libevent-1.4.13-stable-fb-fresh/http.c
---- http.c     2009-07-01 23:05:28.000000000 -0700
-+++ http.c     2010-01-28 14:52:35.154415000 -0800
-@@ -478,7 +478,6 @@
+       /* Callback */
+       void (*cb)(struct evhttp_request *, void *);
+       void *cb_arg;
+diff -rp -U 5 libevent-1.4.14-stable/http-internal.h libevent-1.4.14-stable-fb/http-internal.h
+--- libevent-1.4.14-stable/http-internal.h     2010-06-07 14:40:35.000000000 -0700
++++ libevent-1.4.14-stable-fb/http-internal.h  2010-06-18 16:30:57.000000000 -0700
+@@ -114,10 +114,13 @@ struct evhttp {
+       TAILQ_HEAD(boundq, evhttp_bound_socket) sockets;
+       TAILQ_HEAD(httpcbq, evhttp_cb) callbacks;
+         struct evconq connections;
++        int connection_count;
++        int connection_limit;
++
+         int timeout;
+       void (*gencb)(struct evhttp_request *req, void *);
+       void *gencbarg;
+diff -rp -U 5 libevent-1.4.14-stable/http.c libevent-1.4.14-stable-fb/http.c
+--- libevent-1.4.14-stable/http.c      2010-06-07 14:40:35.000000000 -0700
++++ libevent-1.4.14-stable-fb/http.c   2010-06-18 16:35:23.000000000 -0700
+@@ -217,10 +217,17 @@ static int evhttp_decode_uri_internal(co
+     char *ret, int always_decode_plus);
+ void evhttp_read(int, short, void *);
+ void evhttp_write(int, short, void *);
++
++void evhttp_server_drop_connection(struct evhttp_connection *evcon);
++void evhttp_server_add_connection(struct evhttp *http,
++                                struct evhttp_connection *evcon);
++void evhttp_pause(struct evhttp *http);
++void evhttp_resume(struct evhttp *http);
++
+ #ifndef HAVE_STRSEP
+ /* strsep replacement for platforms that lack it.  Only works if
+  * del is one character long. */
+ static char *
+ strsep(char **s, const char *del)
+@@ -476,21 +483,19 @@ evhttp_make_header_response(struct evhtt
+                */
+               if (req->minor == 0 && is_keepalive)
                        evhttp_add_header(req->output_headers,
                            "Connection", "keep-alive");
  
@@ -139,7 +273,9 @@ diff -wbBdu -ur libevent-1.4.13-stable/http.c libevent-1.4.13-stable-fb-fresh/ht
                        /* 
                         * we need to add the content length if the
                         * user did not give it, this is required for
-@@ -488,7 +487,6 @@
+                        * persistent connections to work.
+                        */
+                       evhttp_maybe_add_content_length_header(
                                req->output_headers,
                                (long)EVBUFFER_LENGTH(req->output_buffer));
                }
@@ -147,7 +283,11 @@ diff -wbBdu -ur libevent-1.4.13-stable/http.c libevent-1.4.13-stable-fb-fresh/ht
  
        /* Potentially add headers for unidentified content. */
        if (EVBUFFER_LENGTH(req->output_buffer)) {
-@@ -675,14 +673,14 @@
+               if (evhttp_find_header(req->output_headers,
+                       "Content-Type") == NULL) {
+@@ -685,18 +690,18 @@ evhttp_connection_fail(struct evhttp_con
+ void
  evhttp_write(int fd, short what, void *arg)
  {
        struct evhttp_connection *evcon = arg;
@@ -164,7 +304,11 @@ diff -wbBdu -ur libevent-1.4.13-stable/http.c libevent-1.4.13-stable-fb-fresh/ht
        if (n == -1) {
                event_debug(("%s: evbuffer_write", __func__));
                evhttp_connection_fail(evcon, EVCON_HTTP_EOF);
-@@ -694,6 +692,7 @@
+               return;
+       }
+@@ -704,10 +709,11 @@ evhttp_write(int fd, short what, void *a
+       if (n == 0) {
+               event_debug(("%s: write nothing", __func__));
                evhttp_connection_fail(evcon, EVCON_HTTP_EOF);
                return;
        }
@@ -172,7 +316,55 @@ diff -wbBdu -ur libevent-1.4.13-stable/http.c libevent-1.4.13-stable-fb-fresh/ht
  
        if (EVBUFFER_LENGTH(evcon->output_buffer) != 0) {
                evhttp_add_event(&evcon->ev, 
-@@ -1262,19 +1261,52 @@
+                   evcon->timeout, HTTP_WRITE_TIMEOUT);
+               return;
+@@ -1010,15 +1016,13 @@ evhttp_connection_free(struct evhttp_con
+        */
+       while ((req = TAILQ_FIRST(&evcon->requests)) != NULL) {
+               TAILQ_REMOVE(&evcon->requests, req, next);
+               evhttp_request_free(req);
+       }
+-
+-      if (evcon->http_server != NULL) {
+-              struct evhttp *http = evcon->http_server;
+-              TAILQ_REMOVE(&http->connections, evcon, next);
+-      }
++      
++      if (evcon->http_server != NULL)
++              evhttp_server_drop_connection(evcon);
+       if (event_initialized(&evcon->close_ev))
+               event_del(&evcon->close_ev);
+       if (event_initialized(&evcon->ev))
+@@ -1099,14 +1103,20 @@ evhttp_connection_reset(struct evhttp_co
+               EVUTIL_CLOSESOCKET(evcon->fd);
+               evcon->fd = -1;
+       }
+       evcon->state = EVCON_DISCONNECTED;
+-      evbuffer_drain(evcon->input_buffer,
+-          EVBUFFER_LENGTH(evcon->input_buffer));
+-      evbuffer_drain(evcon->output_buffer,
+-          EVBUFFER_LENGTH(evcon->output_buffer));
++      /*
++       * These can grow quite large if processing a large photo or video
++       * upload/download.  Instead of keeping the buffers around, just
++       * free and allocate new.
++       */
++      evbuffer_free(evcon->input_buffer);
++      evcon->input_buffer = evbuffer_new();
++
++      evbuffer_free(evcon->output_buffer);
++      evcon->output_buffer = evbuffer_new();
+ }
+ static void
+ evhttp_detect_close_cb(int fd, short what, void *arg)
+ {
+@@ -1276,23 +1286,56 @@ evhttp_parse_request_line(struct evhttp_
+       /* Parse the request line */
+       method = strsep(&line, " ");
        if (line == NULL)
                return (-1);
        uri = strsep(&line, " ");
@@ -227,7 +419,11 @@ diff -wbBdu -ur libevent-1.4.13-stable/http.c libevent-1.4.13-stable-fb-fresh/ht
        } else {
                event_debug(("%s: bad method %s on request %p from %s",
                        __func__, method, req, req->remote_host));
-@@ -1939,10 +1971,44 @@
+               return (-1);
+       }
+@@ -1961,14 +2004,48 @@ evhttp_send_reply(struct evhttp_request 
+       evhttp_response_code(req, code, reason);
+       
        evhttp_send(req, databuf);
  }
  
@@ -272,47 +468,63 @@ diff -wbBdu -ur libevent-1.4.13-stable/http.c libevent-1.4.13-stable-fb-fresh/ht
        evhttp_response_code(req, code, reason);
        if (req->major == 1 && req->minor == 1) {
                /* use chunked encoding for HTTP/1.1 */
-@@ -1957,6 +2023,8 @@
- void
- evhttp_send_reply_chunk(struct evhttp_request *req, struct evbuffer *databuf)
- {
+               evhttp_add_header(req->output_headers, "Transfer-Encoding",
+                   "chunked");
+@@ -1984,10 +2061,12 @@ evhttp_send_reply_chunk(struct evhttp_re
+       struct evhttp_connection *evcon = req->evcon;
+       if (evcon == NULL)
+               return;
 +      if (req->referenced < 0) return;
 +
        if (req->chunked) {
-               evbuffer_add_printf(req->evcon->output_buffer, "%x\r\n",
+               evbuffer_add_printf(evcon->output_buffer, "%x\r\n",
                                    (unsigned)EVBUFFER_LENGTH(databuf));
-@@ -1973,6 +2041,13 @@
- {
-       struct evhttp_connection *evcon = req->evcon;
+       }
+       evbuffer_add_buffer(evcon->output_buffer, databuf);
+@@ -2005,11 +2084,18 @@ evhttp_send_reply_end(struct evhttp_requ
+       if (evcon == NULL) {
+               evhttp_request_free(req);
+               return;
+       }
+-      /* we expect no more calls form the user on this request */
++      if (req->referenced < 0) {
++              req->referenced = 0;
++              evhttp_request_free(req);
++              return;
++      }
++      req->referenced = 0;
++      
++      /* we expect no more calls form the user on this request */
+       req->userdone = 1;
  
-+      if (req->referenced < 0) {
-+              req->referenced = 0;
-+              evhttp_request_free(req);
-+              return;
-+      }
-+      req->referenced = 0;
-+
        if (req->chunked) {
                evbuffer_add(req->evcon->output_buffer, "0\r\n\r\n", 5);
                evhttp_write_buffer(req->evcon, evhttp_send_done, NULL);
-@@ -2251,6 +2326,16 @@
+@@ -2291,33 +2377,63 @@ accept_socket(int fd, short what, void *
+       evhttp_get_request(http, nfd, (struct sockaddr *)&ss, addrlen);
+ }
  int
- evhttp_bind_socket(struct evhttp *http, const char *address, u_short port)
+-evhttp_bind_socket(struct evhttp *http, const char *address, u_short port)
++evhttp_bind_socket_backlog_fd(struct evhttp *http, const char *address,
++                              u_short port, int backlog)
  {
-+      int res = evhttp_bind_socket_with_fd(http, address, port);
-+      if (res < 0) {
-+              return (res);
-+      }
-+      return (0);
-+}
-+
-+int
-+evhttp_bind_socket_with_fd(struct evhttp *http, const char *address, u_short port)
-+{
        int fd;
        int res;
  
-@@ -2265,9 +2350,11 @@
+       if ((fd = bind_socket(address, port, 1 /*reuse*/)) == -1)
+               return (-1);
+-      if (listen(fd, 128) == -1) {
++      if (listen(fd, backlog) == -1) {
+               event_warn("%s: listen", __func__);
+               EVUTIL_CLOSESOCKET(fd);
+               return (-1);
+       }
  
        res = evhttp_accept_socket(http, fd);
        
@@ -325,7 +537,42 @@ diff -wbBdu -ur libevent-1.4.13-stable/http.c libevent-1.4.13-stable-fb-fresh/ht
  
        return (res);
  }
-@@ -2301,6 +2388,25 @@
++static int
++mask_fd(int fd)
++{
++      return fd > 0 ? 0 : fd;
++}
++
++int
++evhttp_bind_socket(struct evhttp *http, const char *address, u_short port)
++{
++      return mask_fd(evhttp_bind_socket_backlog_fd(http, address, port, 128));
++}
++
++int
++evhttp_bind_socket_with_fd(struct evhttp *http, const char *address,
++                              u_short port) 
++{
++      return evhttp_bind_socket_backlog_fd(http, address, port, 128);
++}
++
++int
++evhttp_bind_socket_backlog(struct evhttp *http, const char *address,
++                              u_short port, int backlog) 
++{
++      return mask_fd(
++              evhttp_bind_socket_backlog_fd(http, address, port, backlog));
++}
++
+ int
+ evhttp_accept_socket(struct evhttp *http, int fd)
+ {
+       struct evhttp_bound_socket *bound;
+       struct event *ev;
+@@ -2343,10 +2459,29 @@ evhttp_accept_socket(struct evhttp *http
+       TAILQ_INSERT_TAIL(&http->sockets, bound, next);
        return (0);
  }
  
@@ -351,7 +598,11 @@ diff -wbBdu -ur libevent-1.4.13-stable/http.c libevent-1.4.13-stable-fb-fresh/ht
  static struct evhttp*
  evhttp_new_object(void)
  {
-@@ -2483,6 +2589,11 @@
+       struct evhttp *http = NULL;
+@@ -2525,10 +2660,15 @@ evhttp_request_new(void (*cb)(struct evh
+ }
  void
  evhttp_request_free(struct evhttp_request *req)
  {
@@ -363,3 +614,85 @@ diff -wbBdu -ur libevent-1.4.13-stable/http.c libevent-1.4.13-stable-fb-fresh/ht
        if (req->remote_host != NULL)
                free(req->remote_host);
        if (req->uri != NULL)
+               free(req->uri);
+       if (req->response_code_line != NULL)
+@@ -2655,17 +2795,76 @@ evhttp_get_request(struct evhttp *http, 
+       /* 
+        * if we want to accept more than one request on a connection,
+        * we need to know which http server it belongs to.
+        */
+-      evcon->http_server = http;
+-      TAILQ_INSERT_TAIL(&http->connections, evcon, next);
++       
++      evhttp_server_add_connection(http, evcon);
+       
+       if (evhttp_associate_new_request_with_connection(evcon) == -1)
+               evhttp_connection_free(evcon);
+ }
++void
++evhttp_pause(struct evhttp *http)
++{
++      struct evhttp_bound_socket *bound;
++      TAILQ_FOREACH(bound, &http->sockets, next) {
++              event_del(&bound->bind_ev);
++      }
++}
++
++void
++evhttp_resume(struct evhttp *http)
++{
++      struct evhttp_bound_socket *bound;
++      TAILQ_FOREACH(bound, &http->sockets, next) {
++              event_add(&bound->bind_ev, 0);
++      }
++}
++
++int
++evhttp_get_connection_limit(struct evhttp *http)
++{
++      return http->connection_limit;
++}
++
++int
++evhttp_set_connection_limit(struct evhttp *http, int nlimit)
++{
++      int olimit = http->connection_limit;
++      http->connection_limit = nlimit;
++      return olimit;
++}
++
++void
++evhttp_server_add_connection(struct evhttp *http,
++                           struct evhttp_connection *evcon)
++{
++      evcon->http_server = http;
++      TAILQ_INSERT_TAIL(&http->connections, evcon, next);
++
++      http->connection_count++;
++      if (http->connection_limit > 0
++              && http->connection_count >= http->connection_limit)
++      {
++              evhttp_pause(http);
++      }
++}
++
++void
++evhttp_server_drop_connection(struct evhttp_connection *evcon)
++{
++      struct evhttp *http = evcon->http_server;
++      TAILQ_REMOVE(&http->connections, evcon, next);
++      http->connection_count--;
++      if (http->connection_limit > 0
++              && http->connection_count < http->connection_limit)
++      {
++              evhttp_resume(http);
++      }
++}
+ /*
+  * Network helper functions that we do not want to export to the rest of
+  * the world.
+  */
+
This page took 0.135069 seconds and 4 git commands to generate.