Diff for /loncom/lond between versions 1.511 and 1.512

version 1.511, 2014/06/29 03:22:43 version 1.512, 2014/11/24 02:36:16
Line 3322  sub dump_with_regexp { Line 3322  sub dump_with_regexp {
 #                          namespace   - Name of the database being modified  #                          namespace   - Name of the database being modified
 #                          rid         - Resource keyword to modify.  #                          rid         - Resource keyword to modify.
 #                          what        - new value associated with rid.  #                          what        - new value associated with rid.
   #                          laststore   - (optional) version=timestamp
   #                                        for most recent transaction for rid
   #                                        in namespace, when cstore was called
 #  #
 #    $client             - Socket open on the client.  #    $client             - Socket open on the client.
 #  #
Line 3330  sub dump_with_regexp { Line 3333  sub dump_with_regexp {
 #      1 (keep on processing).  #      1 (keep on processing).
 #  Side-Effects:  #  Side-Effects:
 #    Writes to the client  #    Writes to the client
   #    Successful storage will cause either 'ok', or, if $laststore was included
   #    in the tail of the request, and the version number for the last transaction
   #    is larger than the version in $laststore, delay:$numtrans , where $numtrans
   #    is the number of store evevnts recorded for rid in namespace since
   #    lonnet::store() was called by the client.
   #
 sub store_handler {  sub store_handler {
     my ($cmd, $tail, $client) = @_;      my ($cmd, $tail, $client) = @_;
     
     my $userinput = "$cmd:$tail";      my $userinput = "$cmd:$tail";
       chomp($tail);
     my ($udom,$uname,$namespace,$rid,$what) =split(/:/,$tail);      my ($udom,$uname,$namespace,$rid,$what,$laststore) =split(/:/,$tail);
     if ($namespace ne 'roles') {      if ($namespace ne 'roles') {
   
  chomp($what);  
  my @pairs=split(/\&/,$what);   my @pairs=split(/\&/,$what);
  my $hashref  = &tie_user_hash($udom, $uname, $namespace,   my $hashref  = &tie_user_hash($udom, $uname, $namespace,
        &GDBM_WRCREAT(), "S",         &GDBM_WRCREAT(), "S",
        "$rid:$what");         "$rid:$what");
  if ($hashref) {   if ($hashref) {
     my $now = time;      my $now = time;
     my @previouskeys=split(/&/,$hashref->{"keys:$rid"});              my $numtrans;
     my $key;              if ($laststore) {
                   my ($previousversion,$previoustime) = split(/\=/,$laststore);
                   my ($lastversion,$lasttime) = (0,0);
                   $lastversion = $hashref->{"version:$rid"};
                   if ($lastversion) {
                       $lasttime = $hashref->{"$lastversion:$rid:timestamp"};
                   }
                   if (($previousversion) && ($previousversion !~ /\D/)) {
                       if (($lastversion > $previousversion) && ($lasttime >= $previoustime)) {
                           $numtrans = $lastversion - $previousversion;
                       }
                   } elsif ($lastversion) {
                       $numtrans = $lastversion;
                   }
                   if ($numtrans) {
                       $numtrans =~ s/D//g;
                   }
               }
     $hashref->{"version:$rid"}++;      $hashref->{"version:$rid"}++;
     my $version=$hashref->{"version:$rid"};      my $version=$hashref->{"version:$rid"};
     my $allkeys='';       my $allkeys=''; 
Line 3359  sub store_handler { Line 3384  sub store_handler {
     $allkeys.='timestamp';      $allkeys.='timestamp';
     $hashref->{"$version:keys:$rid"}=$allkeys;      $hashref->{"$version:keys:$rid"}=$allkeys;
     if (&untie_user_hash($hashref)) {      if (&untie_user_hash($hashref)) {
  &Reply($client, "ok\n", $userinput);                  my $msg = 'ok';
                   if ($numtrans) {
                       $msg = 'delay:'.$numtrans;
                   }
    &Reply($client, "$msg\n", $userinput);
     } else {      } else {
  &Failure($client, "error: ".($!+0)." untie(GDBM) Failed ".   &Failure($client, "error: ".($!+0)." untie(GDBM) Failed ".
  "while attempting store\n", $userinput);   "while attempting store\n", $userinput);

Removed from v.1.511  
changed lines
  Added in v.1.512


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>