Changes in lib/events_libevent.c [04026d4:9ff5737]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/events_libevent.c
r04026d4 r9ff5737 32 32 #include <unistd.h> 33 33 #include <sys/types.h> 34 #include "proxy.h"35 36 34 #include <sys/time.h> 37 35 #include <event.h> 38 39 static guint id_next; 36 #include "proxy.h" 37 38 static void b_main_restart(); 39 static guint id_next = 1; 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 50 53 struct b_event_data 51 54 { … … 59 62 void b_main_init() 60 63 { 61 event_init(); 62 63 id_next = 1; 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 64 74 id_hash = g_hash_table_new( g_int_hash, g_int_equal ); 65 75 read_hash = g_hash_table_new( g_int_hash, g_int_equal ); … … 69 79 void b_main_run() 70 80 { 71 event_dispatch(); 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() 98 { 99 struct timeval tv; 100 101 memset( &tv, 0, sizeof( struct timeval ) ); 102 event_base_loopexit( leh, &tv ); 103 104 event_debug( "b_main_restart()\n" ); 72 105 } 73 106 74 107 void b_main_quit() 75 108 { 76 struct timeval tv; 77 78 /* libevent sometimes generates events before really quitting, 109 /* Tell b_main_run() that it shouldn't restart the loop. Also, 110 libevent sometimes generates events before really quitting, 79 111 we want to stop them. */ 80 112 quitting = 1; 81 113 82 memset( &tv, 0, sizeof( struct timeval ) ); 83 event_loopexit( &tv ); 114 b_main_restart(); 84 115 } 85 116
Note: See TracChangeset
for help on using the changeset viewer.