[BUG] : compile errors and threading issues



	Hi all,
I'm trying to code the new sentbox behaviour upon sending.
But before that there a 2 serious issues : balsa won't compile with the 
following configure options
./configure  --with-esmtp=no --enable-threads=no
The problem is in libbalsa/send.c, in libbalsa_process_queue (the 
non-esmtp version) :

gboolean libbalsa_process_queue(LibBalsaMailbox* outbox, gint 
encoding, 		       gboolean flow)
{
     [Variables decl.];

     /* We do messages in queue now only if where are not sending them 
already */

     send_lock();

     ensure_send_progress_dialog();
     if (sending_threads==0) {
	libbalsa_mailbox_open(outbox);
	lista = outbox->message_list;
	 
	mqi = message_queue;
	while (lista != NULL) {
	    queu = LIBBALSA_MESSAGE(lista->data);
	    	    new_message = msg_queue_item_new(queu);
	    if (!libbalsa_create_msg(queu, new_message->message,
				     
new_message->tempfile, 				     encoding, flow, 1)) {
		msg_queue_item_destroy(new_message);
	    } else {
		if (mqi)
		    mqi->next_message = new_message;
		else
		    message_queue = new_message;

		mqi = new_message;
		total_messages_left++;
	    }
	    lista = lista->next;
	}
---> #ifdef BALSA_USE_THREADS
     }
         start_thread = sending_threads==0;

     if (start_thread) {
         sending_threads++;
	send_message_info=send_message_info_new(outbox);

	pthread_create(&send_mail, NULL,
		       (void *) &balsa_send_message_real, 
send_message_info);
	/* Detach so we don't need to pthread_join
	 * This means that all resources will be
	 * reclaimed as soon as the thread exits
	 */
	pthread_detach(send_mail);
     }
#else				/*non-threaded code */
         send_message_info=send_message_info_new(outbox);
     balsa_send_message_real(send_message_info);
#endif
     send_unlock();
     return TRUE;
}

The ifdef is misplaced (One line down corrects this). This is for the 
compile problem, but then when you compare both instances of 
libbalsa_process_queue (with or without libEsmtp), there is a big 
difference in the way they handle the threading issues, and both seems 
buggy.
The non esmtp version (the one above) tests if sending thread is yet in 
progres, and do nothing if it is.
The esmtp version just do not test if another thread is in progress. What 
is the good way to do it ? Could someone review it also please.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]