- Timestamp:
- 2007-11-28T23:24:26Z (17 years ago)
- Branches:
- master
- Children:
- 9ff5737
- Parents:
- 221a273
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/events_libevent.c
r221a273 rb6a2373 37 37 #include <event.h> 38 38 39 static guint id_next; 39 static void b_main_restart(); 40 41 static guint id_next = 1; 40 42 static GHashTable *id_hash; 41 43 static int quitting = 0; … … 48 50 static GHashTable *write_hash; 49 51 52 struct event_base *leh; 53 struct event_base *old_leh; 54 50 55 struct b_event_data 51 56 { … … 59 64 void b_main_init() 60 65 { 61 event_init(); 62 63 id_next = 1; 66 if( leh != NULL ) 67 { 68 /* Clean up the hash tables? */ 69 70 b_main_restart(); 71 old_leh = leh; 72 } 73 74 leh = event_init(); 75 64 76 id_hash = g_hash_table_new( g_int_hash, g_int_equal ); 65 77 read_hash = g_hash_table_new( g_int_hash, g_int_equal ); … … 69 81 void b_main_run() 70 82 { 71 event_dispatch(); 83 /* This while loop is necessary to exit the event loop and start a 84 different one (necessary for ForkDaemon mode). */ 85 while( event_base_dispatch( leh ) == 0 && !quitting ) 86 { 87 if( old_leh != NULL ) 88 { 89 /* For some reason this just isn't allowed... 90 Possibly a bug in older versions, will see later. 91 event_base_free( old_leh ); */ 92 old_leh = NULL; 93 } 94 95 printf( "New event loop.\n" ); 96 } 97 } 98 99 static void b_main_restart() 100 { 101 struct timeval tv; 102 103 memset( &tv, 0, sizeof( struct timeval ) ); 104 event_base_loopexit( leh, &tv ); 105 106 printf( "b_main_restart()\n" ); 72 107 } 73 108 74 109 void b_main_quit() 75 110 { 76 struct timeval tv; 77 78 /* libevent sometimes generates events before really quitting, 111 /* Tell b_main_run() that it shouldn't restart the loop. Also, 112 libevent sometimes generates events before really quitting, 79 113 we want to stop them. */ 80 114 quitting = 1; 81 115 82 memset( &tv, 0, sizeof( struct timeval ) ); 83 event_loopexit( &tv ); 116 b_main_restart(); 84 117 } 85 118
Note: See TracChangeset
for help on using the changeset viewer.