masqmail

diff src/deliver.c @ 237:5f9f3a65032e

refactoring: new function split_rcpts() replaces two others split_rcpts() merges rcptlist_with_one_of_hostlist() and rcptlist_with_addr_is_local() into one with hardly adding complexity I'd actually say that the overall complexity decreased. Have a look at the comment for split_rcpts() in route.c
author markus schnalke <meillo@marmaro.de>
date Fri, 22 Oct 2010 11:56:47 -0300
parents 996b53a50f55
children 72e377210d5e
line diff
     1.1 --- a/src/deliver.c	Fri Oct 22 11:15:24 2010 -0300
     1.2 +++ b/src/deliver.c	Fri Oct 22 11:56:47 2010 -0300
     1.3 @@ -668,7 +668,7 @@
     1.4  		GList *rcpt_list;
     1.5  		GList *local_rcpt_list = NULL;
     1.6  		GList *localnet_rcpt_list = NULL;
     1.7 -		GList *other_rcpt_list;
     1.8 +		GList *other_rcpt_list = NULL;
     1.9  
    1.10  		if (!spool_lock(msgout->msg->uid)) {
    1.11  			DEBUG(5) debugf("spool_lock(%s) failed.\n", msgout->msg->uid);
    1.12 @@ -689,40 +689,28 @@
    1.13  			rcpt_list = aliased_rcpt_list;
    1.14  		}
    1.15  
    1.16 +		split_rcpts(rcpt_list, conf.local_nets, &local_rcpt_list, &localnet_rcpt_list, &other_rcpt_list);
    1.17 +		g_list_free(rcpt_list);
    1.18 +
    1.19  		/* local recipients */
    1.20 -		other_rcpt_list = NULL;
    1.21 -		rcptlist_with_addr_is_local(rcpt_list, &local_rcpt_list, &other_rcpt_list);
    1.22 -
    1.23 -		if (flags & DLVR_LOCAL) {
    1.24 -			if (local_rcpt_list != NULL) {
    1.25 -				msg_out *local_msgout = clone_msg_out(msgout);
    1.26 -				local_msgout->rcpt_list = local_rcpt_list;
    1.27 -				local_msgout_list = g_list_append(local_msgout_list, local_msgout);
    1.28 -			}
    1.29 +		if ((flags & DLVR_LOCAL) && local_rcpt_list) {
    1.30 +			msg_out *local_msgout = clone_msg_out(msgout);
    1.31 +			local_msgout->rcpt_list = local_rcpt_list;
    1.32 +			local_msgout_list = g_list_append(local_msgout_list, local_msgout);
    1.33  		}
    1.34  
    1.35 -		g_list_free(rcpt_list);
    1.36 -
    1.37  		/* local net recipients */
    1.38 -		rcpt_list = other_rcpt_list;
    1.39 -		other_rcpt_list = NULL;
    1.40 -		rcptlist_with_one_of_hostlist(rcpt_list, conf.local_nets, &localnet_rcpt_list, &other_rcpt_list);
    1.41 -
    1.42 -		if (flags & DLVR_LAN) {
    1.43 -			if (localnet_rcpt_list != NULL) {
    1.44 -				msg_out *localnet_msgout = clone_msg_out(msgout);
    1.45 -				localnet_msgout->rcpt_list = localnet_rcpt_list;
    1.46 -				localnet_msgout_list = g_list_append(localnet_msgout_list, localnet_msgout);
    1.47 -			}
    1.48 +		if ((flags & DLVR_LAN) && localnet_rcpt_list) {
    1.49 +			msg_out *localnet_msgout = clone_msg_out(msgout);
    1.50 +			localnet_msgout->rcpt_list = localnet_rcpt_list;
    1.51 +			localnet_msgout_list = g_list_append(localnet_msgout_list, localnet_msgout);
    1.52  		}
    1.53  
    1.54 -		if (flags & DLVR_ONLINE) {
    1.55 -			/* the rest, this is online delivery */
    1.56 -			if (other_rcpt_list != NULL) {
    1.57 -				msg_out *other_msgout = clone_msg_out(msgout);
    1.58 -				other_msgout->rcpt_list = other_rcpt_list;
    1.59 -				other_msgout_list = g_list_append(other_msgout_list, other_msgout);
    1.60 -			}
    1.61 +		/* remote recipients (the rest), requires online delivery  */
    1.62 +		if ((flags & DLVR_ONLINE) && other_rcpt_list) {
    1.63 +			msg_out *other_msgout = clone_msg_out(msgout);
    1.64 +			other_msgout->rcpt_list = other_rcpt_list;
    1.65 +			other_msgout_list = g_list_append(other_msgout_list, other_msgout);
    1.66  		}
    1.67  	}
    1.68  
    1.69 @@ -730,7 +718,8 @@
    1.70  		destroy_table(alias_table);
    1.71  
    1.72  	/* actual delivery */
    1.73 -	if (local_msgout_list != NULL) {
    1.74 +
    1.75 +	if (local_msgout_list) {
    1.76  		DEBUG(5) debugf("local_msgout_list\n");
    1.77  		foreach(local_msgout_list, msgout_node) {
    1.78  			msg_out *msgout = (msg_out *) (msgout_node->data);
    1.79 @@ -740,7 +729,7 @@
    1.80  		destroy_msg_out_list(local_msgout_list);
    1.81  	}
    1.82  
    1.83 -	if (localnet_msgout_list != NULL) {
    1.84 +	if (localnet_msgout_list) {
    1.85  		GList *route_list = NULL;
    1.86  		GList *route_node;
    1.87  
    1.88 @@ -759,7 +748,7 @@
    1.89  		destroy_route_list(route_list);
    1.90  	}
    1.91  
    1.92 -	if (other_msgout_list != NULL) {
    1.93 +	if (other_msgout_list) {
    1.94  		DEBUG(5) debugf("other_msgout_list\n");
    1.95  		if (!deliver_msgout_list_online(other_msgout_list))
    1.96  			ok = FALSE;