> On 07/04/11 07:02, Simon Hobson wrote:
>> Nikolai Schupbach wrote:
>>> We are running 2.1-snapshot-201104210611 with Postfix 2.8.3
>> What OS, which version of MySQL ?
>>
>>> It appears that Postfix tries to re-use the same socket for the 
>>> smtpd_recipient_restrictions and smtpd_end_of_data_restrictions. 
>>> However it appears cbpolicyd closes this socket after the first 
>>> check or has some error. As a result we notice that there is about a 
>>> 1-2 second delay after the result of the DATA command while Postfix 
>>> times out and reconnects to cbpolicyd.
>> I don't know if it's related, or just a red herring, but I started 
>> what turned out to be a fairly long thread a while ago on a 
>> performance related issue. I'm running PostfixAdmin as well, so 
>> Postfix is also doing lots of lookups and was getting timeouts.
>>
>> http://lists.policyd.org/pipermail/users/2011-April/003324.html
>>
>> And the bit where I announced the solution (at least to the timeouts) 
>> - upgrading from Debian Lenny to Squeeze, and MySQL from 5.0 to 5.1 
>> made the problem go away.
>>
>> http://lists.policyd.org/pipermail/users/2011-April/003340.html
>>
> I'll go through the code but from what I saw this morning, this may be a
> pretty valid explanation for some issues with Policyd. If Policyd does
> close the connection after telnet'ing to it and doing a policy request,
> that would be confirmation.
>
> Not a trainsmash to fix tho.
>
> I'll check it out.

The attached patch supports pipelining for v2.1.x .

Can those who have had slow performance issues and possible postfix =>
policyd timeouts or socket errors please apply this and test.

# cd cbpolicyd-source-dir
# patch -p1 < cbpolicyd-v2.1.x-pipelining.patch

Thanks goes to Nikolai Schupbach for tracking this one down.

Regards
Nigel
diff --git a/cbpolicyd b/cbpolicyd
index cdd63d2..beaba88 100755
--- a/cbpolicyd
+++ b/cbpolicyd
@@ -388,12 +388,18 @@ sub process_request {
 	my $log = defined($self->{'config'}{'logging'}{'modules'});
 
 
-	# Found module
-	my $found;
-	
+	# How many times did we pipeline...
+	my $policyRequests = 0;
+
 	#
 	# Loop till we fill up the buffer
 	#
+
+	# Beginning label, we do pipelining ...
+CONN_READ:
+
+	# Found module, set to 1 if found, 0 if otherwize
+	my $found = 0;
 	
 	# Buffer
 	my $buf = "";
@@ -449,7 +455,6 @@ sub process_request {
 		return;
 	}
 
-
 	# Set protocol handler
 	$server->{'_protocol_handler'} = $found;
 
@@ -540,7 +545,10 @@ sub process_request {
 		return;
 	}
 
-	$self->log(LOG_DEBUG,"[CBPOLICYD] Got request, running modules...") if ($log);
+	# Increment counter
+	$policyRequests++;
+
+	$self->log(LOG_DEBUG,"[CBPOLICYD] Got request #$policyRequests (> 1 indicates pipelining)");
 
 	# Loop with modules
 	foreach my $module ( sort { $b->{'priority'} <=> $a->{'priority'} }  @{$self->{'modules'}} ) {
@@ -592,8 +600,10 @@ sub process_request {
 
 	# Grab and return response
 	my $response = $self->protocol_getresponse();
-
 	print($response);
+
+	# Carry on with pipelining?
+	goto CONN_READ;
 }
 
 

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Users mailing list
[email protected]
http://lists.policyd.org/mailman/listinfo/users

Reply via email to