Changeset 640
- Timestamp:
- 07/25/05 20:39:45 (3 years ago)
- Files:
-
- trunk/src/users.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/users.c
r630 r640 34 34 static char *spool_dir; 35 35 char *default_user_locale="C"; 36 static guint users_tick_source; 37 38 static int user_destroy(User *s); 39 40 static gboolean users_gc_hash_func(gpointer key,gpointer value,gpointer udata){ 41 User *u=(User *)value; 42 43 if (u->refcount==0) { 44 user_destroy(u); 45 g_free(key); 46 } 47 return TRUE; 48 } 49 50 int users_gc(){ 51 g_hash_table_foreach_remove(users_jid,users_gc_hash_func,NULL); 52 return 0; 53 } 54 55 gboolean users_tick(gpointer data){ 56 57 users_gc(); 58 return TRUE; 59 } 36 60 37 61 int users_init(){ … … 49 73 users_jid=g_hash_table_new(g_str_hash,g_str_equal); 50 74 if (!users_jid) return -1; 75 76 users_tick_source=g_timeout_add(60000,users_tick,NULL); 77 51 78 return 0; 52 79 } 53 80 54 static int user_destroy(User *s);55 56 static gboolean users_gc_hash_func(gpointer key,gpointer value,gpointer udata){57 User *u=(User *)value;58 59 if (u->refcount==0) {60 user_destroy(u);61 g_free(key);62 }63 return TRUE;64 }65 66 int users_gc(){67 g_hash_table_foreach_remove(users_jid,users_gc_hash_func,NULL);68 return 0;69 }70 81 71 82 … … 73 84 guint s; 74 85 86 g_source_remove(users_tick_source); 75 87 s=g_hash_table_size(users_jid); 76 88 if (s) g_debug(L_("Before cleanup: %u users in hash table"),s); … … 648 660 g_free(njid); 649 661 662 users_gc(); 663 650 664 return r; 651 665 }
