Changes in lib/events_libevent.c [9ff5737:04026d4]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/events_libevent.c
r9ff5737 r04026d4 32 32 #include <unistd.h> 33 33 #include <sys/types.h> 34 #include "proxy.h" 35 34 36 #include <sys/time.h> 35 37 #include <event.h> 36 #include "proxy.h" 37 38 static void b_main_restart(); 39 static guint id_next = 1; 38 39 static guint id_next; 40 40 static GHashTable *id_hash; 41 41 static int quitting = 0; … … 48 48 static GHashTable *write_hash; 49 49 50 struct event_base *leh;51 struct event_base *old_leh;52 53 50 struct b_event_data 54 51 { … … 62 59 void b_main_init() 63 60 { 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; 74 64 id_hash = g_hash_table_new( g_int_hash, g_int_equal ); 75 65 read_hash = g_hash_table_new( g_int_hash, g_int_equal ); … … 79 69 void b_main_run() 80 70 { 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 74 void b_main_quit() 98 75 { 99 76 struct timeval tv; 100 77 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, 111 79 we want to stop them. */ 112 80 quitting = 1; 113 81 114 b_main_restart(); 82 memset( &tv, 0, sizeof( struct timeval ) ); 83 event_loopexit( &tv ); 115 84 } 116 85
Note: See TracChangeset
for help on using the changeset viewer.