[pkg-kolab] r950 - libkolab-perl/trunk/debian/patches
mparent-guest at alioth.debian.org
mparent-guest at alioth.debian.org
Tue Oct 14 17:13:59 UTC 2008
Author: mparent-guest
Date: 2008-10-14 17:13:58 +0000 (Tue, 14 Oct 2008)
New Revision: 950
Modified:
libkolab-perl/trunk/debian/patches/51-syncrepl.dpatch
Log:
Current syncrepl patch
Modified: libkolab-perl/trunk/debian/patches/51-syncrepl.dpatch
===================================================================
--- libkolab-perl/trunk/debian/patches/51-syncrepl.dpatch 2008-10-05 12:01:10 UTC (rev 949)
+++ libkolab-perl/trunk/debian/patches/51-syncrepl.dpatch 2008-10-14 17:13:58 UTC (rev 950)
@@ -1,11 +1,12 @@
---- /root/syncrepl.pm.orig 2008-10-01 18:56:40.000000000 +0000
-+++ /usr/share/perl5/Kolab/LDAP/Backend/syncrepl.pm 2008-10-04 12:40:34.000000000 +0000
-@@ -21,8 +21,12 @@
+--- syncrepl.pm.orig 2008-10-01 18:56:40.000000000 +0000
++++ syncrepl.pm 2008-10-14 17:11:25.000000000 +0000
+@@ -21,8 +21,13 @@
use warnings;
use Kolab;
use Kolab::LDAP;
-use Net::LDAP;
+use Net::LDAP qw(
++ LDAP_USER_CANCELED
+ LDAP_SYNC_REFRESH_ONLY
+ LDAP_SYNC_REFRESH_AND_PERSIST
+);
@@ -14,7 +15,7 @@
use Net::LDAP::Entry;
use vars qw($ldap $cookie $disconnected);
my $cookie = '';
-@@ -45,96 +49,7 @@
+@@ -45,97 +50,13 @@
);
@@ -83,12 +84,16 @@
- entryUUID syncUUID,
- cookie syncCookie OPTIONAL
-}
--
++our $VERSION = '0.2';
+
-syncDoneValue ::= SEQUENCE {
- cookie syncCookie OPTIONAL,
- refreshDeletes BOOLEAN -- DEFAULT FALSE
--}
--
++sub mode {
++ LDAP_SYNC_REFRESH_ONLY;
++ #LDAP_SYNC_REFRESH_AND_PERSIST;
+ }
+
-syncInfoValue ::= CHOICE {
- newcookie [0] syncCookie,
- refreshDelete [1] SEQUENCE {
@@ -108,11 +113,11 @@
-
-LDAP_ASN
-
-+our $VERSION = '0.2';
-
+-
sub startup { 1; }
-@@ -184,22 +99,17 @@
+ sub shutdown
+@@ -184,22 +105,17 @@
Kolab::LDAP::ensureAsync($ldap);
Kolab::log('SYNCREPL', 'Async checked', KOLAB_DEBUG);
@@ -133,7 +138,7 @@
- #search
- my $mesg = $ldap->search(base => $Kolab::config{'base_dn'},
+ my $ctrl = Net::LDAP::Control::SyncRequest->new(
-+ mode => LDAP_SYNC_REFRESH_ONLY,
++ mode => Kolab::LDAP::Backend::syncrepl::mode,
+ cookie => $cookie,
+ reloadHint => 0);
+ Kolab::log('SYNCREPL', 'Control created: mode='.$ctrl->mode().
@@ -145,7 +150,7 @@
scope => 'sub',
control => [ $ctrl ],
callback => \&searchCallback, # call for each entry
-@@ -210,7 +120,7 @@
+@@ -210,7 +126,7 @@
$Kolab::config{'user_field_quota'},
$Kolab::config{'user_field_deleted'},
],
@@ -154,28 +159,32 @@
Kolab::log('SYNCREPL', 'Search created', KOLAB_DEBUG);
$mesg->sync;
Kolab::log('SYNCREPL', "Finished Net::LDAP::Search::sync sleeping 10s", KOLAB_DEBUG);
-@@ -223,7 +133,7 @@
+@@ -223,37 +139,53 @@
#search callback
sub searchCallback {
my $mesg = shift;
- my $entry = shift;
+- my $issearch = $mesg->isa("Net::LDAP::Search");
+ my $param2 = shift; # might be entry or intermediate
- my $issearch = $mesg->isa("Net::LDAP::Search");
my @controls = $mesg->control;
- if(not $issearch) {
-@@ -235,6 +145,8 @@
- Kolab::log('SYNCREPL', "Not a search: mesg->code = `" . $mesg->code . "', mesg->msg = `" . $mesg->error . "'", KOLAB_DEBUG);
- &abort;
- }
-+ } elsif($param2 && $param2->isa("Net::LDAP::Intermediate")) {
-+ Kolab::log('SYNCREPL', 'Received Intermediate Message', KOLAB_DEBUG);
- } elsif(@controls == 0) {
- if ($mesg->code == 1) {
- Kolab::log('SYNCREPL', 'No control: Communications Error: disconnecting', KOLAB_DEBUG);
-@@ -244,16 +156,21 @@
- Kolab::log('SYNCREPL', "No control: mesg->code = `" . $mesg->code . "', mesg->msg = `" . $mesg->error . "'", KOLAB_DEBUG);
- &abort;
- }
+- if(not $issearch) {
+- Kolab::log('SYNCREPL', 'mesg is not a search object, testing code...', KOLAB_DEBUG);
+- if ($mesg->code == 88) {
+- Kolab::log('SYNCREPL', 'searchCallback() -> Exit code received, returning', KOLAB_DEBUG);
+- return;
+- } elsif ($mesg->code) {
+- Kolab::log('SYNCREPL', "Not a search: mesg->code = `" . $mesg->code . "', mesg->msg = `" . $mesg->error . "'", KOLAB_DEBUG);
+- &abort;
+- }
+- } elsif(@controls == 0) {
+- if ($mesg->code == 1) {
+- Kolab::log('SYNCREPL', 'No control: Communications Error: disconnecting', KOLAB_DEBUG);
+- $disconnected = 1;
+- return;
+- } elsif ($mesg->code) {
+- Kolab::log('SYNCREPL', "No control: mesg->code = `" . $mesg->code . "', mesg->msg = `" . $mesg->error . "'", KOLAB_DEBUG);
+- &abort;
+- }
- } elsif($controls[0]->type eq LDAP_CONTROL_SYNC_STATE) {
- Kolab::log('SYNCREPL', 'Received Sync State Control', KOLAB_DEBUG);
- Kolab::log('SYNCREPL', "Entry (".$entry->changetype."): ".$entry->dn(), KOLAB_DEBUG);
@@ -183,14 +192,44 @@
- Kolab::log('SYNCREPL', 'Received Sync Done Control', KOLAB_DEBUG);
- my $asn_syncDoneValue = $asn->find('syncDoneValue');
- my $out = $asn_syncDoneValue->decode($controls[0]->value);
-+ } elsif($controls[0]->isa('Net::LDAP::Control::SyncState')) {
-+ Kolab::log('SYNCREPL', 'Received Sync State Control: '.
-+ 'state='.$controls[0]->state().
-+ '; entryUUID='.unpack("H*",$controls[0]->entryUUID()).
-+ '; cookie='.(defined($controls[0]->cookie()) ? $controls[0]->cookie() : 'UNDEF')
++ my @sync_controls = ();
++ if($param2 && $param2->isa("Net::LDAP::Entry")) {
++ Kolab::log('SYNCREPL', 'Received Search Entry', KOLAB_DEBUG);
++ #retrieve Sync State Control
++ foreach my $ctrl (@controls) {
++ push(@sync_controls, $ctrl)
++ if $ctrl->isa('Net::LDAP::Control::SyncState');
++ }
++ if(@sync_controls>1) {
++ Kolab::log('SYNCREPL', 'Got search entry with multiple Sync State controls',
++ KOLAB_DEBUG);
++ return;
++ }
++ if(!@sync_controls) {
++ Kolab::log('SYNCREPL', 'Got search entry without Sync State control',
++ KOLAB_DEBUG);
++ return;
++ }
++ if(!$sync_controls[0]->entryUUID) {
++ Kolab::log('SYNCREPL', 'Got empty entryUUID',
++ KOLAB_DEBUG);
++ return;
++ }
++ Kolab::log('SYNCREPL', 'Search Entry has Sync State Control: '.
++ 'state='.$sync_controls[0]->state().
++ '; entryUUID='.unpack("H*",$sync_controls[0]->entryUUID()).
++ '; cookie='.(defined($sync_controls[0]->cookie()) ? $sync_controls[0]->cookie() : 'UNDEF')
+ , KOLAB_DEBUG);
++ if(defined($sync_controls[0]->cookie)) {
++ $cookie = $sync_controls[0]->cookie;
++ Kolab::log('SYNCREPL',"New cookie: $cookie", KOLAB_DEBUG);
++ }
+ Kolab::log('SYNCREPL', "Entry (".$param2->changetype."): ".$param2->dn(), KOLAB_DEBUG);
-+ } elsif($controls[0]->isa('Net::LDAP::Control::SyncDone')) {
++ } elsif($param2 && $param2->isa("Net::LDAP::Reference")) {
++ Kolab::log('SYNCREPL', 'Received Search Reference', KOLAB_DEBUG);
++ return;
++ #if it not first control?
++ } elsif($controls[0] and $controls[0]->isa('Net::LDAP::Control::SyncDone')) {
+ Kolab::log('SYNCREPL', 'Received Sync Done Control: '.
+ 'cookie='.(defined($controls[0]->cookie()) ? $controls[0]->cookie() : 'UNDEF').
+ '; refreshDeletes='.$controls[0]->refreshDeletes()
@@ -203,3 +242,49 @@
Kolab::log('SYNCREPL', "New cookie: $cookie", KOLAB_DEBUG);
Kolab::log('SYNCREPL', "Calling Kolab::LDAP::sync", KOLAB_DEBUG);
Kolab::LDAP::sync;
+@@ -261,8 +193,44 @@
+ Kolab::log('SYNCREPL', "Finished Kolab::LDAP::sync sleeping 1s", KOLAB_DEBUG);
+ sleep 1; # we get too many bogus change notifications!
+ }
++ } elsif($param2 && $param2->isa("Net::LDAP::Intermediate")) {
++ Kolab::log('SYNCREPL', 'Received Intermediate Message', KOLAB_DEBUG);
++ my $attrs = $param2->{asn};
++ if($attrs->{newcookie}) {
++ $cookie = $attrs->{newcookie};
++ Kolab::log('SYNCREPL', "New cookie: $cookie", KOLAB_DEBUG);
++ } elsif(my $refreshInfos = ($attrs->{refreshDelete} || $attrs->{refreshPresent})) {
++ $cookie = $refreshInfos->{cookie} if defined($refreshInfos->{cookie});
++ Kolab::log('SYNCREPL',
++ (defined($refreshInfos->{cookie}) ? 'New ' : 'Empty ').
++ "cookie from ".
++ ($attrs->{refreshDelete} ? 'refreshDelete' : 'refreshPresent').
++ " (refreshDone=".$refreshInfos->{refreshDone}."): $cookie", KOLAB_DEBUG);
++ } elsif(my $syncIdSetInfos = $attrs->{syncIdSet}) {
++ $cookie = $syncIdSetInfos->{cookie} if defined($syncIdSetInfos->{cookie});
++ Kolab::log('SYNCREPL',
++ (defined($syncIdSetInfos->{cookie}) ? 'Empty ' : 'New ').
++ "cookie from syncIdSet".
++ " (refreshDeletes=".$syncIdSetInfos->{refreshDeletes}."): $cookie", KOLAB_DEBUG);
++ foreach my $syncUUID ($syncIdSetInfos->{syncUUIDs}) {
++ Kolab::log('SYNCREPL', 'entryUUID='.
++ unpack("H*",$syncUUID), KOLAB_DEBUG);
++ }
++ }
++ } elsif($mesg->code) {
++ if ($mesg->code == 1) {
++ Kolab::log('SYNCREPL', 'Communication Error: disconnecting', KOLAB_DEBUG);
++ $disconnected = 1;
++ return 0;
++ } elsif ($mesg->code == LDAP_USER_CANCELED) {
++ Kolab::log('SYNCREPL', 'searchCallback() -> Exit code received, returning', KOLAB_DEBUG);
++ return;
++ } else {
++ Kolab::log('SYNCREPL', "searchCallback: mesg->code = `" . $mesg->code . "', mesg->msg = `" . $mesg->error . "'", KOLAB_DEBUG);
++ &abort;
++ }
+ } else {
+- Kolab::log('SYNCREPL', 'Received unknown control: '.$controls[0]->type, KOLAB_DEBUG);
++ Kolab::log('SYNCREPL', 'Received something else', KOLAB_DEBUG);
+ }
+ return 0;
+ }
More information about the pkg-kolab-devel
mailing list