Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/events_libevent.c

    r9ff5737 r04026d4  
    3232#include <unistd.h>
    3333#include <sys/types.h>
     34#include "proxy.h"
     35
    3436#include <sys/time.h>
    3537#include <event.h>
    36 #include "proxy.h"
    37 
    38 static void b_main_restart();
    39 static guint id_next = 1;
     38
     39static guint id_next;
    4040static GHashTable *id_hash;
    4141static int quitting = 0;
     
    4848static GHashTable *write_hash;
    4949
    50 struct event_base *leh;
    51 struct event_base *old_leh;
    52 
    5350struct b_event_data
    5451{
     
    6259void b_main_init()
    6360{
    64         if( leh != NULL )
    65         {
    66                 /* Clean up the hash tables? */
    67                
    68                 b_main_restart();
    69                 old_leh = leh;
    70         }
    71        
    72         leh = event_init();
    73        
     61        event_init();
     62       
     63        id_next = 1;
    7464        id_hash = g_hash_table_new( g_int_hash, g_int_equal );
    7565        read_hash = g_hash_table_new( g_int_hash, g_int_equal );
     
    7969void b_main_run()
    8070{
    81         /* This while loop is necessary to exit the event loop and start a
    82            different one (necessary for ForkDaemon mode). */
    83         while( event_base_dispatch( leh ) == 0 && !quitting )
    84         {
    85                 if( old_leh != NULL )
    86                 {
    87                         /* For some reason this just isn't allowed...
    88                            Possibly a bug in older versions, will see later.
    89                         event_base_free( old_leh ); */
    90                         old_leh = NULL;
    91                 }
    92                
    93                 event_debug( "New event loop.\n" );
    94         }
    95 }
    96 
    97 static void b_main_restart()
     71        event_dispatch();
     72}
     73
     74void b_main_quit()
    9875{
    9976        struct timeval tv;
    10077       
    101         memset( &tv, 0, sizeof( struct timeval ) );
    102         event_base_loopexit( leh, &tv );
    103        
    104         event_debug( "b_main_restart()\n" );
    105 }
    106 
    107 void b_main_quit()
    108 {
    109         /* Tell b_main_run() that it shouldn't restart the loop. Also,
    110            libevent sometimes generates events before really quitting,
     78        /* libevent sometimes generates events before really quitting,
    11179           we want to stop them. */
    11280        quitting = 1;
    11381       
    114         b_main_restart();
     82        memset( &tv, 0, sizeof( struct timeval ) );
     83        event_loopexit( &tv );
    11584}
    11685
Note: See TracChangeset for help on using the changeset viewer.