libevent / libevent Goto Github PK
View Code? Open in Web Editor NEWEvent notification library
Home Page: https://libevent.org
License: Other
Event notification library
Home Page: https://libevent.org
License: Other
Here's what I observe:
Here's what the SSL man page says about the SYSCALL error:
SSL_ERROR_SYSCALL
Some I/O error occurred. The OpenSSL error queue may contain more
information on the error. If the error queue is empty (i.e.
ERR_get_error() returns 0), ret can be used to find out more about the
error: If ret == 0, an EOF was observed that violates the protocol.
If ret == -1, the underlying BIO reported an I/O error (for socket I/O
on Unix systems, consult errno for details).
Since ret is -1 and errno is 0, I'm not sure where to go next. In particular, I'm not sure how to isolate this to libevent (vs. an OpenSSL issue).
Note that this happens non-deterministically and typically under high load. I'm on Ubuntu 12.04 using libevent 2.0.19 and OpenSSL 1.0.0e
I'm not seeing any crashes due to libevent. I am seeing spurious SSL failures though -- spurious, in the
sense that I get the SYSCALL error but ret is -1 and errno returns 0. Here's a stack trace when that happens:
#0 0x00007fff8e4dace2 in __pthread_kill ()
#1 0x00007fff867957d2 in pthread_kill ()
#2 0x00007fff86786a7a in abort ()
#3 0x00000001007ca309 in conn_closed (bev_ssl=<value temporarily
unavailable, due to optimizations>, errcode=<value temporarily
unavailable, due to optimizations>, ret=<value temporarily
unavailable, due to optimizations>) at bufferevent_openssl.c:504
#4 0x00000001007ca5cf in do_read (bev_ssl=0x101d262e0, n_to_read=0)
at bufferevent_openssl.c:614
#5 0x00000001007cabec in consider_reading (bev_ssl=0x101d262e0) at
bufferevent_openssl.c:779
#6 0x00000001007c11ef in bufferevent_run_deferred_callbacks_unlocked
() at TAsyncChannel.cpp:834
#7 0x00000001007b9a75 in event_base_loop () at TAsyncChannel.cpp:834
Disregard the first 3 frames -- I added the abort as a cheap hack to get a quick stack trace.
Per the libevent book, setting a timeout to NULL disables it:
Setting a timeout to NULL removes it.
However, this does not work. Specifically, setting the timeout to NULL doesn't seem to be doing anything -- any previous timeouts continue to fire. I have carved out a minimal program that demonstrates this; will create a gist and include it here shortly.
I thought that this call would leave the event pending, but remove its timeout entirely. Looking at the code, I'm not sure this is what we do. We should probably document this if so; it is surprising behavior.
This is with libevent 2.0.21
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x12d
Stack frame #00 pc 00024872 mylib.so: Routine evdns_request_transmit in libevent/evdns.c:2262
Stack frame #01 pc 00024c29 mylib.so: Routine evdns_requests_pump_waiting_queue in libevent/evdns.c:760
Stack frame #02 pc 000273a9 mylib.so: Routine evdns_base_resume in libevent/evdns.c:2448
The line numbers are a little funny I think because of gcc optimization. Anyway, on this system, it appears that 0x12d matches the offset of the choked
member of a struct nameserver *
which is NULL. So the crash is probably in the access to req->ns->choked
where req->ns
is NULL. Not sure how it got to be NULL -- right before this, I did this:
void update_dns()
{
evdns_base_clear_nameservers_and_suspend(g_evdns_base);
evdns_base_nameserver_ip_add(g_evdns_base, "8.8.8.8");
evdns_base_nameserver_ip_add(g_evdns_base, "8.8.4.4");
// crashes in here
evdns_base_resume(g_evdns_base);
}
Hi,
I am using Libevent to write my code. My program terminated after 20 days of running.
Here is the core dump I obeseve
#0 0x00007fa23513c025 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00007fa23513c025 in raise () from /lib64/libc.so.6
#1 0x00007fa23513d3d5 in abort () from /lib64/libc.so.6
#2 0x00007fa23643afc1 in ?? () from /lib64/libevent-2.0.so.5
#3 0x00007fa23643b065 in event_errx () from /lib64/libevent-2.0.so.5
#4 0x00007fa2364331b4 in _evbuffer_decref_and_unlock () from /lib64/libevent-2.0.so.5
#5 0x00007fa23643337d in evbuffer_free () from /lib64/libevent-2.0.so.5
#6 0x00007fa236434fc9 in _bufferevent_decref_and_unlock () from /lib64/libevent-2.0.so.5
#7 0x00007fa23643517d in bufferevent_enable () from /lib64/libevent-2.0.so.5
#8 0x000000000043e529 in setupConnection (listener=0x2630fc0, cfd=53, address=0x7fffd5cf2720, socklen=16, ctx=0x7fffd5cf2910)
at mycode.c:180
#9 0x00007fa236438564 in ?? () from /lib64/libevent-2.0.so.5
#10 0x00007fa23642ebee in event_base_loop () from /lib64/libevent-2.0.so.5
#11 0x00007fa23642ee73 in event_base_dispatch () from /lib64/libevent-2.0.so.5
Does this problem belong to libevent bugs?
my libevent version is libevent_2.0.16
_evdns_log
has a clause to use default_evdns_log_fn
, but only if evdns_log_fn
is NULL. However, it starts by returning if evdns_log_fn
is NULL.
static void
_evdns_log(int warn, const char *fmt, ...)
{
va_list args;
char buf[512];
if (!evdns_log_fn)
return;
va_start(args,fmt);
evutil_vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
__android_log_print(ANDROID_LOG_INFO, "moo", "good monkey %p\n", evdns_log_fn);
if (evdns_log_fn) {
if (warn == EVDNS_LOG_MSG)
warn = EVDNS_LOG_WARN;
evdns_log_fn(warn, buf);
} else {
default_evdns_log_fn(warn, buf);
}
}
libevent version: libevent-2.0.21-stable.tar.gz
thrift version: thrift-0.8.0.tar.gz
use very simple nonbloking server and related client, when client thread num is more than thread_num in server's thread_manager, and the network causes many receive timeout in client, it will cause fd leak.
I do not know whether it's my wrong usage or bug.
server code:
shared_ptr<aicidclickHandler> handler(new aicidclickHandler());
shared_ptr<TProcessor> processor(new aicidclick::aicidclickProcessor(handler));
shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(64); //thread num
shared_ptr<PosixThreadFactory> threadFactory = shared_ptr<PosixThreadFactory> (new PosixThreadFactory());
threadManager->threadFactory(threadFactory);
threadManager->start();
TNonblockingServer server(processor, protocolFactory, 18601, threadManager);
try{
server.serve();
}
catch(TException e){
exit(-1);
}
return 0;
client code(thread function):
boost::shared_ptr<TSocket> sock = boost::shared_ptr<TSocket>(new TSocket("10.0.2.21", 18601));
sock->setConnTimeout(40);
sock->setRecvTimeout(10); //make receive timeout
sock->setSendTimeout(40);
boost::shared_ptr<TTransport> transport = boost::shared_ptr<TFramedTransport>(new TFramedTransport(sock));
boost::shared_ptr<TProtocol> protocol = boost::shared_ptr<TBinaryProtocol>(new TBinaryProtocol(transport));
aicidclick::aicidclickClient client = aicidclick::aicidclickClient(protocol);
idclick::AdResponse resp;
while(1) {
try {
if (!transport->isOpen()) {
transport->open();
}
client.GetAdResponse(resp, g_req);
} catch (TException &tx) {
FATAL("ERROR: %s", tx.what());
transport->close();
}
}
return NULL;
server threadmanager's thread num is 64, client's thread num is 120, call for a while, kill some client's thread, with a monitor to observ using "lsof |grep server|grep "can't identify protocol | wc -l" ", you'll find the number goes up and will not return to 0 if you killall client
See #46 for some discussion of implementations and portability here.
I have a lot of connection to different servers and my app can work for about 5000 different connections to other servers, but after that got SIGABRT. It uses dns_base to make async dns requests with evhttp_connection_base_new(). Here is backtrace and warnings from app.
[warn] event_del: event has no event_base set.
[err] evdns.c:4253: Assertion req->type == DNS_IPv4_A || req->type == DNS_IPv6_AAAA failed in evdns_getaddrinfo_gotresolve
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x41001940 (LWP 19206)]
0x0000003baf630265 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x0000003baf630265 in raise () from /lib64/libc.so.6
#1 0x0000003baf631d10 in abort () from /lib64/libc.so.6
#2 0x0000000000422bac in event_exit (errcode=19195) at log.c:79
#3 0x0000000000422c5a in event_errx (eval=-559030611, fmt=) at log.c:136
#4 0x000000000042ffef in evdns_getaddrinfo_gotresolve (result=70, type=0 '\000', count=0, ttl=, addresses=0x0, arg=0x132bb10) at evdns.c:4334
#5 0x000000000042e3cc in reply_run_callback (d=0x7fffe80028d0, user_pointer=0x101010101010101) at evdns.c:782
#6 0x0000000000417ef2 in event_process_active (base=0x661b20, flags=0) at event.c:1364
#7 event_base_loop (base=0x661b20, flags=0) at event.c:1589
#8 0x0000000000403f2b in admin_interface_thread (arg=0x661ad0) at main.cpp:518
#9 0x0000003bb060673d in start_thread () from /lib64/libpthread.so.0
#10 0x0000003baf6d44bd in clone () from /lib64/libc.so.6
Currently only GET, POST, HEAD, PUT, DELETE methods are enabled when calling evhttp_new
. Please consider enabling all methods, or at least the ones defined on rfc2616, so callers get a fully http compliant server by default.
Continuation of Issue #59(Thx).
There is no gdi.lib on my windows XP SP3, there is gdi32.lib :)
LINK : fatal error LNK1181: cannot open input file 'gdi.lib'
I tried enable debugging using event_enable_debug_logging(EVENT_DBG_ALL), but I get a linking error when doing so. I then searched the Libevent code files and couldn't find any implementation of the actual function, it is only present in event.h. Am I missing something vital?
My code:
event_enable_debug_mode();
event_enable_debug_logging(EVENT_DBG_ALL);
event_set_log_callback(libeventlog);
Where libeventlog does:
void libeventlog(int severity, const char *msg)
{
fprintf(stderr, "\tLIBEVENT: %s\n", msg);
}
==15587== 136 bytes in 1 blocks are still reachable in loss record 4 of 5 ==15587== at 0x4C280A4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==15587== by 0x4E4FD14: event_base_once (event.c:1876)
eonce
variable must free after breaking loop, isn't it?
Maybe make it static
?
Line 1813 in f2050e7
Functions in this file use "memset(buf, 0, sizeof(buf))"
example:
static int arc4_seed_win32(void) {
/* This is adapted from Tor's crypto_seed_rng() */
static int provider_set = 0;
static HCRYPTPROV provider;
unsigned char buf[ADD_ENTROPY];
if (!provider_set) {
....
}
if (!CryptGenRandom(provider, sizeof(buf), buf))
return -1;
arc4_addrandom(buf, sizeof(buf));
memset(buf, 0, sizeof(buf));
arc4_seeded_ok = 1;
return 0;
}
But some compilers with enabled optimizations can remove memset(buf, 0, sizeof(buf));
Alternatively you can use memset_s (c11 standard) or some variants from http://goo.gl/y8311
Our application uses evconnlistener that accepts connection requests, creates a buffered event using bufferevent_socket_new for passed fd and assigns it to one of running event loop threads. It seems that in some rare cases file descriptor passed to evconnlistener callback is already invalid. In this case code called from bufferevent_socket_new eventually fails with a warning like that:
[warn] Epoll ADD(1) on fd 45 failed. Old events were 0; read change was 1 (add); write change was 0 (none): Bad file descriptor
but it does not cause a NULL return from bufferevent_socket_new. I think that it's a bug as I do not see an easy way to check whether a file descriptor is valid without actually using it. Probably a result of evbuffer_add_cb define is not checked.
On libevent-users, Adrian Chadd and Oleg Moskalenko report that it's annoying to have evconnlistener report ENFILE over and over when the file table is full. And it is!
There's a workaround, where you set the error handler for the listener to disable the listener if the error was ENFILE, and the you re-enable the listener once you've closed a socket or a few seconds have gone by or something.
There's another "workaround", where you use the logging functions to make it so that log callbacks don't go to stderr. But that's not much comfort.
What can Libevent do better here on its own? Rate-limiting logs could be an option, I guess, though I hesitate to step in that direction.
Documenting the first workaround above might also rock. (Also, we should test to make sure that it works before I go and claim that it's what people should be doing.)
hi every one,
In my app, the libevent coredump in the bufferevent_free(), the info is:
"[err] ....\libevent-2.1\event.c:1526: Assertion (evcb->evcb_flags & EVLIST_FINALIZING) failed in event_process_active_single_queue",
And the evcb_flags sometime is128, sometime is 192. It coredump when the value is 192.
Can onlyone tell my what's wrong with my app?
hi all:
is there a multi-thread http server example?
many thanks~
evdns_requests are only set up with a timeout if they were submitted to a name server (in evdns_request_transmit). If there are no name servers which are "good" to submit to, the request hangs indefinitely in the waiting queue. This happens, quite obviously, if the internet connection is dead.
Is the intention that the caller should implement a secondary timeout event to cover this case, or should evdns requests be made to eventually timeout if no name server is available within some time period?
Hi there,
Trying to develop a http client with timeouts assertion req != NULL
occurs from time to time.
It's difficult to say what steps are required to reproduce the error, but I suppose it's occurs after calls to evhttp_cancel_request
.
evhttp_cancel_request
the request is cleaned up in evhttp_connection_fail_
evhttp_connection_fail_
is called for the second time for the already cleaned up requestHere is the backtrace
#0 0x00007fa36a0e9425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#1 0x00007fa36a0ecb8b in abort () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#2 0x00007fa36ac8f53b in event_exit (errcode=-559030611) at log.c:107
No locals.
#3 0x00007fa36ac8f8e8 in event_errx (eval=-559030611, fmt=0x7fa36acb1018 "%s:%d: Assertion %s failed in %s") at log.c:164
ap = {{gp_offset = 48, fp_offset = 48, overflow_arg_area = 0x7fff8c717030, reg_save_area = 0x7fff8c716f70}}
#4 0x00007fa36aca35c6 in evhttp_connection_fail_ (evcon=0xd4b230, error=EVCON_HTTP_EOF) at http.c:686
errsave = 114
req = 0x0
cb = 0
cb_arg = 0x7fff8c717080
__func__ = "evhttp_connection_fail_"
#5 0x00007fa36aca4c7a in evhttp_error_cb (bufev=0xd4b3d0, what=32, arg=0xd4b230) at http.c:1380
evcon = 0xd4b230
req = 0x0
__func__ = "evhttp_error_cb"
#6 0x00007fa36aca4d0e in evhttp_connection_cb (bufev=0xd4b3d0, what=32, arg=0xd4b230) at http.c:1409
evcon = 0xd4b230
error = 1791534691
errsz = 4
__func__ = "evhttp_connection_cb"
#7 0x00007fa36ac757d8 in bufferevent_run_eventcb_ (bufev=0xd4b3d0, what=32) at bufferevent.c:265
p = 0xd4b3d0
#8 0x00007fa36ac7bec4 in bufferevent_socket_connect (bev=0xd4b3d0, sa=0xd4edf0, socklen=16) at bufferevent_sock.c:428
bufev_p = 0xd4b3d0
fd = 23
r = -1
result = -1
ownfd = 0
#9 0x00007fa36ac7bfd3 in bufferevent_connect_getaddrinfo_cb (result=0, ai=0xd4edc0, arg=0xd4b3d0) at bufferevent_sock.c:461
bev = 0xd4b3d0
bev_p = 0xd4b3d0
r = 0
#10 0x00007fa36ac9e642 in evdns_getaddrinfo_gotresolve (result=3, type=0 '\000', count=0, ttl=60, addresses=0x0, arg=0xd4e5b0) at evdns.c:4367
i = 32767
req = 0xd4e5b0
other_req = 0xd4e5a0
data = 0xd4e550
res = 0x1400d4e000
sin = {sin_family = 29360, sin_port = 35953, sin_addr = {s_addr = 32767}, sin_zero = "\000;\310j\243\177\000"}
sin6 = {sin6_family = 29376, sin6_port = 35953, sin6_flowinfo = 32767, sin6_addr = {__in6_u = {
__u6_addr8 = "\336\375\307j\243\177\000\000\350\232\324\000\000\000\000", __u6_addr16 = {64990, 27335, 32675, 0, 39656, 212, 0, 0}, __u6_addr32 = {
1791491550, 32675, 13933288, 0}}}, sin6_scope_id = 13930656}
sa = 0xd50040
socklen = 13933288
addrlen = 0
addrp = 0x3
err = -2
user_canceled = 0
__func__ = "evdns_getaddrinfo_gotresolve"
#11 0x00007fa36ac93a3b in reply_run_callback (d=0xd50040, user_pointer=0xd4e5b0) at evdns.c:799
cb = 0xd50040
__func__ = "reply_run_callback"
#12 0x00007fa36ac800aa in event_process_active_single_queue (base=0xd490a0, activeq=0xd494f0, max_to_process=2147483647, endtime=0x0) at event.c:1476
ev = 0x0
evcb = 0xd50040
count = 2
__func__ = "event_process_active_single_queue"
#13 0x00007fa36ac80364 in event_process_active (base=0xd490a0) at event.c:1538
activeq = 0xd494f0
i = 0
c = 0
endtime = 0x0
tv = {tv_sec = 13931328, tv_usec = 13930656}
maxcb = 2147483647
limit_after_prio = 2147483647
#14 0x00007fa36ac80ac0 in event_base_loop (base=0xd490a0, flags=0) at event.c:1761
n = 2
evsel = 0x7fa36aebcbc0
tv = {tv_sec = 0, tv_usec = 116012}
tv_p = 0x7fff8c717390
res = 0
done = 0
retval = 0
__func__ = "event_base_loop"
#15 0x00007fa36ac803ec in event_base_dispatch (event_base=0xd490a0) at event.c:1572
No locals.
#16 0x0000000000403dba in ev2_module_start () at ../src/ev2_module.c:124
rv = 0
#17 0x0000000000403a2b in main () at ../src/ev2_main.c:10
No locals.
: set_target_properties called with incorrect number of arguments.
set_target_properties(event event_core event_extras
PROPERTIES PUBLIC_HEADER ${HDR_PUBLIC})
This happened on a fresh git clone from the github. At first when trying to configure the file it askes for openSSL which i then would click the Event_Disable_openssl option. Then it asks for Zlib and python which i click the Disable_tests option. then it gives me a error upon the above.
My Cmake version when first trying was 2.8.7 it is now 2.8.12.1 and still has this error.
I am using it with Visual studios 11 and have tried it with visual studios 10 and it gives me a error for the compiler people say this is due to Visual studios 11 being installed.
using windows 7 sp1
The last compiled on Windows release was 2.1.1-alpha.
On 2.1.2-alpha there was openssl error.
For now, there is a change to 2.1.3-alpha and I got next error:
event.c(2051) : error C2065: 'uint8_t' : undeclared identifier
Line 231 in 9cd5acb
realloc(sig->sh_old, ...)
followed by
sizeof(*sig->sh_old)
might be undefined behavior.
I think it would be safer to write
const int element_size = sizeof(*sig->sh_old);
This was introduced by be7a95c, event_pending() now tries to lock ev_base, but fails to check if it's set and ends up crashing.
I'd suggest to add some check similar to that in event_add() or event_del(), though I'm not sure what the return value should be in case of error: -1 or 0.
is it possible to use bufferevent
to only listen to errors? That is, I have my own layer around sockets and would prefer to read/write through those instead of using the bufferevents. I'd still like to be able to catch any errors on the file descriptors though.
Is this possible?
Continuation of Issue #57(Thx).
The next error of compilation on windows since 2.1.1-alpha, is:
regress.exe : fatal error LNK1120: 14 unresolved externals
cl /I.. /I../WIN32-Code /I../include /I../compat /DHAVE_CONFIG_H /DTINYTEST_LOCAL /Ic:\openssl-1.0.1e\include /DEVENT__HAVE_OPENSSL /Ox /W3 /wd4996 /
nologo ..\libevent.lib ws2_32.lib shell32.lib advapi32.lib ..\libevent_openssl.lib c:\openssl-1.0.1e\lib\libeay32.lib c:\openssl-1.0.1e\lib\ssleay32.lib regr
ess.obj regress_buffer.obj regress_http.obj regress_dns.obj regress_testutils.obj regress_rpc.obj regress.gen.obj regress_et.obj regress_bufferevent.obj
regress_listener.obj regress_util.obj tinytest.obj regress_main.obj regress_minheap.obj regress_iocp.obj regress_thread.obj regress_finalize.obj regress_ss
l.obj
libeay32.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp__GetUserObjectInformationW@20 referenced in function _OPENSSL_isservice
libeay32.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp__GetProcessWindowStation@0 referenced in function _OPENSSL_isservice
libeay32.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp__GetDesktopWindow@0 referenced in function _OPENSSL_isservice
libeay32.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp__MessageBoxA@16 referenced in function _OPENSSL_showfatal
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__DeleteDC@4 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__DeleteObject@4 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__GetBitmapBits@12 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__BitBlt@36 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__GetObjectA@12 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__SelectObject@8 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__CreateCompatibleBitmap@12 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__GetDeviceCaps@8 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__CreateCompatibleDC@4 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__CreateDCA@16 referenced in function _readscreen
regress.exe : fatal error LNK1120: 14 unresolved externals
...
It looks like the write timeout on filter bufferevent are not disabled when there's nothing to write.
A bit surprisingly, this code can crash:
struct bufferevent *bev;
int fd = socket(PF_INET, SOCK_STREAM, 0);
evutil_make_socket_nonblocking(fd);
bev = bufferevent_socket_new(base, fd, BEV_OPT_CLOSE_ON_FREE);
bufferevent_setcb(bev, NULL, NULL, eventcb, NULL);
bufferevent_enable(bev, EV_READ|EV_WRITE);
bufferevent_socket_connect(bev, addr, sizeof(addr));
I know the bufferevent_enable
call is superfluous, but it seems like it should also be safe (particularly since reading is already enabled!) Instead, it can cause bev_async_consider_reading
to call the eventcb
, which frees the bufferevent on error. Then, the call to bufferevent_socket_connect
will crash.
Using the latest checkout from git, the following race condition is observable with many bufferevents on a single base.
If bufferevent_free is called while event_persist_closure is currently processing, a segfault can occur. Take the following scenario:
I can reproduce this in our rather large server application using CentOS 6.4 x86_64 and OSX 10.9.
I added a few extra assertions to the end of event_persist_closure (As follows):
static inline void
event_persist_closure(struct event_base *base, struct event *ev)
{
...
EVBASE_RELEASE_LOCK(base, th_base_lock);
event_debug((
"event_persist_closure: event: %p, %s%s%scall %p",
ev,
ev->ev_res & EV_READ ? "EV_READ " : " ",
ev->ev_res & EV_WRITE ? "EV_WRITE " : " ",
ev->ev_res & EV_CLOSED ? "EV_CLOSED " : " ",
ev->ev_callback));
EVUTIL_ASSERT(*ev->ev_callback != bufferevent_finalize_cb_);
EVUTIL_ASSERT(ev->ev_evcallback.evcb_closure == EV_CLOSURE_EVENT_PERSIST);
(*ev->ev_callback)(ev->ev_fd, ev->ev_res, ev->ev_arg);
}
And lastly I added a log to event_process_active_single_queue just before the switch statement:
event_debug(("closure_switch(%d)", evcb->evcb_closure));
switch (evcb->evcb_closure) {
A copy of a custom log showing the series of events:
Thread 1 T:01/24/14 15:46:48 - Event [debug]: closure_switch(2)
Thread 1 T:01/24/14 15:46:48 - Event [debug]: event_add: event: 0x105019818 (fd 21), EV_READ EV_TIMEOUT call 0x100058d50
Thread 1 T:01/24/14 15:46:48 - Event [debug]: event_add: event 0x105019818, timeout in 32313 seconds 403099 useconds, call 0x100058d50
Thread 1 T:01/24/14 15:46:48 - Event [debug]: event_add_nolock_ in event_persist_closure
Thread 2 T:01/24/14 15:46:48 - I:127.0.0.1 - Freeing bufferevent
Thread 2 T:01/24/14 15:46:48 - Event [debug]: event_callback_finalize_many_: 3 events finalizing
Thread 2 T:01/24/14 15:46:48 - Event [debug]: event_del: 0x105019818 (fd 21), callback 0x100058d50
Thread 2 T:01/24/14 15:46:48 - Event [debug]: event_del: 0x105019898 (fd 21), callback 0x100058dc0
Thread 2 T:01/24/14 15:46:48 - I:127.0.0.1 - Freed bufferevent
Thread 1 T:01/24/14 15:46:48 - Event [debug]: event_persist_closure: event: 0x105019818, EV_READ call 0x100058d50
Thread 1 T:01/24/14 15:46:48 - Event [err]: /Users/John/Documents/Git/Server/lib/libevent/event.c:1508: Assertion *ev->ev_callback != bufferevent_finalize_cb_ failed in event_persist_closure
Any thoughts?
There's some as-yet-unused windows code for condition variables that calls "LOAD(SleepConditionVariable)". That's not right -- it needs to load SleepConditionVariableCS.
If bufferevent_priority_set() is to work, it needs to change the priority assigned to every future event and callback. But events and callbacks can be initialized after bufferevent_priority_set() is called -- for example, in be_socket_setfd.
Further, it should really affect the priority of events used to implement rate-limiting.
I'm the developer of Seafile (https://github.com/haiwen/seafile)
We use the lastest libevent package but use 1.0 API, i.e. evdns_resolve_ipv4() to look up server's address. It works well in most cases. But a few seafile users report that the DNS look up can't work. The callback of evdns_resolve_ipv4() shows a message "DNS look up failed with unknown reason".
Seafile retries the DNS look up every 10 seconds. From the log, I find the failure can be lasted for 1 day or more.
Edit: User can connect the server in a web browser while evdns failed.
Any ideas?
"libevent can't properly detect dns replys with no data.
evdns.c,reply_parse:1006,reply_parse(). datalength (RDLENGTH).
have_answer defined as true for any data with zeroed RDLENGTHs"
(Reported by skruffy in IRC)
test code
void onTimeOut(evutil_socket_t fd, short event, void *arg)
{
struct event_base* base = (struct event_base*)arg;
event_base_loopbreak(base);
}
int main(int argc, char* argv[])
{
int rc = evthread_use_pthreads();
evthread_enable_lock_debuging();
struct event_base* base = event_base_new();
struct event* timeEvent = event_new(base, -1, EV_PERSIST, onTimeOut, base);
struct timeval tv;
evutil_timerclear(&tv);
tv.tv_sec = 1;
event_add(timeEvent, &tv);
event_base_dispatch(base);
event_free(timeEvent);
event_base_free(base);
return 0;
}
valgrind --leak-check=full --show-reachable=yes ./a.out
==15543== Memcheck, a memory error detector.
==15543== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==15543== Using LibVEX rev 1658, a library for dynamic binary translation.
==15543== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==15543== Using valgrind-3.2.1, a dynamic binary instrumentation framework.
==15543== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==15543== For more details, rerun with: -v
==15543==
==15543==
==15543== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 1)
==15543== malloc/free: in use at exit: 120 bytes in 3 blocks.
==15543== malloc/free: 14 allocs, 11 frees, 1,776 bytes allocated.
==15543== For counts of detected errors, rerun with: -v
==15543== searching for pointers to 3 not-freed blocks.
==15543== checked 206,968 bytes.
==15543==
==15543== 120 bytes in 3 blocks are still reachable in loss record 1 of 1
==15543== at 0x4A05809: malloc (vg_replace_malloc.c:149)
==15543== by 0x4E61ED1: evthread_posix_lock_alloc (evthread_pthread.c:46)
==15543== by 0x4C2AB37: event_global_setup_locks_ (event.c:2894)
==15543== by 0x4E61CE3: evthread_use_pthreads (evthread_pthread.c:187)
==15543== by 0x400A57: main (in /root/dev/a.out)
==15543==
==15543== LEAK SUMMARY:
==15543== definitely lost: 0 bytes in 0 blocks.
==15543== possibly lost: 0 bytes in 0 blocks.
==15543== still reachable: 120 bytes in 3 blocks.
==15543== suppressed: 0 bytes in 0 blocks.
Having some kind of http spider, making a lot of requests, I see sometimes this error:
[err] http.c:1112: Assertion evcon->state == EVCON_WRITING failed in evhttp_write_connectioncb
So evcon->state is overwritten somewhere in bufferevent callbacks.
Tested on libevent-2.0.19
Using master @ c149a1a
GCC 4.8.0
Cygwin 1.7.11(0.260/5/3)
I get the following error:
In file included from evutil_time.c:50:0:
evutil_time.c:205:5: error: missing binary operator before token "4"
#if CLOCK_MONOTONIC < 0
^
It looks like the definition of CLOCK_MONOTONIC on my machine has an extra (clockid_t) cast which causes the preprocessor to complain.
$ gcc -dM -E evutil_time.c -Iinclude/ |grep MONO
...
...
Everytime I try to dl this I get:
2012-11-10 18:49:03 (1.20 KB/s) - Connection closed at byte 587363. Retrying.
When running the bufferevent_connect_fail regress test with IOCP, there's a crash on this line:
https://github.com/libevent/libevent/blob/master/bufferevent.c#L689
The callback arg passed to this function is a NULL pointer in this case. I tried to make sense of where in the code this is happening but couldn't find the cause.
It works fine with the non-iocp regress test.
In both tests, the argument is set here correctly:
https://github.com/libevent/libevent/blob/master/event.c#L2921
Hi,
I just downloaded libevent source and tried to compile it. However, I got the following error
/usr/src/libevent-2.0.18-stable# make
make all-recursive
make[1]: Entering directory /usr/src/libevent-2.0.18-stable' Making all in . make[2]: Entering directory
/usr/src/libevent-2.0.18-stable'
/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I./compat -I./include -I./include -g -O2 -Wall -fno-strict-aliasing -pthread -MT event.lo -MD -MP -MF .deps/event.Tpo -c -o event.lo event.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./compat -I./include -I./include -g -O2 -Wall -fno-strict-aliasing -pthread -MT event.lo -MD -MP -MF .deps/event.Tpo -c event.c -fPIC -DPIC -o .libs/event.o
In file included from event.c:27:0:
./include/event2/event-config.h:18:3: error: expected identifier or '(' before '/' token
In file included from event.c:35:0:
/usr/include/x86_64-linux-gnu/sys/types.h:34:1: error: unknown type name '__u_char'
make[2]: *** [event.lo] Error 1
make[2]: Leaving directory /usr/src/libevent-2.0.18-stable' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory
/usr/src/libevent-2.0.18-stable'
make: *** [all] Error 2
Here is the output of ./configure
root@li423-94:/usr/src# tar -xzf libevent-2.0.18-stable.tar.gz
root@li423-94:/usr/src# cd libevent-2.0.18-stable
root@li423-94:/usr/src/libevent-2.0.18-stable# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether gcc and cc understand -c and -o together... yes
checking whether ln -s works... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking whether gcc needs -traditional... no
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @file support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for library containing inet_ntoa... none required
checking for library containing socket... none required
checking for library containing inet_aton... none required
checking for library containing clock_gettime... -lrt
checking for library containing sendfile... none required
checking for WIN32... no
checking for CYGWIN... no
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for library containing inflateEnd... -lz
checking openssl/bio.h usability... yes
checking openssl/bio.h presence... yes
checking for openssl/bio.h... yes
checking for library containing SSL_new... -lssl
checking for ANSI C header files... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking stdarg.h usability... yes
checking stdarg.h presence... yes
checking for stdarg.h... yes
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking poll.h usability... yes
checking poll.h presence... yes
checking for poll.h... yes
checking for unistd.h... (cached) yes
checking sys/epoll.h usability... yes
checking sys/epoll.h presence... yes
checking for sys/epoll.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/queue.h usability... yes
checking sys/queue.h presence... yes
checking for sys/queue.h... yes
checking sys/event.h usability... no
checking sys/event.h presence... no
checking for sys/event.h... no
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/devpoll.h usability... no
checking sys/devpoll.h presence... no
checking for sys/devpoll.h... no
checking port.h usability... no
checking port.h presence... no
checking for port.h... no
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking netinet/in6.h usability... no
checking netinet/in6.h presence... no
checking for netinet/in6.h... no
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking sys/uio.h usability... yes
checking sys/uio.h presence... yes
checking for sys/uio.h... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking sys/eventfd.h usability... yes
checking sys/eventfd.h presence... yes
checking for sys/eventfd.h... yes
checking sys/mman.h usability... yes
checking sys/mman.h presence... yes
checking for sys/mman.h... yes
checking sys/sendfile.h usability... yes
checking sys/sendfile.h presence... yes
checking for sys/sendfile.h... yes
checking sys/wait.h usability... yes
checking sys/wait.h presence... yes
checking for sys/wait.h... yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking for sys/sysctl.h... yes
checking for TAILQ_FOREACH in sys/queue.h... yes
checking for timeradd in sys/time.h... yes
checking for timercmp in sys/time.h... yes
checking for timerclear in sys/time.h... yes
checking for timerisset in sys/time.h... yes
checking whether CTL_KERN is declared... yes
checking whether KERN_RANDOM is declared... yes
checking whether RANDOM_UUID is declared... yes
checking whether KERN_ARND is declared... no
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking whether time.h and sys/time.h may both be included... yes
checking for gettimeofday... yes
checking for vasprintf... yes
checking for fcntl... yes
checking for clock_gettime... yes
checking for strtok_r... yes
checking for strsep... yes
checking for getnameinfo... yes
checking for strlcpy... no
checking for inet_ntop... yes
checking for inet_pton... yes
checking for signal... yes
checking for sigaction... yes
checking for strtoll... yes
checking for inet_aton... yes
checking for pipe... yes
checking for eventfd... yes
checking for sendfile... yes
checking for mmap... yes
checking for splice... yes
checking for arc4random... no
checking for arc4random_buf... no
checking for issetugid... no
checking for geteuid... yes
checking for getegid... yes
checking for getprotobynumber... yes
checking for setenv... yes
checking for unsetenv... yes
checking for putenv... yes
checking for sysctl... yes
checking for getaddrinfo... yes
checking size of long... 8
checking for F_SETFD in fcntl.h... yes
checking for select... yes
checking for poll... yes
checking for epoll_ctl... yes
checking for port_create... no
checking for pid_t... yes
checking for size_t... yes
checking for ssize_t... yes
checking for uint64_t... yes
checking for uint32_t... yes
checking for uint16_t... yes
checking for uint8_t... yes
checking for uintptr_t... yes
checking for fd_mask... yes
checking size of long long... 8
checking size of long... (cached) 8
checking size of int... 4
checking size of short... 2
checking size of size_t... 8
checking size of void *... 8
checking for struct in6_addr... yes
checking for struct sockaddr_in6... yes
checking for sa_family_t... yes
checking for struct addrinfo... yes
checking for struct sockaddr_storage... yes
checking for struct in6_addr.s6_addr32... yes
checking for struct in6_addr.s6_addr16... yes
checking for struct sockaddr_in.sin_len... no
checking for struct sockaddr_in6.sin6_len... no
checking for struct sockaddr_storage.ss_family... yes
checking for struct sockaddr_storage.ss_family... no
checking for socklen_t... yes
checking whether our compiler supports __func... yes
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking size of pthread_t... 8
configure: creating ./config.status
config.status: creating libevent.pc
config.status: creating libevent_openssl.pc
config.status: creating libevent_pthreads.pc
config.status: creating Makefile
config.status: creating include/Makefile
config.status: creating test/Makefile
config.status: creating sample/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
Here is the output of uname -a
Linux li423-94 3.0.18-x86_64-linode24 #1 SMP Mon Jan 30 14:25:46 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
This is a Linode small instance (Xen-based)
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 11.10
Release: 11.10
Codename: oneiric
Thanks for help. Now I am able to get the .sln files. I have checked out aux files to Mswin32 folder. But I have below questions.
Is NAMP windows source code is 64 bit compatible?
Is windows repository nmap-win32-aux is same for 64 bit machines?
If yes , when I provided the lib path in project properties directories and additional dependencies in linker I am getting below error.
I am compiling NMAP on windows 8 64 bit. One project need libeay32.lib to be included. I added the downloaded path in linker and directory path with /MD option. But I am getting below errors. Is something wrong with the depository available at https://svn.nmap.org/nmap-mswin32-aux.Or for 64 bit versions "libeay32.lib" is different?
1> libnetutil.lib(netutil.obj) : MSIL .netmodule or module compiled
1>with /GL found; restarting link with /LTCG; add /LTCG to the link
1>command line to improve linker performance LINK : warning LNK4075:
1>ignoring '/INCREMENTAL' due to '/LTCG' specification Crypto.obj :
1>error LNK2001: unresolved external symbol HMAC Crypto.obj : error
1>LNK2001: unresolved external symbol EVP_sha256 Crypto.obj : error
1>LNK2001: unresolved external symbol EVP_CIPHER_CTX_cleanup Crypto.obj
1>: error LNK2001: unresolved external symbol EVP_EncryptFinal
1>Crypto.obj : error LNK2001: unresolved external symbol
1>EVP_EncryptUpdate Crypto.obj : error LNK2001: unresolved external
1>symbol EVP_EncryptInit Crypto.obj : error LNK2001: unresolved external
1>symbol EVP_aes_128_cbc Crypto.obj : error LNK2001: unresolved external
1>symbol EVP_CIPHER_CTX_set_padding Crypto.obj : error LNK2001:
1>unresolved external symbol EVP_CIPHER_CTX_init Crypto.obj : error
1>LNK2001: unresolved external symbol ERR_error_string
1>nsock.lib(nsock_core.obj) : error LNK2001: unresolved external symbol
1>ERR_error_string
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>ERR_error_string Crypto.obj : error LNK2001: unresolved external
1>symbol ERR_peek_last_error Crypto.obj : error LNK2001: unresolved
1>external symbol EVP_DecryptFinal Crypto.obj : error LNK2001:
1>unresolved external symbol EVP_DecryptUpdate Crypto.obj : error
1>LNK2001: unresolved external symbol EVP_DecryptInit Crypto.obj : error
1>LNK2001: unresolved external symbol EVP_MD_CTX_cleanup Crypto.obj :
1>error LNK2001: unresolved external symbol EVP_DigestFinal Crypto.obj :
1>error LNK2001: unresolved external symbol EVP_DigestUpdate Crypto.obj
1>: error LNK2001: unresolved external symbol EVP_DigestInit Crypto.obj
1>: error LNK2001: unresolved external symbol EVP_MD_size Crypto.obj :
1>error LNK2001: unresolved external symbol EVP_MD_CTX_init NpingOps.obj
1>: error LNK2001: unresolved external symbol pcap_findalldevs
1>libdnet-stripped.lib(intf-win32.obj) : error LNK2001: unresolved
1>external symbol pcap_findalldevs NpingOps.obj : error LNK2001:
1>unresolved external symbol pcap_lookupdev winfix.obj : error LNK2001:
1>unresolved external symbol pcap_lib_version winfix.obj : error
1>LNK2001: unresolved external symbol PacketGetAdapterNames
1>nsock.lib(nsock_core.obj) : error LNK2001: unresolved external symbol
1>SSL_clear
1>nsock.lib(nsock_core.obj) : error LNK2001: unresolved external symbol
1>SSL_get_error
1>nsock.lib(nsock_iod.obj) : error LNK2001: unresolved external symbol
1>SSL_get_error
1>nsock.lib(nsock_core.obj) : error LNK2001: unresolved external symbol
1>SSL_ctrl
1>nsock.lib(nsock_core.obj) : error LNK2001: unresolved external symbol
1>SSL_connect
1>nsock.lib(nsock_core.obj) : error LNK2001: unresolved external symbol
1>SSL_set_session
1>nsock.lib(nsock_core.obj) : error LNK2001: unresolved external symbol
1>SSL_set_fd
1>nsock.lib(nsock_core.obj) : error LNK2001: unresolved external symbol
1>ERR_get_error
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>ERR_get_error
1>nsock.lib(nsock_core.obj) : error LNK2001: unresolved external symbol
1>SSL_new
1>nsock.lib(nsock_core.obj) : error LNK2001: unresolved external symbol
1>SSL_write
1>nsock.lib(nsock_core.obj) : error LNK2001: unresolved external symbol
1>ERR_reason_error_string
1>nsock.lib(nsock_iod.obj) : error LNK2001: unresolved external symbol
1>ERR_reason_error_string
1>nsock.lib(nsock_core.obj) : error LNK2001: unresolved external symbol
1>SSL_read
1>nsock.lib(nsock_iod.obj) : error LNK2001: unresolved external symbol
1>pcap_close
1>libnetutil.lib(netutil.obj) : error LNK2001: unresolved external
1>symbol pcap_close
1>nsock.lib(nsock_iod.obj) : error LNK2001: unresolved external symbol
1>SSL_free
1>nsock.lib(nsock_iod.obj) : error LNK2001: unresolved external symbol
1>SSL_shutdown
1>nsock.lib(nsock_iod.obj) : error LNK2001: unresolved external symbol
1>SSL_get1_session
1>nsock.lib(nsock_iod.obj) : error LNK2001: unresolved external symbol
1>SSL_get_session
1>nsock.lib(nsock_pcap.obj) : error LNK2001: unresolved external symbol
1>pcap_freecode
1>libnetutil.lib(netutil.obj) : error LNK2001: unresolved external
1>symbol pcap_freecode
1>nsock.lib(nsock_pcap.obj) : error LNK2001: unresolved external symbol
1>pcap_setfilter
1>libnetutil.lib(netutil.obj) : error LNK2001: unresolved external
1>symbol pcap_setfilter
1>nsock.lib(nsock_pcap.obj) : error LNK2001: unresolved external symbol
1>pcap_geterr
1>libnetutil.lib(netutil.obj) : error LNK2001: unresolved external
1>symbol pcap_geterr
1>nsock.lib(nsock_pcap.obj) : error LNK2001: unresolved external symbol
1>pcap_compile
1>libnetutil.lib(netutil.obj) : error LNK2001: unresolved external
1>symbol pcap_compile
1>nsock.lib(nsock_pcap.obj) : error LNK2001: unresolved external symbol
1>pcap_datalink
1>libnetutil.lib(netutil.obj) : error LNK2001: unresolved external
1>symbol pcap_datalink
1>nsock.lib(nsock_pcap.obj) : error LNK2001: unresolved external symbol
1>pcap_next_ex
1>nsock.lib(nsock_pcap.obj) : error LNK2001: unresolved external symbol
1>pcap_setnonblock
1>libnetutil.lib(netutil.obj) : error LNK2001: unresolved external
1>symbol pcap_setnonblock
1>nsock.lib(nsock_pcap.obj) : error LNK2001: unresolved external symbol
1>pcap_setmintocopy
1>libnetutil.lib(netutil.obj) : error LNK2001: unresolved external
1>symbol pcap_setmintocopy
1>nsock.lib(nsock_pcap.obj) : error LNK2001: unresolved external symbol
1>pcap_open_live
1>libnetutil.lib(netutil.obj) : error LNK2001: unresolved external
1>symbol pcap_open_live
1>nsock.lib(nsock_pool.obj) : error LNK2001: unresolved external symbol
1>SSL_CTX_free
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>SSL_CTX_set_timeout
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>SSL_CTX_ctrl
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>SSL_CTX_new
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>SSLv23_client_method
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>SSL_library_init
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>SSL_load_error_strings
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>SSL_CTX_set_cipher_list
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>SSL_CTX_set_verify
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>RAND_status
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>RAND_add
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>RAND_seed
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>SSL_get_verify_result
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>X509_free
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>SSL_get_peer_certificate
1>nsock.lib(nsock_ssl.obj) : error LNK2001: unresolved external symbol
1>SSL_get_verify_mode
1>libdnet-stripped.lib(eth-win32.obj) : error LNK2001: unresolved
1>external symbol PacketSendPacket
1>libdnet-stripped.lib(eth-win32.obj) : error LNK2001: unresolved
1>external symbol PacketInitPacket
1>libdnet-stripped.lib(eth-win32.obj) : error LNK2001: unresolved
1>external symbol PacketCloseAdapter
1>libdnet-stripped.lib(eth-win32.obj) : error LNK2001: unresolved
1>external symbol PacketFreePacket
1>libdnet-stripped.lib(eth-win32.obj) : error LNK2001: unresolved
1>external symbol PacketRequest
1>libdnet-stripped.lib(eth-win32.obj) : error LNK2001: unresolved
1>external symbol PacketAllocatePacket
1>libdnet-stripped.lib(eth-win32.obj) : error LNK2001: unresolved
1>external symbol PacketSetBuff
1>libdnet-stripped.lib(eth-win32.obj) : error LNK2001: unresolved
1>external symbol PacketOpenAdapter
1>libdnet-stripped.lib(intf-win32.obj) : error LNK2001: unresolved
1>external symbol pcap_freealldevs
1>libnetutil.lib(netutil.obj) : error LNK2001: unresolved external
1>symbol pcap_next
1>libnetutil.lib(netutil.obj) : error LNK2001: unresolved external
1>symbol pcap_getnonblock
1>libnetutil.lib(netutil.obj) : error LNK2001: unresolved external
1>symbol PacketSetReadTimeout .\Release/nping.exe : fatal error LNK1120:
1>77 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.59
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I write a simple web server that handles long-polling, which means the server doesn't send a full HTTP response to the client(web browser, curl, etc), but only sends HTTP headers and hang the connection.
I use command line curl to product a request to the server, it prints out HTTP response headers well, and curl hangs as expected. Then I press CTRL+C to terminate the curl process. But the server never knows this close(on_disconnect() is never called).
Some of the codes:
void request_handler(struct evhttp_request *req, void *arg){
// only send response headers, and one piece of chunked data
evhttp_send_reply_start(req, HTTP_OK, "OK");
evbuffer_add_printf(buf, "...\n");
evhttp_send_reply_chunk(req, buf);
// register connection close callback
evhttp_connection_set_closecb(req->evcon, on_disconnect, sub);
}
void on_disconnect(struct evhttp_connection *evcon, void *arg){
printf("disconnected\n");
}
evhttp_set_gencb(http, request_handler, NULL);
My question is, how to detect this kind of client close(a TCP FIN received)? Is this a bug?
Someone tells:
When evhttp_read_header() in libevent's http.c is done reading the HTTP headers from the client, it disables any future read events by calling bufferevent_disable(..., EV_READ). However, read events need to be enabled for the underlying bufferevent to report EOF. That's why the bufferevent never tells libevent's HTTP code when the client closes the connection. - http://stackoverflow.com/questions/18743948/libevent2-http-server-how-to-detect-client-close/18776728?noredirect=1#18776728
New to libevent, a great library that fits my need.
The following piece of code always gave segmentation fault on "evhttp_request_free(req)", wonder why.
Thanks in advance.
void http_request_done(struct evhttp_request *req, void *arg){
int s = evbuffer_remove(req->input_buffer, &bigBuf, sizeof(buf) - 1);
bigBuf[s] = '\0';
printf("%s", bigBuf);
printf("=======%d\n", req->cb_arg);
int len = sprintf(buf, "{sid : \"%d\"}\n", (int) (req->cb_arg));
evhttp_request_free (req);
}
int http_req(int i, char *uri) {
struct evhttp_connection *conn = evhttp_connection_base_new(base, NULL, "127.0.0.1", 80);
struct evhttp_request *req = evhttp_request_new(http_request_done, base);
req->cb_arg = (void *)i;
evhttp_add_header(req->output_headers, "Host", "localhost");
evhttp_make_request(conn, req, EVHTTP_REQ_GET, uri);
}
I clear all timers and expect long running connection with a long delayed chunked response.
Hi there,
It seems that evhttp_request_own does not work as expected, as described here. Although the mentioned issue was created in 2009 it seems still to be actual.
Here is the sample to reproduce
#include <event.h>
#include <assert.h>
#include <event2/http.h>
static struct evhttp_request *resp = NULL;
static struct event_base *base;
static void request_done(struct evhttp_request *req, void *arg) {
evhttp_request_own(req);
resp = req;
}
void rest_process(enum evhttp_cmd_type method, const char *host, int port,
const char *uri, struct evbuffer *body) {
struct evhttp_connection *conn;
struct evhttp_request *req;
int ret;
conn = evhttp_connection_base_new(base, NULL, host, port);
assert(conn != NULL);
req = evhttp_request_new(request_done, NULL );
assert(req != NULL);
ret = evhttp_make_request(conn, req, method, uri);
assert(ret == 0);
}
int main(int argc, char **argv) {
base = event_init();
rest_process(EVHTTP_REQ_GET, "127.0.0.1", 8080, "/path", NULL );
event_base_loop(base, 0);
assert(resp != NULL);
evhttp_request_free(resp);
return 0;
}
And here is the backtrace
Program terminated with signal 11, Segmentation fault.
#0 0x00007fa00d3883dc in evhttp_clear_headers (headers=0x22baa40) at http.c:1724
1724 TAILQ_REMOVE(headers, header, next);
(gdb) bt full
#0 0x00007fa00d3883dc in evhttp_clear_headers (headers=0x22baa40) at http.c:1724
header = 0x22bab90
#1 0x00007fa00d38a77e in evhttp_request_free (req=0x22ba970) at http.c:3730
No locals.
#2 evhttp_request_free (req=0x22ba970) at http.c:3712
No locals.
#3 0x0000000000403639 in main (argc=1, argv=0x7fff444f7288) at ../src/http_own.c:38
__PRETTY_FUNCTION__ = "main"
bufferevent_pair has strange close semantics; "Freeing either member of the pair does not automatically free the other or generate an EOF event".
Generating an EOF event with bufferevent_flush(bev, EV_WRITE, BEV_FINISHED)
can generate spurious read_cb calls with 0 new bytes. This EOF discrepancy also prevents bufferevents as part of a pair from being treated just like any other bufferevent, since they must be closed in a special way.
As a user, I expected bufferevent_pair to act exactly like a socketpair with corresponding bufferevents, like this:
int bufferevent_socketpair_new(struct event_base *base, int options, struct bufferevent *pair[2])
{
int rc;
int family;
evutil_socket_t socks[2];
struct bufferevent *bevs[2];
#if defined(AF_UNIX)
family = AF_UNIX;
#else
family = AF_INET;
#endif
rc = evutil_socketpair(family, SOCK_STREAM, 0, socks);
if (rc < 0) {
return -1;
}
evutil_make_socket_closeonexec(socks[0]);
evutil_make_socket_nonblocking(socks[0]);
bevs[0] = bufferevent_socket_new(base, socks[0], options);
if (!bevs[0]) {
evutil_closesocket(socks[0]);
evutil_closesocket(socks[1]);
return -1;
}
evutil_make_socket_closeonexec(socks[1]);
evutil_make_socket_nonblocking(socks[1]);
bevs[1] = bufferevent_socket_new(base, socks[1], options);
if (!bevs[1]) {
bufferevent_free(bevs[0]);
evutil_closesocket(socks[0]);
evutil_closesocket(socks[1]);
return -1;
}
pair[0] = bevs[0];
pair[1] = bevs[1];
return 0;
}
This is obviously less efficient, but requires significantly less code, and far less surprising behavior.
So! I propose that the semantics of bufferevent_pair be changed to match the example above.
Running make verify I get this in a Centos 6.3 machine:
Running tests: EVPORT Skipping test KQUEUE Skipping test EPOLL test-eof: OKAY test-weof: OKAY test-time: OKAY test-changelist: OKAY regress: [Error code 3] FAIL regress_dns.c:188: assert(dns_ok == DNS_PTR): 0 vs 2dns/gethostbyaddr: FAIL regress_main.c:332: Legacy unit test failed [gethostbyaddr FAILED] [Error code 3] FAIL regress_dns.c:213: assert(dns_ok == DNS_PTR): 0 vs 2dns/resolve_reverse: [resolve_reverse FAILED] FAIL regress_dns.c:1147: assert(n_dns == 2): 4 vs 2dns/bufferevent_connect_hostname: [bufferevent_connect_hostname FAILED] 3/179 TESTS FAILED. (0 skipped) FAILED EPOLL (changelist) test-eof: OKAY test-weof: OKAY test-time: OKAY test-changelist: OKAY regress: [Error code 3] FAIL regress_dns.c:188: assert(dns_ok == DNS_PTR): 0 vs 2dns/gethostbyaddr: FAIL regress_main.c:332: Legacy unit test failed [gethostbyaddr FAILED] [Error code 3] FAIL regress_dns.c:213: assert(dns_ok == DNS_PTR): 0 vs 2dns/resolve_reverse: [resolve_reverse FAILED] FAIL regress_dns.c:1147: assert(n_dns == 2): 4 vs 2dns/bufferevent_connect_hostname: [bufferevent_connect_hostname FAILED] 3/179 TESTS FAILED. (0 skipped) FAILED DEVPOLL Skipping test POLL test-eof: OKAY test-weof: OKAY test-time: OKAY test-changelist: OKAY regress: [Error code 3] FAIL regress_dns.c:188: assert(dns_ok == DNS_PTR): 0 vs 2dns/gethostbyaddr: FAIL regress_main.c:332: Legacy unit test failed [gethostbyaddr FAILED] [Error code 3] FAIL regress_dns.c:213: assert(dns_ok == DNS_PTR): 0 vs 2dns/resolve_reverse: [resolve_reverse FAILED] FAIL regress_dns.c:1147: assert(n_dns == 2): 4 vs 2dns/bufferevent_connect_hostname: [bufferevent_connect_hostname FAILED] 3/179 TESTS FAILED. (0 skipped) FAILED SELECT test-eof: OKAY test-weof: OKAY test-time: OKAY test-changelist: OKAY regress: [Error code 3] FAIL regress_dns.c:188: assert(dns_ok == DNS_PTR): 0 vs 2dns/gethostbyaddr: FAIL regress_main.c:332: Legacy unit test failed [gethostbyaddr FAILED] [Error code 3] FAIL regress_dns.c:213: assert(dns_ok == DNS_PTR): 0 vs 2dns/resolve_reverse: [resolve_reverse FAILED] FAIL regress_dns.c:1147: assert(n_dns == 2): 4 vs 2dns/bufferevent_connect_hostname: [bufferevent_connect_hostname FAILED] 3/179 TESTS FAILED. (0 skipped) FAILED WIN32 Skipping test FAIL: ../test/test.sh ================== 1 of 1 test failed
Sure, the developer responsible should be frowned at until the blocking call returns. But, libevent could either mark all fds as nonblocking when they are registered for events, or assert that they are already nonblocking, possibly in debug mode only.
If evdns has multiple waiting requests and evdns_shutdown() is
called, it releases only one request and leaks the other requests. This
sometimes causes SIGSEGV.
Test program: evdns_test.c
Test result on OpenBSD 5.4 amd64 + libevent-release-2.0.21-stable
% env MALLOC_OPTIONS=J ./evdns_test
periodic(1)
periodic(2)
on_resolved(result[0]=68)
periodic(3)
periodic(4)
periodic(5)
periodic(6)
Segmentation fault (core dumped)
%
Patch to fix: evdns_shutdown.diff
Test result on OpenBSD 5.4 amd64 + libevent -current + patch
% env MALLOC_OPTIONS=J ./evdns_test
[msg] Nameserver 127.0.0.2:53 has failed: Network is unreachable
[msg] All nameservers have failed
periodic(1)
periodic(2)
on_resolved(result[1]=68)
on_resolved(result[0]=68)
periodic(3)
periodic(4)
periodic(5)
periodic(6)
periodic(7)
periodic(8)
%
A Uniform Resource Identifier consists of the following components:
[scheme:][//authority][path][?query][#fragment]
evhttp_request->uri returns the [path] and [?query] components concatenated together... This is annoying because If you try to access an evhttp by typing the following URI in the address bar of a browser:
http://localhost:1234/?key=var
Then evhttp_request->uri returns "/?key=var" which causes the following code to return a dictionary with the key element "/?key" instead of "key":
evhttp_parse_query_str(req->uri, &GET);
The solution is probably to remove evhttp_request->uri entirely and replace it with evhttp_request->path and evhttp_request->query.
For example to obtain the GET prams you could use this:
evhttp_parse_query_str(req->query, &GET);
And if you wanted to work with the path:
if(strcmp(req->path,'/index.html')==0){
...
}
Or another option is to have evhttp_parse_query_str() deal with the [path] part of a URI in an elegant way, I think we can all agree that turning the path into a key is a bug.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.