Changes in uspace/app/trace/ipcp.c [a3b339b4:c0699467] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/trace/ipcp.c
ra3b339b4 rc0699467 38 38 #include <sys/typefmt.h> 39 39 #include <abi/ipc/methods.h> 40 #include <macros.h>41 40 #include "ipc_desc.h" 42 41 #include "proto.h" … … 53 52 ipc_callid_t call_hash; 54 53 55 ht_link_t link;54 link_t link; 56 55 } pending_call_t; 57 56 … … 65 64 int have_conn[MAX_PHONE]; 66 65 67 static hash_table_t pending_calls; 66 #define PCALL_TABLE_CHAINS 32 67 hash_table_t pending_calls; 68 68 69 69 /* … … 73 73 proto_t *proto_unknown; /**< Protocol with no known methods. */ 74 74 75 76 static size_t pending_call_key_hash(void *key) 77 { 78 ipc_callid_t *call_id = (ipc_callid_t *)key; 79 return *call_id; 80 } 81 82 static size_t pending_call_hash(const ht_link_t *item) 83 { 84 pending_call_t *hs = hash_table_get_inst(item, pending_call_t, link); 85 return hs->call_hash; 86 } 87 88 static bool pending_call_key_equal(void *key, const ht_link_t *item) 89 { 90 ipc_callid_t *call_id = (ipc_callid_t *)key; 91 pending_call_t *hs = hash_table_get_inst(item, pending_call_t, link); 92 93 return *call_id == hs->call_hash; 94 } 95 96 static hash_table_ops_t pending_call_ops = { 75 static hash_index_t pending_call_hash(unsigned long key[]); 76 static int pending_call_compare(unsigned long key[], hash_count_t keys, 77 link_t *item); 78 static void pending_call_remove_callback(link_t *item); 79 80 hash_table_operations_t pending_call_ops = { 97 81 .hash = pending_call_hash, 98 .key_hash = pending_call_key_hash, 99 .key_equal = pending_call_key_equal, 100 .equal = NULL, 101 .remove_callback = NULL 82 .compare = pending_call_compare, 83 .remove_callback = pending_call_remove_callback 102 84 }; 85 86 87 static hash_index_t pending_call_hash(unsigned long key[]) 88 { 89 // printf("pending_call_hash\n"); 90 return key[0] % PCALL_TABLE_CHAINS; 91 } 92 93 static int pending_call_compare(unsigned long key[], hash_count_t keys, 94 link_t *item) 95 { 96 pending_call_t *hs; 97 98 // printf("pending_call_compare\n"); 99 hs = hash_table_get_instance(item, pending_call_t, link); 100 101 // FIXME: this will fail if sizeof(long) < sizeof(void *). 102 return key[0] == hs->call_hash; 103 } 104 105 static void pending_call_remove_callback(link_t *item) 106 { 107 // printf("pending_call_remove_callback\n"); 108 } 103 109 104 110 … … 140 146 void ipcp_init(void) 141 147 { 148 ipc_m_desc_t *desc; 149 oper_t *oper; 150 142 151 val_type_t arg_def[OPER_MAX_ARGS] = { 143 152 V_INTEGER, … … 159 168 proto_system = proto_new("system"); 160 169 161 for (size_t i = 0; i < ipc_methods_len; i++) { 162 oper_t *oper = oper_new(ipc_methods[i].name, OPER_MAX_ARGS, 163 arg_def, V_INTEGER, OPER_MAX_ARGS, arg_def); 164 proto_add_oper(proto_system, ipc_methods[i].number, oper); 165 } 166 167 bool ok = hash_table_create(&pending_calls, 0, 0, &pending_call_ops); 168 assert(ok); 170 desc = ipc_methods; 171 while (desc->number != 0) { 172 oper = oper_new(desc->name, OPER_MAX_ARGS, arg_def, V_INTEGER, 173 OPER_MAX_ARGS, arg_def); 174 proto_add_oper(proto_system, desc->number, oper); 175 176 ++desc; 177 } 178 179 hash_table_create(&pending_calls, PCALL_TABLE_CHAINS, 1, &pending_call_ops); 169 180 } 170 181 … … 179 190 pending_call_t *pcall; 180 191 proto_t *proto; 192 unsigned long key[1]; 181 193 oper_t *oper; 182 194 sysarg_t *args; … … 242 254 pcall->oper = oper; 243 255 244 hash_table_insert(&pending_calls, &pcall->link); 256 key[0] = hash; 257 258 hash_table_insert(&pending_calls, key, &pcall->link); 245 259 } 246 260 … … 320 334 void ipcp_call_in(ipc_call_t *call, ipc_callid_t hash) 321 335 { 322 ht_link_t *item;336 link_t *item; 323 337 pending_call_t *pcall; 338 unsigned long key[1]; 324 339 325 340 if ((hash & IPC_CALLID_ANSWERED) == 0 && hash != IPCP_CALLID_SYNC) { … … 332 347 333 348 hash = hash & ~IPC_CALLID_ANSWERED; 334 335 item = hash_table_find(&pending_calls, &hash); 349 key[0] = hash; 350 351 item = hash_table_find(&pending_calls, key); 336 352 if (item == NULL) 337 353 return; /* No matching question found */ … … 341 357 */ 342 358 343 pcall = hash_table_get_inst (item, pending_call_t, link);344 hash_table_remove(&pending_calls, &hash);359 pcall = hash_table_get_instance(item, pending_call_t, link); 360 hash_table_remove(&pending_calls, key, 1); 345 361 346 362 parse_answer(hash, pcall, call);
Note:
See TracChangeset
for help on using the changeset viewer.