[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] help about an error message



Hi,

On Tue, Mar 26, 2013 at 2:22 AM, sven falempin <sven.falempin@xxxxxxxxx> wrote:
> using libevent2 (libevent-2.0.21-stable) i create this log:
>
> [warn] event_del: event has no event_base set.
> [err] event_assign called on an already added event 0x84de9e4 (events: 0x0,
> fd: 0, flags: 0x0)
>
> using this code:
>
> void connection::listen_write_event() {
>   int rc = 0;
>   if (fd == -1) return;
>   if (is_listening_write) return;
>   is_listening_write = 1;
> #ifdef DEBUG
>       fprintf(stderr,"%d:%08X, LISTEN WRITING\n",fd, (unsigned
> int)pthread_self());
> #endif
>   event_del(&_sock_ev_write);

What is "_sock_ev_write" how you initialize it?
On stack I suppose?

Why do you call event_del() if you don't set event_base for it?
You install base, on the next line.

>   rc = event_assign(&_sock_ev_write, s->get_evt_base(),
>     fd, EV_WRITE,
>     server::con_ready_pattern, this);
>   if (rc == 0)
>     event_add(&_sock_ev_write, NULL);
>   else
>     syslog( LOG_CRIT, "%d:cannot create write event",fd);
> }
>
> i cannot supress the warn even if i put an event base (probably
> missunderstood the doc)

Did saw this? It has all that you need, for now, I think.
http://www.wangafu.net/~nickm/libevent-book/Ref4_event.html

>
> i declared
> struct event_base * evt_base; as a global
>
> and get it init:
>
> #ifdef DEBUG
>   event_enable_debug_mode();
> #endif
>   evthread_use_pthreads();
>   gconf.evt_base = event_base_new();
>   if ( gconf.evt_base == NULL ) {
>     syslog( LOG_ERR, "cannot allocate base for %s:%d", gconf.ip,
> gconf.port);
>     return 1;
>   }
>
> then used it everywhere
>
>
> to create the bug i connect frenzy to the server using a while true;
>
> Notice: if the program do not close the FD i exhaust the files desc before
> reaching the bug.
>
> --
> ---------------------------------------------------------------------------------------------------------------------
> () ascii ribbon campaign - against html e-mail
> /\



--
Respectfully
Azat Khuzhin
Primary email a3at.mail@xxxxxxxxx
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.