Changeset 2503
- Timestamp:
- 07/26/07 10:49:35
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r2499 r2503 1 2007-07-26 Philip Van Hoof <pvanhoof@gnome.org> 2 3 * More granularity in the locking of the POP code 4 * Several fixes in the POP code 5 1 6 2007-07-25 Philip Van Hoof <pvanhoof@gnome.org> 2 7 trunk/libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-folder.c
r2499 r2503 96 96 for (i=0;i<pop3_folder->uids->len;i++,fi++) { 97 97 if (fi[0]->cmd) { 98 99 g_static_rec_mutex_lock (pop3_store->eng_lock); 100 101 if (pop3_store->engine == NULL) { 102 g_ptr_array_free(pop3_folder->uids, TRUE); 103 g_hash_table_destroy(pop3_folder->uids_uid); 104 g_free(fi[0]->uid); 105 g_free(fi[0]); 106 g_static_rec_mutex_unlock (pop3_store->eng_lock); 107 return; 108 } 109 98 110 while (camel_pop3_engine_iterate(pop3_store->engine, fi[0]->cmd) > 0) 99 111 ; 100 112 camel_pop3_engine_command_free(pop3_store->engine, fi[0]->cmd); 113 114 g_static_rec_mutex_unlock (pop3_store->eng_lock); 101 115 } 102 116 … … 516 530 517 531 if (!expunge) { 532 camel_service_disconnect (CAMEL_SERVICE (pop3_store), TRUE, &dex); 518 533 g_static_rec_mutex_unlock (pop3_store->eng_lock); 519 camel_service_disconnect (CAMEL_SERVICE (pop3_store), TRUE, &dex);520 534 return; 521 535 } … … 957 971 958 972 g_static_rec_mutex_lock (pop3_store->eng_lock); 973 974 if (pop3_store->engine == NULL) { 975 g_static_rec_mutex_unlock (pop3_store->eng_lock); 976 goto fail; 977 } 978 959 979 while ((i = camel_pop3_engine_iterate(pop3_store->engine, fi->cmd)) > 0) 960 980 ; 981 961 982 g_static_rec_mutex_unlock (pop3_store->eng_lock); 962 983 … … 965 986 966 987 /* getting error code? */ 967 /* g_assert (fi->cmd->state == CAMEL_POP3_COMMAND_DATA);*/988 /* g_assert (fi->cmd->state == CAMEL_POP3_COMMAND_DATA); */ 968 989 969 990 g_static_rec_mutex_lock (pop3_store->eng_lock); … … 1100 1121 while (camel_pop3_engine_iterate(pop3_store->engine, cmd) > 0); 1101 1122 camel_pop3_engine_command_free(pop3_store->engine, cmd); 1123 1102 1124 g_static_rec_mutex_unlock (pop3_store->eng_lock); 1103 1125 } … … 1259 1281 fi->err = errno; 1260 1282 camel_pop3_engine_command_free(pop3_store->engine, pcr); 1283 1261 1284 g_static_rec_mutex_unlock (pop3_store->eng_lock); 1262 1285 … … 1408 1431 camel_folder_change_info_remove_uid (changes, uids->pdata[i]); 1409 1432 /* We intentionally don't remove it from the cache because 1410 * the cached data may be useful in replaying a COPY later. 1411 */ 1433 * the cached data may be useful in replaying a COPY later. */ 1412 1434 } 1413 1435 camel_folder_summary_save (folder->summary); trunk/libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-store.c
r2499 r2503 331 331 store->delete_after = atoi(delete_days); 332 332 333 g_static_rec_mutex_lock (store->eng_lock); 333 g_static_rec_mutex_lock (store->eng_lock); /* ! */ 334 334 335 if (!(store->engine = camel_pop3_engine_new (tcp_stream, flags))) { 335 336 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, … … 337 338 service->url->host); 338 339 camel_object_unref (tcp_stream); 339 g_static_rec_mutex_unlock (store->eng_lock); 340 341 g_static_rec_mutex_unlock (store->eng_lock); /* ! */ 342 340 343 return FALSE; 341 344 } 342 345 store->engine->store = store; 343 346 store->engine->partial_happening = FALSE; 347 348 #ifndef HAVE_SSL /* ! */ 344 349 g_static_rec_mutex_unlock (store->eng_lock); 350 #endif 345 351 346 352 if (!must_tls && (ssl_mode != MODE_TLS)) … … 348 354 camel_object_unref (tcp_stream); 349 355 store->connected = TRUE; 356 357 #ifdef HAVE_SSL /* ! */ 358 g_static_rec_mutex_unlock (store->eng_lock); 359 #endif 360 350 361 return TRUE; 351 362 } … … 405 416 store->connected = TRUE; 406 417 418 g_static_rec_mutex_unlock (store->eng_lock); /* ! */ 419 407 420 return TRUE; 408 421 409 422 stls_exception: 423 424 410 425 if (clean_quit) 411 426 { … … 417 432 } 418 433 419 g_static_rec_mutex_lock (store->eng_lock);420 434 camel_object_unref (CAMEL_OBJECT (store->engine)); 421 435 camel_object_unref (CAMEL_OBJECT (tcp_stream)); 422 436 store->engine = NULL; 423 437 store->connected = FALSE; 424 g_static_rec_mutex_unlock (store->eng_lock); 438 439 g_static_rec_mutex_unlock (store->eng_lock); /* ! */ 425 440 426 441 return FALSE; … … 500 515 GList *types = NULL; 501 516 502 types = CAMEL_SERVICE_CLASS (parent_class)->query_auth_types (service, ex);517 types = CAMEL_SERVICE_CLASS (parent_class)->query_auth_types (service, ex); 503 518 if (camel_exception_is_set (ex)) 504 519 return NULL; 505 520 506 521 if (connect_to_server_wrapper (service, NULL)) { 522 523 g_static_rec_mutex_lock (store->eng_lock); 524 525 if (store->engine == NULL) { 526 g_static_rec_mutex_unlock (store->eng_lock); 527 return NULL; 528 } 529 507 530 types = g_list_concat(types, g_list_copy(store->engine->auth)); 531 g_static_rec_mutex_unlock (store->eng_lock); 532 508 533 pop3_disconnect (service, TRUE, NULL); 509 534 } else { … … 614 639 615 640 if (!service->url->authmech) { 641 642 g_static_rec_mutex_lock (store->eng_lock); 643 644 if (store->engine == NULL) { 645 g_static_rec_mutex_unlock (store->eng_lock); 646 return FALSE; 647 } 648 616 649 /* pop engine will take care of pipelining ability */ 617 650 pcu = camel_pop3_engine_command_new(store->engine, 0, NULL, NULL, "USER %s\r\n", service->url->user); 618 651 pcp = camel_pop3_engine_command_new(store->engine, 0, NULL, NULL, "PASS %s\r\n", service->url->passwd); 652 653 g_static_rec_mutex_unlock (store->eng_lock); 654 619 655 } else if (strcmp(service->url->authmech, "+APOP") == 0 && store->engine->apop) { 620 656 char *secret, md5asc[33], *d; … … 635 671 d++; 636 672 } 637 673 674 g_static_rec_mutex_lock (store->eng_lock); 675 676 if (store->engine == NULL) { 677 g_static_rec_mutex_unlock (store->eng_lock); 678 return FALSE; 679 } 680 638 681 secret = g_alloca(strlen(store->engine->apop)+strlen(service->url->passwd)+1); 639 682 sprintf(secret, "%s%s", store->engine->apop, service->url->passwd); … … 642 685 for (s = md5sum, d = md5asc; d < md5asc + 32; s++, d += 2) 643 686 sprintf (d, "%.2x", *s); 644 687 645 688 pcp = camel_pop3_engine_command_new(store->engine, 0, NULL, NULL, "APOP %s %s\r\n", 646 689 service->url->user, md5asc); 690 691 g_static_rec_mutex_unlock (store->eng_lock); 692 647 693 } else { 648 694 CamelServiceAuthType *auth; 649 695 GList *l; 650 696 697 g_static_rec_mutex_lock (store->eng_lock); 698 699 if (store->engine == NULL) { 700 g_static_rec_mutex_unlock (store->eng_lock); 701 return FALSE; 702 } 703 651 704 l = store->engine->auth; 652 705 while (l) { 653 706 auth = l->data; 654 if (strcmp(auth->authproto, service->url->authmech) == 0) 707 if (strcmp(auth->authproto, service->url->authmech) == 0) { 708 g_static_rec_mutex_unlock (store->eng_lock); 655 709 return try_sasl(store, service->url->authmech, ex) == -1; 710 } 656 711 l = l->next; 657 712 } 658 713 714 g_static_rec_mutex_unlock (store->eng_lock); 715 659 716 camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID, 660 717 _("Unable to connect to POP server %s: " … … 663 720 return FALSE; 664 721 } 665 722 723 g_static_rec_mutex_lock (store->eng_lock); 724 725 if (store->engine == NULL) { 726 g_static_rec_mutex_unlock (store->eng_lock); 727 return FALSE; 728 } 729 666 730 while ((status = camel_pop3_engine_iterate(store->engine, pcp)) > 0) 667 731 ; 668 732 733 669 734 if (status == -1) { 670 735 if (errno == EINTR) { … … 689 754 CAMEL_SERVICE (store)->url->host, 690 755 store->engine->line ? (char *)store->engine->line : _("Unknown error")); 691 692 camel_pop3_engine_command_free (store->engine, pcp);756 757 camel_pop3_engine_command_free (store->engine, pcp); 693 758 694 759 if (pcu) 695 760 camel_pop3_engine_command_free(store->engine, pcu); 696 761 762 g_static_rec_mutex_unlock (store->eng_lock); 763 697 764 return status; 698 765 } … … 706 773 char *errbuf = NULL; 707 774 int status; 708 775 709 776 session = camel_service_get_session (service); 710 777 … … 737 804 738 805 /* Now that we are in the TRANSACTION state, try regetting the capabilities */ 806 807 g_static_rec_mutex_lock (store->eng_lock); 808 809 if (store->engine == NULL) { 810 g_static_rec_mutex_unlock (store->eng_lock); 811 return FALSE; 812 } 813 739 814 store->engine->state = CAMEL_POP3_ENGINE_TRANSACTION; 740 815 camel_pop3_engine_reget_capabilities (store->engine); 741 816 817 g_static_rec_mutex_unlock (store->eng_lock); 818 742 819 return TRUE; 743 820 } … … 747 824 { 748 825 CamelPOP3Store *store = CAMEL_POP3_STORE (service); 749 826 827 g_static_rec_mutex_lock (store->eng_lock); 828 if (store->engine == NULL) { 829 g_static_rec_mutex_unlock (store->eng_lock); 830 return TRUE; 831 } 832 750 833 if (clean) { 751 834 CamelPOP3Command *pc; … … 757 840 } 758 841 759 g_static_rec_mutex_lock (store->eng_lock);760 842 camel_object_unref((CamelObject *)store->engine); 761 843 store->engine = NULL;
