kc3-lang/libevent/evutil.c

Branch :


Log

Author Commit Date CI Message
22845886 2011-01-31 16:45:23 Merge remote branch 'origin/patches-2.0'
3c8f4e75 2011-01-31 16:44:06 Add compile-time check for AF_UNSPEC==PF_UNSPEC
cb921139 2011-01-31 16:32:05 Build on systems without AI_PASSIVE
453317b2 2011-01-24 18:22:32 Fall back to sscanf if we have no other way to implement strtoll
8b0afe96 2011-01-12 21:41:58 Merge remote branch 'origin/patches-2.0'
666b0966 2010-12-18 01:07:27 Detect and handle more allocation failures.
9b27b307 2011-01-02 08:04:12 Remove event-private.h and switch to evconfig-private.h
c51ef930 2010-12-22 23:24:01 Eliminate a couple more manual internal _GNU_SOURCE defines
b8b8aa56 2010-09-02 17:52:20 Use GetSystemTimeAsFileTime to implement gettimeofday on win32. It is (in my benchmarks) way faster than _ftime, though the conversion process is not so straightforward. In theory, it can have a better granularity too, though in practice who knows what you're getting.
22f4af65 2010-12-09 11:43:12 Remove end-of-line whitespace
32390732 2010-11-23 19:40:23 Fix snprintf related failures on IRIX.
49418612 2010-11-16 12:55:10 Use the US-English "canceled", not the UK "cancelled".
a3245afe 2010-11-01 14:23:33 Fix win32 build in response to fixes from win64 build.
f8095d64 2010-11-01 14:15:34 Fix a typo in 7484df61c981fc33db2~
7484df61 2010-11-01 13:43:43 Fix even more win64 warnings
19c71e74 2010-10-27 10:36:08 Fix som event_warns that should have been event_warnx
f5ad31c1 2010-10-27 12:47:07 Check return value for ioctlsocket on win32
a8b7674c 2010-09-28 01:09:17 Merge remote branch 'github/signed_compare'
d49b5e33 2010-09-27 15:12:55 Do not search outside of the system directory for windows DLLs Hardens against some attacks.
9c8db0f8 2010-09-23 22:45:55 Fix all warnings in the main codebase flagged by -Wsigned-compare Remember, the code int is_less_than(int a, unsigned b) { return a < b; } is buggy, since the C integer promotion rules basically turn it into int is_less_than(int a, unsigned b) { return ((unsigned)a) < b; } and we really want something closer to int is_less_than(int a, unsigned b) { return a < 0 || ((unsigned)a) < b; } . Suggested by an example from Ralph Castain
57d3413c 2010-09-08 11:39:24 Merge remote branch 'github/globals'
e50c0fcc 2010-09-02 11:10:50 Use the _func() replacements for open, fstat, etc in evutil.c on win32 Remember that in a fit of ANSI C compliance, Microsoft decided to screw portability by renaming basically all the functions in unistd.h to get prefixed with an understore. For some reason, mingw didn't seem to mind, but at least some people's compilers did: see bug 3044490.
1fdec20f 2010-09-01 15:01:39 Stop using global arrays to implement the EVUTIL_ctype functions These apparently made libtool sad on win32, and the function call overhead here should be negligable anyway.
ec347b92 2010-07-07 16:45:03 Move event-config.h to include/event2 This change means that all required include files are in event2, and all files not in event2/* are optional.
57b30cd7 2010-08-06 13:01:32 Turn our socketpair() replacement into its own function This patch splits the formerly windows-only case of evutil_socketpair() into an (internal-use-only) function named evutil_ersatz_socketpair(), and makes it build and work right on non-Windows hosts. We need this for convenience to test sendfile on solaris, where socketpair can't give you an AF_INET pair, and sendfile() won't work on AF_UNIX.
7c2dea16 2010-07-13 11:06:08 Pass flags to fcntl(F_SETFL) and fcntl(F_SETFD) as int, not long Everybody but Linux documents this as taking an int, and Linux is very tolerant of getting an int instead. If it weren't, everybody doing fcntl(fd,F_SETFL,O_NONBLOCK) would break, since the glibc headers define O_NONBLOCK as an int literal.
0798dd12 2010-05-27 22:37:09 Close the file in evutil_read_file whether there's an error or not. evutil_read_file would close the file if there was an error, but not if things went normally.
47c5dfbe 2010-05-18 17:28:51 Remove some dead assignments
8c3452bc 2010-05-18 13:55:32 Correctly recognize .255 addresses as link-local when looking for interfaces
c1cd32a1 2010-05-08 22:21:52 Define _REENTRANT as needed on Solaris, elsewhere It turns out that _REENTRANT isn't only needed to make certain functions visible; we also need it to make pthreads work properly some places (like Solaris, where forgetting _REENTRANT basically means that all threads are sharing the same errno). Fortunately, our ACX_PTHREAD() configure macro already gives us a PTHREAD_CFLAG variable, so all we have to do is use it.
935e1504 2010-05-08 19:36:05 Fix whitespace in evutil.c
35570716 2010-05-08 19:16:47 Fix another nasty solaris getaddrinfo() behavior Everybody else thinks that when you getaddrinfo() on an ip address and don't specify the protocol and the socktype, it should give you multiple answers , one for each protocol/socktype implementation. OpenSolaris takes a funny view of RFC3493, and leaves the results set to 0. This patch post-processes the getaddrinfo() results for consistency.
2cf2a286 2010-04-21 11:57:55 Fix getaddrinfo with protocol unset on Solaris 9. Found by Dagobert Michelsen Apparently when you call Solaris 9's getaddrinfo(), it likes to leave ai_protocol unset in the result. This is no way to behave, if I'm reading RFC3493 right. This patch makes us check for a getaddrinfo() that's broken in this way, and work around it by trying to infer socktype and protocol from one another. Partial bugfix for 2987542
20fda296 2010-05-03 13:00:00 Try /proc on Linux as entropy fallback; use sysctl as last resort It turns out that the happy fun Linux kernel is deprecating sysctl, and using sysctl to fetch entropy will spew messages in the kernel logs. Let's not do that. Instead, let's call sysctl for our entropy only when all other means fail. Additionally, let's add another means, and try /proc/sys/kernel/random/uuid if /dev/urandom fails.
b1c79500 2010-04-23 14:42:25 Make evdns logging threadsafe The old logging code was littered with places where we stored messages in static char[] fields. This is fine in a single-threaded program, but if you ever tried to log evdns messages from two threads at once, you'd hit a race. This patch also refactors evdns's debug_ntop function into a more useful evutil_sockaddr_port_format() function, with unit tests.
899c1dcc 2010-04-14 15:42:57 Replace EVUTIL_CLOSESOCKET macro with a function The EVUTIL_CLOSESOCKET() macro required you to include unistd.h in your source for POSIX. We might as well turn it into a function: an extra function call is going to be cheap in comparison with the system call. We retain the EVUTIL_CLOSESOCKET() macro as an alias for the new evutil_closesocket() function. (commit message from email by Nick and Sebastian)
8f9e60c8 2010-04-09 19:16:09 Always round up when there's a fractional number of msecs.
850c3ff2 2010-03-31 20:30:55 Add evutil_tv_to_msec for safe conversion of timevals to milliseconds. This is useful for backends that require their timeout values be in milliseconds.
cdd4c490 2010-03-11 00:38:46 Try to comment some of the event code more
b677032b 2010-03-08 13:46:04 Avoid errors in evutil.c when building with _UNICODE defined
17efc1cd 2010-03-04 01:25:51 Update all our copyright notices to say "2010"
57b72488 2010-02-27 22:27:13 Small cleanups on freebsd-connect-refused patch. There should be no need to call be_socket_enable: that does an event_add(). What we really want to do is event_active(), to make sure that the writecb is executed. Also, there was one "} if () {" that was missing an else. I've noted that the return value for evutil_socket_connect() is getting screwy, but since that isn't an exported function, we can fix it whenever.
7bc48bfd 2010-02-27 18:59:06 deal with connect() failing immediately
4faeaea9 2010-02-19 03:39:50 Clean up formatting: function/keyword spacing consistency. - Keywords always have a space before a paren. Functions never do. - No more than 3 blank lines in a row.
e5bbd40a 2010-02-18 17:41:15 Clean up formatting: use tabs, not 8-spaces, to indent.
d4de062e 2010-02-10 17:19:18 Add an arc4random implementation for use by evdns Previously, evdns was at the mercy of the user for providing a good entropy source; without one, it would be vulnerable to various active attacks. This patch adds a port of OpenBSD's arc4random() calls to Libevent [port by Chris Davis], and wraps it up a little bit so we can use it more safely.
6810bdb1 2010-02-05 13:50:51 Always use our own gai_strerror() replacement. This is necessary if we have any errors that the platform gai_strerror() doesn't know how to handle.
c18490e6 2010-02-05 01:09:01 Add a check to make soure our EVUTIL_AI flags do not conflict with the native ones
5c7a7bca 2010-01-23 20:07:05 Fix windows and msvc build
918e9c5e 2010-01-23 16:38:36 Fix a number of warnings from gcc -pedantic
26e1b6f2 2010-01-21 01:51:40 Remove some commented-out code in evutil
8d4aaf90 2010-01-20 12:56:54 Don't use a bind address for nameservers on loopback If the user sets a bind address to use for nameservers, and a nameserver happens to be on 127.0.0.1, the nameserver will generally fail. This patch alters this behavior so that the bind address is only applied when the nameserver is on a non-loopback address.
0f7144fd 2009-12-07 17:21:13 Refactor code from evdns into a new internal "read a file" function.
ba2945f9 2010-01-06 17:59:44 Merge branch 'ratelimit' Conflicts: bufferevent_async.c
165d30e3 2009-12-30 14:29:56 Fix compilation of rate-limiting code on win32.
d0939d2b 2009-12-29 16:21:26 Introduced evutil_make_socket_closeonexec() to preserve fd flags for F_SETFD. Use this to eliminate the various macros that called F_SETFD throughout the code.
4df7dbcb 2009-12-29 16:19:24 Adjusted fcntl() retval comparison on evutil_make_socket_nonblocking(). Apparently, a successful return value on F_SETFL is "anything but -1".
5a43df82 2009-12-28 16:03:47 Improve readability of evutil_unparse_protoname()
0d64051f 2009-12-28 16:01:59 Fix a bogus free in evutil_new_addrinfo()
4c8b7cdc 2009-12-28 16:00:05 Make evutil_make_socket_nonblocking() leave any other flags alone. Fixes bug 2922121
f070a4ae 2009-11-18 23:18:55 Do the proper hack for the (Open)BSD getaddrinfo quirk. From evutil.c: Some older BSDs (like OpenBSD up to 4.6) used to believe that giving a numeric port without giving an ai_socktype was verboten. We test for this so we can apply an appropriate workaround. If it turns out that the bug is present, then: - If nodename==NULL and servname is numeric, we build an answer ourselves using evutil_getaddrinfo_common(). - If nodename!=NULL and servname is numeric, then we set servname=NULL when calling getaddrinfo, and post-process the result to set the ports on it. We test for this bug at runtime, since otherwise we can't have the same binary run on multiple BSD versions. svn:r1550
201d8d0b 2009-11-17 18:29:44 Clarify even more about various system-specific problems with getaddrinfo svn:r1542
9151d000 2009-11-17 03:36:43 Use the common-case code from getaddrinfo_common *always*; OS differences are just too huge. svn:r1541
3451c870 2009-11-17 02:57:32 Never pass our weird flags to the system getaddrinfo. Make sure there is no overlap between flag values. svn:r1540
888007f9 2009-11-17 02:38:19 Windows *does* have getservbyname, no matter what autoconf says. TODO: figure out why autoconf is confused about this. svn:r1538
86f57420 2009-11-16 22:25:46 Add two implementations of getaddrinfo: one blocking and one nonblocking. The entry points are evutil_getaddrinfo and evdns_getaddrinfo respectively. There are fairly extensive unit tests. I believe this code conforms to RFC3493 pretty closely, but there are probably more issues. It should get tested on more platforms. This code means we can dump the well-intentioned but weirdly-implemented bufferevent_evdns and evutil_resolve code. svn:r1537
629a6133 2009-11-15 18:59:59 When running set[ug]id, don't check the environment. Idea from OpenBSD, but made a bit more generic to handle uncivilized lands that do not define issetugid. svn:r1530
784b8773 2009-11-06 21:46:57 We do not work any more without an event-config.h; stop pretending that it is meaningful to check for HAVE_CONFIG_H svn:r1516
0b9eb1bf 2009-11-03 20:40:48 Add a bufferevent function to resolve a name then connect to it. This function, bufferevent_socket_connect_hostname() can either use evdns to do the resolve, or use a new function (evutil_resolve) that uses getaddrinfo or gethostbyname, like http.c does now. This function is meant to eventually replace the hostname resolution mess in http.c. svn:r1496
25af6954 2009-10-14 00:46:47 When a bufferevent_connect() call fails, give the client an error callback. Patch from Christopher Davis. svn:r1444
621aafd2 2009-07-30 22:11:23 Export sockaddr comparison functionality. svn:r1400
7c20a6ae 2009-07-30 17:01:21 Export an ev_socklen_t. svn:r1391
72ea534f 2009-07-28 19:41:57 Export evutil_str[n]casecmp as evutil_ascii_str[n]casecmp. svn:r1387
709c21c4 2009-07-28 04:03:57 Bufferevent support for openssl. This code adds a new Bufferevent type that is only compiled when the openssl library is present. It supports using an SSL object and an event alert mechanism, which can either be an fd or an underlying bufferevent. There is still more work to do: the unit tests are incomplete, and we need to support flush and shutdown much better. Sometimes events are generated needlessly: this will hose performance. There's a new encrypting proxy in sample/le-proxy.c. This code has only been tested on OSX, and nowhere else. svn:r1382
043515bc 2009-07-14 18:50:06 Stop using C++ style comments. svn:r1343
01be8708 2009-06-11 19:09:08 Fix compile on cygwin. This isnt the solution I would like: I would prefer to get pton and ntop to work even when AF_INET6 is not defined. svn:r1326
f11dff2c 2009-05-07 03:45:51 Add and use locale-independent strcasecmp functions. svn:r1280
ebf29455 2009-04-30 23:49:15 Compilation fixes for vc++ 2008 express. Not the end of them. svn:r1260
50e20fe0 2009-04-29 20:48:35 fix a typo in a comment svn:r1251
a835c7cf 2009-04-18 18:27:56 fix a misindent svn:r1200
acaf65c3 2009-02-11 17:23:32 Make evutil_parse_sockaddr_port give a useful socket-length output. svn:r1118
cd731b77 2009-02-10 21:40:12 Do not use ctypes functions in cases when we need the "net" locale. This patch adds a new set of EVUTIL_IS* functions to replace use of the ctypes is* functions in all cases where we care about characters' interpretations in net ascii rather than in the locale. For example, when we're working with DNS hostnames, we don't want to do the 0x20 hack on non-ascii characters, even if the host thinks they should be isalpha. svn:r1114
da49d6a3 2009-02-10 19:43:11 Stop using platform inet_aton/inet_addr; they can behave strangely on certain misformed addresses. svn:r1111
c7b2f8fd 2009-02-10 19:38:05 New function to abstract SO_REUSEADDR. svn:r1102
722885fb 2009-02-02 21:59:53 Some mingws have AF_UNIX, which may have prevented our socketpair from working at all on them. Fix that. svn:r1098
f13bede7 2009-01-28 20:31:19 Fix an unlikely degenerate case of evutil_vsnprintf svn:r1067
b85b710c 2009-01-27 22:34:36 Update copyright statements to reflect the facts that: a) this is 2009 b) niels and nick have been comaintainers for a while c) saying "all rights reserved" when you then go on to explicitly disclaim some rights is sheer cargo-cultism. svn:r1065
8889a770 2009-01-27 22:30:46 Replace all use of config.h with event-config.h. svn:r1064
9993137c 2009-01-27 21:10:31 Remove all trailing whitespace in all the source files. svn:r1063
70405e3c 2009-01-21 07:18:31 fix freebsd compile; from Alexander Drozdov svn:r1030
9935d5b0 2009-01-13 21:39:32 Fix win32 compilation. Surprisingly, unit tests pass too. svn:r1002
169321c9 2009-01-13 20:26:37 Rename four internal headers to follow the -internal.h convention. svn:r1000
980bcd68 2009-01-02 21:21:58 Work better with platforms that do not have ipv6 structures, or that do not have sin_len fields, etc. svn:r986
cfbd1680 2009-01-02 20:46:26 Add another function to parse the common address:port combination formats into a sockaddr. svn:r984
0d9d5cfe 2009-01-02 20:46:12 New functions in evutil to clone inet_pton and inet_ntop, with tests. Adapted from Tor code. svn:r983
fded0a87 2008-09-05 16:47:04 Fix compilation of recent error code with win32. svn:r937
de069b99 2008-09-05 16:29:56 On win32, errno is not the last socket error. Worse, WSAGetLastError() is not the last socket error sometimes (i.e., EWOULDBLOCK). Also, strerror() does not handle winsock errors. Therefore, event_err() and event_warn() are completely wrong for windows socket errors. Fix that. svn:r936
55f91494 2008-06-24 16:29:02 fix evutil_snprintf on windows svn:r860
0cafdeb6 2008-05-12 17:16:47 Tweaks to make unit tests fail less badly on mingw on trunk. svn:r814
c6da86ff 2008-05-12 16:44:24 r19709@catbus: nickm | 2008-05-12 12:42:48 -0400 Possible fix for [1960723] snprintf and vsnprintf return values are wrong on win32 svn:r813