Changeset 4592
- Timestamp:
- 11/05/08 17:21:57 (2 months ago)
- Files:
-
- trunk/src/libstrongswan/crypto/crypto_factory.c (modified) (34 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/libstrongswan/crypto/crypto_factory.c
r4307 r4592 79 79 80 80 /** 81 * mutexto lock access to modules82 */ 83 mutex_t *mutex;81 * rwlock to lock access to modules 82 */ 83 rwlock_t *lock; 84 84 }; 85 85 … … 94 94 crypter_t *crypter = NULL; 95 95 96 this-> mutex->lock(this->mutex);96 this->lock->read_lock(this->lock); 97 97 enumerator = this->crypters->create_enumerator(this->crypters); 98 98 while (enumerator->enumerate(enumerator, &entry)) … … 108 108 } 109 109 enumerator->destroy(enumerator); 110 this-> mutex->unlock(this->mutex);110 this->lock->unlock(this->lock); 111 111 return crypter; 112 112 } … … 122 122 signer_t *signer = NULL; 123 123 124 this-> mutex->lock(this->mutex);124 this->lock->read_lock(this->lock); 125 125 enumerator = this->signers->create_enumerator(this->signers); 126 126 while (enumerator->enumerate(enumerator, &entry)) … … 136 136 } 137 137 enumerator->destroy(enumerator); 138 this-> mutex->unlock(this->mutex);138 this->lock->unlock(this->lock); 139 139 140 140 return signer; … … 151 151 hasher_t *hasher = NULL; 152 152 153 this-> mutex->lock(this->mutex);153 this->lock->read_lock(this->lock); 154 154 enumerator = this->hashers->create_enumerator(this->hashers); 155 155 while (enumerator->enumerate(enumerator, &entry)) … … 165 165 } 166 166 enumerator->destroy(enumerator); 167 this-> mutex->unlock(this->mutex);167 this->lock->unlock(this->lock); 168 168 return hasher; 169 169 } … … 179 179 prf_t *prf = NULL; 180 180 181 this-> mutex->lock(this->mutex);181 this->lock->read_lock(this->lock); 182 182 enumerator = this->prfs->create_enumerator(this->prfs); 183 183 while (enumerator->enumerate(enumerator, &entry)) … … 193 193 } 194 194 enumerator->destroy(enumerator); 195 this-> mutex->unlock(this->mutex);195 this->lock->unlock(this->lock); 196 196 return prf; 197 197 } … … 207 207 rng_constructor_t constr = NULL; 208 208 209 this-> mutex->lock(this->mutex);209 this->lock->read_lock(this->lock); 210 210 enumerator = this->rngs->create_enumerator(this->rngs); 211 211 while (enumerator->enumerate(enumerator, &entry)) … … 222 222 } 223 223 enumerator->destroy(enumerator); 224 this-> mutex->unlock(this->mutex);224 this->lock->unlock(this->lock); 225 225 if (constr) 226 226 { … … 240 240 diffie_hellman_t *diffie_hellman = NULL; 241 241 242 this-> mutex->lock(this->mutex);242 this->lock->read_lock(this->lock); 243 243 enumerator = this->dhs->create_enumerator(this->dhs); 244 244 while (enumerator->enumerate(enumerator, &entry)) … … 254 254 } 255 255 enumerator->destroy(enumerator); 256 this-> mutex->unlock(this->mutex);256 this->lock->unlock(this->lock); 257 257 return diffie_hellman; 258 258 } … … 269 269 entry->algo = algo; 270 270 entry->create_crypter = create; 271 this-> mutex->lock(this->mutex);271 this->lock->write_lock(this->lock); 272 272 this->crypters->insert_last(this->crypters, entry); 273 this-> mutex->unlock(this->mutex);273 this->lock->unlock(this->lock); 274 274 } 275 275 … … 283 283 enumerator_t *enumerator; 284 284 285 this-> mutex->lock(this->mutex);285 this->lock->write_lock(this->lock); 286 286 enumerator = this->crypters->create_enumerator(this->crypters); 287 287 while (enumerator->enumerate(enumerator, &entry)) … … 294 294 } 295 295 enumerator->destroy(enumerator); 296 this-> mutex->unlock(this->mutex);296 this->lock->unlock(this->lock); 297 297 } 298 298 … … 307 307 entry->algo = algo; 308 308 entry->create_signer = create; 309 this-> mutex->lock(this->mutex);309 this->lock->write_lock(this->lock); 310 310 this->signers->insert_last(this->signers, entry); 311 this-> mutex->unlock(this->mutex);311 this->lock->unlock(this->lock); 312 312 } 313 313 … … 321 321 enumerator_t *enumerator; 322 322 323 this-> mutex->lock(this->mutex);323 this->lock->write_lock(this->lock); 324 324 enumerator = this->signers->create_enumerator(this->signers); 325 325 while (enumerator->enumerate(enumerator, &entry)) … … 332 332 } 333 333 enumerator->destroy(enumerator); 334 this-> mutex->unlock(this->mutex);334 this->lock->unlock(this->lock); 335 335 } 336 336 … … 345 345 entry->algo = algo; 346 346 entry->create_hasher = create; 347 this-> mutex->lock(this->mutex);347 this->lock->write_lock(this->lock); 348 348 this->hashers->insert_last(this->hashers, entry); 349 this-> mutex->unlock(this->mutex);349 this->lock->unlock(this->lock); 350 350 } 351 351 … … 359 359 enumerator_t *enumerator; 360 360 361 this-> mutex->lock(this->mutex);361 this->lock->write_lock(this->lock); 362 362 enumerator = this->hashers->create_enumerator(this->hashers); 363 363 while (enumerator->enumerate(enumerator, &entry)) … … 370 370 } 371 371 enumerator->destroy(enumerator); 372 this-> mutex->unlock(this->mutex);372 this->lock->unlock(this->lock); 373 373 } 374 374 … … 383 383 entry->algo = algo; 384 384 entry->create_prf = create; 385 this-> mutex->lock(this->mutex);385 this->lock->write_lock(this->lock); 386 386 this->prfs->insert_last(this->prfs, entry); 387 this-> mutex->unlock(this->mutex);387 this->lock->unlock(this->lock); 388 388 } 389 389 … … 396 396 enumerator_t *enumerator; 397 397 398 this-> mutex->lock(this->mutex);398 this->lock->write_lock(this->lock); 399 399 enumerator = this->prfs->create_enumerator(this->prfs); 400 400 while (enumerator->enumerate(enumerator, &entry)) … … 407 407 } 408 408 enumerator->destroy(enumerator); 409 this-> mutex->unlock(this->mutex);409 this->lock->unlock(this->lock); 410 410 } 411 411 … … 420 420 entry->algo = quality; 421 421 entry->create_rng = create; 422 this-> mutex->lock(this->mutex);422 this->lock->write_lock(this->lock); 423 423 this->rngs->insert_last(this->rngs, entry); 424 this-> mutex->unlock(this->mutex);424 this->lock->unlock(this->lock); 425 425 } 426 426 … … 433 433 enumerator_t *enumerator; 434 434 435 this-> mutex->lock(this->mutex);435 this->lock->write_lock(this->lock); 436 436 enumerator = this->rngs->create_enumerator(this->rngs); 437 437 while (enumerator->enumerate(enumerator, &entry)) … … 444 444 } 445 445 enumerator->destroy(enumerator); 446 this-> mutex->unlock(this->mutex);446 this->lock->unlock(this->lock); 447 447 } 448 448 … … 457 457 entry->algo = group; 458 458 entry->create_dh = create; 459 this-> mutex->lock(this->mutex);459 this->lock->write_lock(this->lock); 460 460 this->dhs->insert_last(this->dhs, entry); 461 this-> mutex->unlock(this->mutex);461 this->lock->unlock(this->lock); 462 462 } 463 463 … … 470 470 enumerator_t *enumerator; 471 471 472 this-> mutex->lock(this->mutex);472 this->lock->write_lock(this->lock); 473 473 enumerator = this->dhs->create_enumerator(this->dhs); 474 474 while (enumerator->enumerate(enumerator, &entry)) … … 481 481 } 482 482 enumerator->destroy(enumerator); 483 this-> mutex->unlock(this->mutex);483 this->lock->unlock(this->lock); 484 484 } 485 485 … … 512 512 linked_list_t *list, void *filter) 513 513 { 514 this-> mutex->lock(this->mutex);514 this->lock->read_lock(this->lock); 515 515 return enumerator_create_filter( 516 516 enumerator_create_filter( 517 517 list->create_enumerator(list), (void*)unique_check, 518 518 linked_list_create(), (void*)list->destroy), 519 filter, this-> mutex, (void*)this->mutex->unlock);519 filter, this->lock, (void*)this->lock->unlock); 520 520 } 521 521 … … 616 616 this->rngs->destroy_function(this->rngs, free); 617 617 this->dhs->destroy_function(this->dhs, free); 618 this-> mutex->destroy(this->mutex);618 this->lock->destroy(this->lock); 619 619 free(this); 620 620 } … … 658 658 this->rngs = linked_list_create(); 659 659 this->dhs = linked_list_create(); 660 this-> mutex = mutex_create(MUTEX_RECURSIVE);660 this->lock = rwlock_create(RWLOCK_DEFAULT); 661 661 662 662 return &this->public;
