Hello..

I appreciate the response I received to my previous request of help with the 
integration of duma into libev. I have 
resolved that issue which was, glady, my own. Albiet embarrassed, it appears it 
was worth the effort to get this 
working as I have found what I belive is a memory leak in libev when dealing 
with signals and the deafult loop.

Since the default loop has 1 signal set by default (childev), even if the 
signal api's are not used (ev_siginal_init(), etc)
by the binding application, it would still have this issue for anyone who uses 
the library.

The "signals" array is never freed, with particular attention to the 
ev_default_destroy() function. 
Rather than going into a bunch of details, the code pretty much speaks for 
itself as to what is the perceived problem
which is/are:

1) The "signals" array is never freed
2) Pending signal events are not restored to to system default handling when 
the default loop is destroyed.

What is:

void
ev_default_destroy (void)
{
#if EV_MULTIPLICITY
  struct ev_loop *loop = ev_default_loop_ptr;
#endif

#ifndef _WIN32
  ev_ref (EV_A); /* child watcher */
  ev_signal_stop (EV_A_ &childev);
#endif

  loop_destroy (EV_A);
}
                    
Has been changed in my version to:

void                                         
ev_default_destroy (void)                    
{                                            
#if EV_MULTIPLICITY                          
  struct ev_loop *loop = ev_default_loop_ptr;
#endif                                       
                                             
#ifndef _WIN32                               
  int signum;                                
                                             
  ev_ref (EV_A); /* child watcher */         
  for ( signum = signalmax; signum--; ) {     
    if ( signals [signum].gotsig )             
      signal (signum, SIG_DFL);              
  }                                          
  ev_free (signals); signalmax = 0;          
#endif                                       
                                             
  loop_destroy (EV_A);                       
}                                            


Now, this works for me but I would love to know if you have any comments about 
my change (good or bad) or anything
I may have missed? Although obviously not the only solution, this one works for 
my observed issues. If you have something
better, I'd love to see it and I would, of course, replace that into what I am 
working with rather than my change.

I hope this e-mail brings out a shortcoming and provides a solution. I would 
not have caught this without duma.

Thanks in advance,

Michael
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to