mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
r19749@catbus: nickm | 2008-05-14 23:48:44 -0400
New function to dump inserted and active events. Also do not recv() on an int array. svn:r829
This commit is contained in:
parent
f9b4ee0aa4
commit
a68de2525d
35
event.c
35
event.c
@ -1391,9 +1391,9 @@ static void
|
||||
evthread_ignore_fd(int fd, short what, void *arg)
|
||||
{
|
||||
struct event_base *base = arg;
|
||||
int buf[128];
|
||||
char buf[128];
|
||||
|
||||
/* we draining the socket */
|
||||
/* we're draining the socket */
|
||||
while (recv(fd, buf, sizeof(buf), 0) != -1)
|
||||
;
|
||||
|
||||
@ -1448,3 +1448,34 @@ evthread_set_lock_create_callbacks(struct event_base *base,
|
||||
/* now, let's allocate our lock */
|
||||
base->th_base_lock = (*alloc_fn)();
|
||||
}
|
||||
|
||||
void
|
||||
event_base_dump_events(struct event_base *base, FILE *output)
|
||||
{
|
||||
struct event *e;
|
||||
int i;
|
||||
fprintf(output, "Inserted events:\n");
|
||||
TAILQ_FOREACH(e, &base->eventqueue, ev_next) {
|
||||
fprintf(output, " %p [fd %ld]%s%s%s%s%s\n",
|
||||
(void*)e, (long)e->ev_fd,
|
||||
(e->ev_events&EV_READ)?" Read":"",
|
||||
(e->ev_events&EV_WRITE)?" Write":"",
|
||||
(e->ev_events&EV_SIGNAL)?" Signal":"",
|
||||
(e->ev_events&EV_TIMEOUT)?" Timeout":"",
|
||||
(e->ev_events&EV_PERSIST)?" Persist":"");
|
||||
|
||||
}
|
||||
for (i = 0; i < base->nactivequeues; ++i) {
|
||||
if (TAILQ_EMPTY(base->activequeues[i]))
|
||||
continue;
|
||||
fprintf(output, "Active events [priority %d]:\n", i);
|
||||
TAILQ_FOREACH(e, &base->eventqueue, ev_next) {
|
||||
fprintf(output, " %p [fd %ld]%s%s%s%s\n",
|
||||
(void*)e, (long)e->ev_fd,
|
||||
(e->ev_res&EV_READ)?" Read active":"",
|
||||
(e->ev_res&EV_WRITE)?" Write active":"",
|
||||
(e->ev_res&EV_SIGNAL)?" Signal active":"",
|
||||
(e->ev_res&EV_TIMEOUT)?" Timeout active":"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,8 @@ extern "C" {
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* For int types. */
|
||||
#include <event2/util.h>
|
||||
|
||||
@ -538,6 +540,8 @@ void event_set_mem_functions(void *(*malloc_fn)(size_t sz),
|
||||
void *(*realloc_fn)(void *ptr, size_t sz),
|
||||
void (*free_fn)(void *ptr));
|
||||
|
||||
void event_base_dump_events(struct event_base *, FILE *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user