Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r21241: LJSUP-11354 (esn-process-sub leaks memor...

Committer: ailyin
LJSUP-11354 (esn-process-sub leaks memory after r89)
U   trunk/cgi-bin/LJ/Comment.pm
U   trunk/cgi-bin/LJ/Entry.pm
Modified: trunk/cgi-bin/LJ/Comment.pm
===================================================================
--- trunk/cgi-bin/LJ/Comment.pm	2012-02-24 08:49:22 UTC (rev 21240)
+++ trunk/cgi-bin/LJ/Comment.pm	2012-02-24 09:45:49 UTC (rev 21241)
@@ -50,12 +50,12 @@
 #    _loaded_props:  loaded props
 
 my %singletons    = (); # journalid->jtalkid->singleton
-my %unloaded      = (); # journalid->jtalkid->singleton
-my %unloaded_text = (); # journalid->jtalkid->singleton
-my %unloaded_prop = (); # journalid->jtalkid->singleton
+my %unloaded      = (); # journalid:jtalkid->singleton
+my %unloaded_text = (); # journalid:jtalkid->singleton
+my %unloaded_prop = (); # journalid:jtalkid->singleton
 
 sub reset_singletons {
-    %singletons = ();
+    %singletons = %unloaded = %unloaded_text = %unloaded_prop = ();
 }
 
 # <LJFUNC>
@@ -1012,23 +1012,25 @@
     return LJ::Talk::Post::blockquote(@_);
 }
 
-sub start_thread_url {
-    my $self    = shift;
+sub thread_start {
+    my ($self) = @_;
 
-    my $dtalkid = $self->dtalkid;
-    my $entry   = $self->entry;
-    my $url     = $entry->url;
+    return $self unless $self->parenttalkid;
 
-    # get all comments to post, makes singletons of many LJ::Comment objects
-    my $comments = LJ::Talk::get_talk_data($self->journal, 'L', $entry->jitemid) || {};
+    my $memkey = join( ':', 'talk_thread_start', $self->journalid, $self->jtalkid );
+    my $thread_start_jtalkid = LJ::MemCache::get_or_set( $memkey, sub {
+        return $self->parent->thread_start->jtalkid;
+    } );
 
-    my $start = $self;
-    while ($start->parent) {
-        $start = $start->parent;
-    }
-    return $start->url;
+    return LJ::Comment->new( $self->journalid, 'jtalkid' => $thread_start_jtalkid );
 }
 
+sub start_thread_url {
+    my ($self) = @_;
+
+    return $self->thread_start->url;
+}
+
 # used for comment email notification headers
 sub email_messageid {
     my $self = shift;

Modified: trunk/cgi-bin/LJ/Entry.pm
===================================================================
--- trunk/cgi-bin/LJ/Entry.pm	2012-02-24 08:49:22 UTC (rev 21240)
+++ trunk/cgi-bin/LJ/Entry.pm	2012-02-24 09:45:49 UTC (rev 21241)
@@ -35,9 +35,11 @@
 #    _loaded_comments: loaded comments
 
 my %singletons = (); # journalid->jitemid->singleton
+my %loaded_comments = (); # journalid->jitemid->[comment, comment, ...]
 
 sub reset_singletons {
     %singletons = ();
+    %loaded_comments = ();
 }
 
 # <LJFUNC>
@@ -527,13 +529,13 @@
 sub comment_list {
     my $self = shift;
     $self->_load_comments unless $self->{_loaded_comments};
-    return @{$self->{comments} || []};
+    return @{ $loaded_comments{ $self->journalid }->{ $self->jitemid } || [] };
 }
 
 sub set_comment_list {
     my $self = shift;
 
-    $self->{comments} = \@_;
+    $loaded_comments{ $self->journalid }->{ $self->jitemid } = \@_;
     $self->{_loaded_comments} = 1;
 
     return 1;

Tags: ailyin, andy, livejournal, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments