OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Licensed Materials - Property of IBM | 3 * Licensed Materials - Property of IBM |
4 * | 4 * |
5 * trousers - An open source TCG Software Stack | 5 * trousers - An open source TCG Software Stack |
6 * | 6 * |
7 * (C) Copyright International Business Machines Corp. 2004 | 7 * (C) Copyright International Business Machines Corp. 2004 |
8 * | 8 * |
9 */ | 9 */ |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 if (ht == NULL) { | 28 if (ht == NULL) { |
29 LogError("malloc of %zd bytes failed.", sizeof(struct host_table
)); | 29 LogError("malloc of %zd bytes failed.", sizeof(struct host_table
)); |
30 return TSPERR(TSS_E_OUTOFMEMORY); | 30 return TSPERR(TSS_E_OUTOFMEMORY); |
31 } | 31 } |
32 | 32 |
33 MUTEX_INIT(ht->lock); | 33 MUTEX_INIT(ht->lock); |
34 | 34 |
35 return TSS_SUCCESS; | 35 return TSS_SUCCESS; |
36 } | 36 } |
37 | 37 |
| 38 #ifdef SOLARIS |
| 39 #pragma init(_init) |
| 40 void _init(void) |
| 41 #else |
38 void __attribute__ ((constructor)) my_init(void) | 42 void __attribute__ ((constructor)) my_init(void) |
| 43 #endif |
39 { | 44 { |
40 host_table_init(); | 45 host_table_init(); |
41 __tspi_obj_list_init(); | 46 __tspi_obj_list_init(); |
42 } | 47 } |
43 | 48 |
44 #if 0 | |
45 void | 49 void |
46 host_table_final() | 50 host_table_final() |
47 { | 51 { |
48 struct host_table_entry *hte, *next = NULL; | 52 struct host_table_entry *hte, *next = NULL; |
49 | 53 |
50 MUTEX_LOCK(ht->lock); | 54 MUTEX_LOCK(ht->lock); |
51 | 55 |
52 for (hte = ht->entries; hte; hte = next) { | 56 for (hte = ht->entries; hte; hte = next) { |
53 if (hte) | 57 if (hte) |
54 next = hte->next; | 58 next = hte->next; |
| 59 if (hte->hostname) |
| 60 free(hte->hostname); |
| 61 if (hte->comm.buf) |
| 62 free(hte->comm.buf); |
55 free(hte); | 63 free(hte); |
56 } | 64 } |
57 | 65 |
58 MUTEX_UNLOCK(ht->lock); | 66 MUTEX_UNLOCK(ht->lock); |
59 | 67 |
60 free(ht); | 68 free(ht); |
61 ht = NULL; | 69 ht = NULL; |
62 } | 70 } |
63 | 71 |
| 72 #ifdef SOLARIS |
| 73 #pragma fini(_fini) |
| 74 void _fini(void) |
| 75 #else |
64 void __attribute__ ((destructor)) my_fini(void) | 76 void __attribute__ ((destructor)) my_fini(void) |
| 77 #endif |
65 { | 78 { |
66 host_table_final(); | 79 host_table_final(); |
67 } | 80 } |
68 #endif | |
69 | 81 |
70 TSS_RESULT | 82 TSS_RESULT |
71 __tspi_add_table_entry(TSS_HCONTEXT tspContext, BYTE *host, int type, struct hos
t_table_entry **ret) | 83 __tspi_add_table_entry(TSS_HCONTEXT tspContext, BYTE *host, int type, struct hos
t_table_entry **ret) |
72 { | 84 { |
73 struct host_table_entry *entry, *tmp; | 85 struct host_table_entry *entry, *tmp; |
74 | 86 |
75 entry = calloc(1, sizeof(struct host_table_entry)); | 87 entry = calloc(1, sizeof(struct host_table_entry)); |
76 if (entry == NULL) { | 88 if (entry == NULL) { |
77 LogError("malloc of %zd bytes failed.", sizeof(struct host_table
_entry)); | 89 LogError("malloc of %zd bytes failed.", sizeof(struct host_table
_entry)); |
78 return TSPERR(TSS_E_OUTOFMEMORY); | 90 return TSPERR(TSS_E_OUTOFMEMORY); |
(...skipping 10 matching lines...) Expand all Loading... |
89 return TSPERR(TSS_E_OUTOFMEMORY); | 101 return TSPERR(TSS_E_OUTOFMEMORY); |
90 } | 102 } |
91 MUTEX_INIT(entry->lock); | 103 MUTEX_INIT(entry->lock); |
92 | 104 |
93 MUTEX_LOCK(ht->lock); | 105 MUTEX_LOCK(ht->lock); |
94 | 106 |
95 for (tmp = ht->entries; tmp; tmp = tmp->next) { | 107 for (tmp = ht->entries; tmp; tmp = tmp->next) { |
96 if (tmp->tspContext == tspContext) { | 108 if (tmp->tspContext == tspContext) { |
97 LogError("Tspi_Context_Connect attempted on an already c
onnected context!"); | 109 LogError("Tspi_Context_Connect attempted on an already c
onnected context!"); |
98 MUTEX_UNLOCK(ht->lock); | 110 MUTEX_UNLOCK(ht->lock); |
| 111 free(entry->hostname); |
99 free(entry->comm.buf); | 112 free(entry->comm.buf); |
100 free(entry); | 113 free(entry); |
101 return TSPERR(TSS_E_CONNECTION_FAILED); | 114 return TSPERR(TSS_E_CONNECTION_FAILED); |
102 } | 115 } |
103 } | 116 } |
104 | 117 |
105 if( ht->entries == NULL ) { | 118 if( ht->entries == NULL ) { |
106 ht->entries = entry; | 119 ht->entries = entry; |
107 } else { | 120 } else { |
108 for (tmp = ht->entries; tmp->next; tmp = tmp->next) | 121 for (tmp = ht->entries; tmp->next; tmp = tmp->next) |
(...skipping 13 matching lines...) Expand all Loading... |
122 struct host_table_entry *hte, *prev = NULL; | 135 struct host_table_entry *hte, *prev = NULL; |
123 | 136 |
124 MUTEX_LOCK(ht->lock); | 137 MUTEX_LOCK(ht->lock); |
125 | 138 |
126 for (hte = ht->entries; hte; prev = hte, hte = hte->next) { | 139 for (hte = ht->entries; hte; prev = hte, hte = hte->next) { |
127 if (hte->tspContext == tspContext) { | 140 if (hte->tspContext == tspContext) { |
128 if (prev != NULL) | 141 if (prev != NULL) |
129 prev->next = hte->next; | 142 prev->next = hte->next; |
130 else | 143 else |
131 ht->entries = hte->next; | 144 ht->entries = hte->next; |
| 145 if (hte->hostname) |
| 146 free(hte->hostname); |
132 free(hte->comm.buf); | 147 free(hte->comm.buf); |
133 free(hte); | 148 free(hte); |
134 break; | 149 break; |
135 } | 150 } |
136 } | 151 } |
137 | 152 |
138 MUTEX_UNLOCK(ht->lock); | 153 MUTEX_UNLOCK(ht->lock); |
139 } | 154 } |
140 | 155 |
141 struct host_table_entry * | 156 struct host_table_entry * |
(...skipping 16 matching lines...) Expand all Loading... |
158 return index; | 173 return index; |
159 } | 174 } |
160 | 175 |
161 void | 176 void |
162 put_table_entry(struct host_table_entry *entry) | 177 put_table_entry(struct host_table_entry *entry) |
163 { | 178 { |
164 if (entry) | 179 if (entry) |
165 MUTEX_UNLOCK(entry->lock); | 180 MUTEX_UNLOCK(entry->lock); |
166 } | 181 } |
167 | 182 |
OLD | NEW |