]> granicus.if.org Git - libevent/commitdiff
Merge remote-tracking branch 'origin/patches-2.0'
authorNick Mathewson <nickm@torproject.org>
Tue, 5 Jul 2011 18:38:21 +0000 (14:38 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 5 Jul 2011 18:38:21 +0000 (14:38 -0400)
Conflicts:
include/event2/buffer.h
include/event2/thread.h
include/event2/util.h

1  2 
event.h
include/event2/buffer.h
include/event2/dns.h
include/event2/dns_compat.h
include/event2/http.h
include/event2/thread.h
include/event2/util.h

diff --cc event.h
Simple merge
index 7e2fc3152cff66926e0c20874420dddad639adc3,19f6f90ab04607550ae8e456e7cc91869940bd26..b5acbb5b138185a1e34f5494b8d0c56332d12cbd
@@@ -365,120 -414,19 +414,128 @@@ int evbuffer_add_reference(struct evbuf
    The function owns the resulting file descriptor and will close it
    when finished transferring data.
  
-   The results of using evbuffer_remove() or evbuffer_pullup() are
-   undefined.
+   The results of using evbuffer_remove() or evbuffer_pullup() on
+   evbuffers whose data was added using this function are undefined.
  
 +  For more fine-grained control, use evbuffer_add_file_segment.
 +
    @param outbuf the output buffer
    @param fd the file descriptor
++<<<<<<< HEAD
 +  @param off the offset from which to read data
 +  @param length how much data to read, or -1 to read as much as possible.
 +    (-1 requires that 'fd' support fstat.)
++||||||| merged common ancestors
++  @param off the offset from which to read data
++  @param length how much data to read
++=======
+   @param offset the offset from which to read data
+   @param length how much data to read
++>>>>>>> origin/patches-2.0
    @return 0 if successful, or -1 if an error occurred
  */
  
- int evbuffer_add_file(struct evbuffer *output, int fd, ev_off_t offset,
+ int evbuffer_add_file(struct evbuffer *outbuf, int fd, ev_off_t offset,
      ev_off_t length);
  
 +/**
 +  An evbuffer_file_segment holds a reference to a range of a file --
 +  possibly the whole file! -- for use in writing from an evbuffer to a
 +  socket.  It could be implemented with mmap, sendfile, splice, or (if all
 +  else fails) by just pulling all the data into RAM.  A single
 +  evbuffer_file_segment can be added more than once, and to more than one
 +  evbuffer.
 + */
 +struct evbuffer_file_segment;
 +
 +/**
 +    Flag for creating evbuffer_file_segment: If this flag is set, then when
 +    the evbuffer_file_segment is freed and no longer in use by any
 +    evbuffer, the underlying fd is closed.
 + */
 +#define EVBUF_FS_CLOSE_ON_FREE    0x01
 +/**
 +   Flag for creating evbuffer_file_segment: Disable memory-map based
 +   implementations.
 + */
 +#define EVBUF_FS_DISABLE_MMAP     0x02
 +/**
 +   Flag for creating evbuffer_file_segment: Disable direct fd-to-fd
 +   implementations (including sendfile and splice).
 +
 +   You might want to use this option if data needs to be taken from the
 +   evbuffer by any means other than writing it to the network: the sendfile
 +   backend is fast, but it only works for sending files directly to the
 +   network.
 + */
 +#define EVBUF_FS_DISABLE_SENDFILE 0x04
 +/**
 +   Flag for creating evbuffer_file_segment: Do not allocate a lock for this
 +   segment.  If this option is set, then neither the segment nor any
 +   evbuffer it is added to may ever be accessed from more than one thread
 +   at a time.
 + */
 +#define EVBUF_FS_DISABLE_LOCKING  0x08
 +
 +/**
 +   Create and return a new evbuffer_file_segment for reading data from a
 +   file and sending it out via an evbuffer.
 +
 +   This function avoids unnecessary data copies between userland and
 +   kernel.  Where available, it uses sendfile or splice.
 +
 +   The file descriptor must not be closed so long as any evbuffer is using
 +   this segment.
 +
 +   The results of using evbuffer_remove() or evbuffer_pullup() or any other
 +   function that reads bytes from an evbuffer on any evbuffer containing
 +   the newly returned segment are undefined, unless you pass the
 +   EVBUF_FS_DISABLE_SENDFILE flag to this function.
 +
 +   @param fd an open file to read from.
 +   @param offset an index within the file at which to start reading
 +   @param length how much data to read, or -1 to read as much as possible.
 +      (-1 requires that 'fd' support fstat.)
 +   @param flags any number of the EVBUF_FS_* flags
 +   @return a new evbuffer_file_segment, or NULL on failure.
 + **/
 +struct evbuffer_file_segment *evbuffer_file_segment_new(
 +      int fd, ev_off_t offset, ev_off_t length, unsigned flags);
 +
 +/**
 +   Free an evbuffer_file_segment
 +
 +   It is safe to call this function even if the segment has been added to
 +   one or more evbuffers.  The evbuffer_file_segment will not be freed
 +   until no more references to it exist.
 + */
 +void evbuffer_file_segment_free(struct evbuffer_file_segment *seg);
 +
 +/**
 +   Insert some or all of an evbuffer_file_segment at the end of an evbuffer
 +
 +   Note that the offset and length parameters of this function have a
 +   different meaning from those provided to evbuffer_file_segment_new: When
 +   you create the segment, the offset is the offset _within the file_, and
 +   the length is the length _of the segment_, whereas when you add a
 +   segment to an evbuffer, the offset is _within the segment_ and the
 +   length is the length of the _part of the segment you want to use.
 +
 +   In other words, if you have a 10 KiB file, and you create an
 +   evbuffer_file_segment for it with offset 20 and length 1000, it will
 +   refer to bytes 20..1019 inclusive.  If you then pass this segment to
 +   evbuffer_add_file_segment and specify an offset of 20 and a length of
 +   50, you will be adding bytes 40..99 inclusive.
 +
 +   @param buf the evbuffer to append to
 +   @param seg the segment to add
 +   @param offset the offset within the segment to start from
 +   @param length the amount of data to add, or -1 to add it all.
 +   @return 0 on success, -1 on failure.
 + */
 +int evbuffer_add_file_segment(struct evbuffer *buf,
 +    struct evbuffer_file_segment *seg, ev_off_t offset, ev_off_t length);
 +
  /**
    Append a formatted string to the end of an evbuffer.
  
Simple merge
Simple merge
Simple merge
index f5b4fe3bd0e9cddc3b06f3d1f716eb88ae0c3f92,2cf11aa8e9a52f391fe65f0f8a1995a3abb3ddaa..3e7216d1237f39317fdff4911929209521f9c937
@@@ -183,12 -187,15 +187,15 @@@ int evthread_set_condition_callbacks
  void evthread_set_id_callback(
      unsigned long (*id_fn)(void));
  
- #if defined(_WIN32) && !defined(_EVENT_DISABLE_THREAD_SUPPORT)
 -#if (defined(WIN32) && !defined(_EVENT_DISABLE_THREAD_SUPPORT)) || defined(_EVENT_IN_DOXYGEN)
++#if (defined(_WIN32) && !defined(_EVENT_DISABLE_THREAD_SUPPORT)) || defined(_EVENT_IN_DOXYGEN)
  /** Sets up Libevent for use with Windows builtin locking and thread ID
-       functions.  Unavailable if Libevent is not built for Windows.
+     functions.  Unavailable if Libevent is not built for Windows.
  
-       @return 0 on success, -1 on failure. */
+     @return 0 on success, -1 on failure. */
  int evthread_use_windows_threads(void);
+ /**
+    Defined if Libevent was built with support for evthread_use_windows_threads()
+ */
  #define EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED 1
  #endif
  
index 687c92d97249e0bd28dd588ccb17b1650d2dce16,67fa809f1629838bef210e0967c497603ab9647c..c71fdcf510cded8ebbc0f6ed35a83aa295982be3
@@@ -200,8 -248,9 +248,9 @@@ extern "C" 
  #endif
  
  #define EV_SSIZE_MIN ((-EV_SSIZE_MAX) - 1)
+ /**@}*/
  
 -#ifdef WIN32
 +#ifdef _WIN32
  #define ev_socklen_t int
  #elif defined(_EVENT_socklen_t)
  #define ev_socklen_t _EVENT_socklen_t
  #endif
  #endif
  
- #ifdef _WIN32
/** A type wide enough to hold the output of "socket()" or "accept()".  On
+ /**
 * A type wide enough to hold the output of "socket()" or "accept()".  On
   * Windows, this is an intptr_t; elsewhere, it is an int. */
 -#ifdef WIN32
++#ifdef _WIN32
  #define evutil_socket_t intptr_t
  #else
  #define evutil_socket_t int
@@@ -267,13 -323,8 +323,8 @@@ int evutil_make_socket_closeonexec(evut
  int evutil_closesocket(evutil_socket_t sock);
  #define EVUTIL_CLOSESOCKET(s) evutil_closesocket(s)
  
- /* Winsock handles socket errors differently from the rest of the world.
-  * Elsewhere, a socket error is like any other error and is stored in errno.
-  * But winsock functions require you to retrieve the error with a special
-  * function, and don't let you use strerror for the error codes.  And handling
-  * EWOULDBLOCK is ... different. */
  
 -#ifdef WIN32
 +#ifdef _WIN32
  /** Return the most recent socket error.  Not idempotent on all platforms. */
  #define EVUTIL_SOCKET_ERROR() WSAGetLastError()
  /** Replace the most recent socket error with errcode */