summaryrefslogtreecommitdiff
path: root/evutil.c
Commit message (Collapse)AuthorAgeFilesLines
* Move event-config.h to include/event2Nick Mathewson2010-08-061-1/+1
| | | | | This change means that all required include files are in event2, and all files not in event2/* are optional.
* Turn our socketpair() replacement into its own functionNick Mathewson2010-08-061-6/+19
| | | | | | | | | 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.
* Pass flags to fcntl(F_SETFL) and fcntl(F_SETFD) as int, not longNick Mathewson2010-07-131-2/+2
| | | | | | | 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.
* Close the file in evutil_read_file whether there's an error or not.Pierre Phaneuf2010-05-271-1/+1
| | | | evutil_read_file would close the file if there was an error, but not if things went normally.
* Remove some dead assignmentsNick Mathewson2010-05-181-3/+0
|
* Correctly recognize .255 addresses as link-local when looking for interfacesNick Mathewson2010-05-181-1/+1
|
* Define _REENTRANT as needed on Solaris, elsewhereNick Mathewson2010-05-081-1/+0
| | | | | | | | | 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.
* Fix whitespace in evutil.cNick Mathewson2010-05-081-4/+4
|
* Fix another nasty solaris getaddrinfo() behaviorNick Mathewson2010-05-081-3/+21
| | | | | | | | | | | 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.
* Fix getaddrinfo with protocol unset on Solaris 9. Found by Dagobert MichelsenNick Mathewson2010-05-081-10/+43
| | | | | | | | | | | | 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
* Try /proc on Linux as entropy fallback; use sysctl as last resortNick Mathewson2010-05-031-0/+24
| | | | | | | | | | 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.
* Make evdns logging threadsafeNick Mathewson2010-04-231-0/+29
| | | | | | | | | 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.
* Replace EVUTIL_CLOSESOCKET macro with a functionSebastian Sjöberg2010-04-141-7/+17
| | | | | | | | | | | 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)
* Always round up when there's a fractional number of msecs.Christopher Davis2010-04-091-1/+1
|
* Add evutil_tv_to_msec for safe conversion of timevals to milliseconds.Christopher Davis2010-03-311-0/+13
| | | | | This is useful for backends that require their timeout values be in milliseconds.
* Try to comment some of the event code moreNick Mathewson2010-03-121-0/+9
|
* Avoid errors in evutil.c when building with _UNICODE definedBrodie Thiesfield2010-03-081-1/+3
|
* Update all our copyright notices to say "2010"Nick Mathewson2010-03-041-1/+1
|
* Small cleanups on freebsd-connect-refused patch.Nick Mathewson2010-02-271-0/+1
| | | | | | | | | | | | 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.
* deal with connect() failing immediatelyNiels Provos2010-02-271-1/+3
|
* Clean up formatting: function/keyword spacing consistency.Nick Mathewson2010-02-191-1/+1
| | | | | | - Keywords always have a space before a paren. Functions never do. - No more than 3 blank lines in a row.
* Clean up formatting: use tabs, not 8-spaces, to indent.Nick Mathewson2010-02-181-18/+18
|
* Add an arc4random implementation for use by evdnsNick Mathewson2010-02-111-2/+2
| | | | | | | | | | 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.
* Always use our own gai_strerror() replacement.Nick Mathewson2010-02-051-7/+13
| | | | | This is necessary if we have any errors that the platform gai_strerror() doesn't know how to handle.
* Add a check to make soure our EVUTIL_AI flags do not conflict with the ↵Nick Mathewson2010-02-051-0/+9
| | | | native ones
* Fix windows and msvc buildNick Mathewson2010-01-231-0/+1
|
* Fix a number of warnings from gcc -pedanticNick Mathewson2010-01-231-2/+2
|
* Remove some commented-out code in evutilNick Mathewson2010-01-211-7/+0
|
* Don't use a bind address for nameservers on loopbackNick Mathewson2010-01-201-0/+22
| | | | | | | 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.
* Refactor code from evdns into a new internal "read a file" function.Nick Mathewson2010-01-081-0/+62
|
* Merge branch 'ratelimit'Nick Mathewson2010-01-061-0/+11
|\ | | | | | | | | Conflicts: bufferevent_async.c
| * Fix compilation of rate-limiting code on win32.Nick Mathewson2009-12-301-0/+11
| |
* | Introduced evutil_make_socket_closeonexec() to preserve fd flags for F_SETFD.Jardel Weyrich2009-12-291-0/+17
| | | | | | | | | | Use this to eliminate the various macros that called F_SETFD throughout the code.
* | Adjusted fcntl() retval comparison on evutil_make_socket_nonblocking().Jardel Weyrich2009-12-291-3/+3
|/ | | | | Apparently, a successful return value on F_SETFL is "anything but -1".
* Improve readability of evutil_unparse_protoname()Jardel Weyrich2009-12-281-10/+13
|
* Fix a bogus free in evutil_new_addrinfo()Jardel Weyrich2009-12-281-1/+1
|
* Make evutil_make_socket_nonblocking() leave any other flags alone.Jardel Weyrich2009-12-281-3/+10
| | | | Fixes bug 2922121
* Do the proper hack for the (Open)BSD getaddrinfo quirk.Nick Mathewson2009-11-181-43/+143
| | | | | | | | | | | | | | | | | | | | | 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
* Clarify even more about various system-specific problems with getaddrinfoNick Mathewson2009-11-171-4/+10
| | | | svn:r1542
* Use the common-case code from getaddrinfo_common *always*; OS differences ↵Nick Mathewson2009-11-171-7/+17
| | | | | | are just too huge. svn:r1541
* Never pass our weird flags to the system getaddrinfo. Make sure there is no ↵Nick Mathewson2009-11-171-4/+65
| | | | | | overlap between flag values. svn:r1540
* Windows *does* have getservbyname, no matter what autoconf says.Nick Mathewson2009-11-171-1/+1
| | | | | | TODO: figure out why autoconf is confused about this. svn:r1538
* Add two implementations of getaddrinfo: one blocking and one nonblocking.Nick Mathewson2009-11-161-67/+659
| | | | | | | | | | | | | 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
* When running set[ug]id, don't check the environment.Nick Mathewson2009-11-151-0/+28
| | | | | | | Idea from OpenBSD, but made a bit more generic to handle uncivilized lands that do not define issetugid. svn:r1530
* We do not work any more without an event-config.h; stop pretending that it ↵Nick Mathewson2009-11-061-2/+1
| | | | | | is meaningful to check for HAVE_CONFIG_H svn:r1516
* Add a bufferevent function to resolve a name then connect to it.Nick Mathewson2009-11-031-0/+89
| | | | | | | | | | | 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
* When a bufferevent_connect() call fails, give the client an error callback.Nick Mathewson2009-10-141-0/+23
| | | | | | Patch from Christopher Davis. svn:r1444
* Export sockaddr comparison functionality.Nick Mathewson2009-07-301-0/+39
| | | | svn:r1400
* Export an ev_socklen_t.Nick Mathewson2009-07-301-1/+1
| | | | svn:r1391
* Export evutil_str[n]casecmp as evutil_ascii_str[n]casecmp.Nick Mathewson2009-07-281-2/+2
| | | | svn:r1387