- Timestamp:
- Aug 6, 2009, 12:35:50 AM (15 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_mail.c
r238 r240 1584 1584 length = res_query (hostname, C_IN, T_MX, 1585 1585 (unsigned char *) reply, 4095); 1586 1586 1587 if (length < 1) 1587 1588 { … … 1649 1650 } 1650 1651 } 1652 1651 1653 count = ntohs (header->ancount); 1652 1654 if (count < 1) … … 1688 1690 /* HEADER NAME 1689 1691 */ 1690 ret = dn_expand ((unsigned char *) &reply, eom, comp_dn,1692 ret = dn_expand ((unsigned char *) reply, eom, comp_dn, 1691 1693 (char *) expanded, 1023); 1692 1694 comp_dn += ret; … … 1711 1713 } 1712 1714 1715 1713 1716 /* CLASS (re-use 'type' var) 1714 1717 */ … … 1723 1726 } 1724 1727 1728 1725 1729 /* TTL 1726 1730 */ … … 1758 1762 } 1759 1763 1760 ret = dn_expand ((unsigned char *) &reply, eom, comp_dn,1764 ret = dn_expand ((unsigned char *) reply, eom, comp_dn, 1761 1765 (char *) expanded, 1023); 1762 1766 comp_dn += ret; -
trunk/src/sh_nmail.c
r232 r240 44 44 45 45 SH_MUTEX_INIT(mutex_listall, PTHREAD_MUTEX_INITIALIZER); 46 SH_MUTEX_INIT(mutex_flush_l, PTHREAD_MUTEX_INITIALIZER); 46 47 47 48 /* Pointer to last address */ … … 376 377 } 377 378 379 /* Is not called from same(recursively) or different thread 380 */ 378 381 static 379 382 int sh_nmail_flag_recipients (int level, const char * message, … … 391 394 } 392 395 396 /* Can be called from same thread with mutex_listall held via sh_nmail_flush() 397 */ 393 398 static 394 399 int sh_nmail_test_recipients (int level, const char * message, … … 399 404 if (message) 400 405 { 401 SH_MUTEX_LOCK_UNSAFE(mutex_listall); 402 retval = sh_nmail_compute_recipients (level, message, alias, 0); 403 SH_MUTEX_UNLOCK_UNSAFE(mutex_listall); 406 if (0 == SH_MUTEX_TRYLOCK_UNSAFE(mutex_flush_l)) 407 { 408 SH_MUTEX_LOCK_UNSAFE(mutex_listall); 409 retval = sh_nmail_compute_recipients (level, message, alias, 0); 410 SH_MUTEX_UNLOCK_UNSAFE(mutex_listall); 411 SH_MUTEX_UNLOCK_UNSAFE(mutex_flush_l); 412 } 404 413 } 405 414 return retval; … … 426 435 } 427 436 437 static int nmail_count = 0; 438 428 439 /* 429 440 * First mark list of recipients, then call sh_mail_msg(). … … 433 444 { 434 445 volatile int retval = 0; 435 static int count = 0;436 446 437 447 /* Need to: … … 445 455 if (0 == SH_MUTEX_TRYLOCK_UNSAFE(nmail_lock)) 446 456 { 447 ++ count;448 if ( count != 1)449 { 450 -- count;457 ++nmail_count; 458 if (nmail_count != 1) 459 { 460 --nmail_count; 451 461 SH_MUTEX_UNLOCK_UNSAFE(nmail_lock); 452 462 goto cleanup; … … 468 478 } 469 479 SH_MUTEX_LOCK_UNSAFE(nmail_lock); 470 -- count;480 --nmail_count; 471 481 SH_MUTEX_UNLOCK_UNSAFE(nmail_lock); 472 482 } … … 477 487 } 478 488 489 static int sh_nmail_flush_int (void); 490 491 int sh_nmail_flush () 492 { 493 int retval = 0; 494 495 if (0 == SH_MUTEX_TRYLOCK_UNSAFE(nmail_lock)) 496 { 497 ++nmail_count; 498 if (nmail_count != 1) 499 { 500 --nmail_count; 501 SH_MUTEX_UNLOCK_UNSAFE(nmail_lock); 502 return retval; 503 } 504 SH_MUTEX_UNLOCK_UNSAFE(nmail_lock); 505 506 retval = sh_nmail_flush_int (); 507 508 SH_MUTEX_LOCK_UNSAFE(nmail_lock); 509 --nmail_count; 510 SH_MUTEX_UNLOCK_UNSAFE(nmail_lock); 511 } 512 return retval; 513 } 514 515 /* warning: variable âlistâ might be clobbered by âlongjmpâ or âvforkâ*/ 516 static struct alias ** list_dummy; 517 479 518 /* 480 519 * Loop over all recipients in stack. … … 483 522 */ 484 523 485 int sh_nmail_flush()524 static int sh_nmail_flush_int () 486 525 { 487 526 int retval = 0; … … 491 530 struct alias * dlist; 492 531 532 /* warning: variable âlistâ might be clobbered by âlongjmpâ or âvforkâ*/ 533 list_dummy = &list; 534 493 535 SH_MUTEX_LOCK(mutex_listall); 494 536 … … 529 571 list = compiled_recipient_list; 530 572 573 SH_MUTEX_LOCK(mutex_flush_l); 531 574 (void) sh_mail_msg(sh_string_str(msg)); 575 SH_MUTEX_UNLOCK(mutex_flush_l); 576 532 577 sh_string_destroy(&msg); 533 578 … … 591 636 if (smsg) 592 637 { 638 SH_MUTEX_LOCK(mutex_flush_l); 593 639 (void) sh_mail_msg(sh_string_str(smsg)); 640 SH_MUTEX_UNLOCK(mutex_flush_l); 594 641 sh_string_destroy(&smsg); 595 642 } … … 656 703 if (smsg) 657 704 { 705 SH_MUTEX_LOCK(mutex_flush_l); 658 706 (void) sh_mail_msg(sh_string_str(smsg)); 707 SH_MUTEX_UNLOCK(mutex_flush_l); 659 708 sh_string_destroy(&smsg); 660 709 }
Note:
See TracChangeset
for help on using the changeset viewer.