Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
d3a58e04
Commit
d3a58e04
authored
Sep 11, 2016
by
Dylan William Hardison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 1301951 - Fix Bugzilla::Bug memory leaks
parent
84ebf678
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
5 deletions
+35
-5
Bugzilla.pm
Bugzilla.pm
+1
-0
Attachment.pm
Bugzilla/Attachment.pm
+8
-1
Bug.pm
Bugzilla/Bug.pm
+20
-1
Comment.pm
Bugzilla/Comment.pm
+6
-3
No files found.
Bugzilla.pm
View file @
d3a58e04
...
@@ -686,6 +686,7 @@ sub _cleanup {
...
@@ -686,6 +686,7 @@ sub _cleanup {
my
$smtp
=
$cache
->
{
smtp
};
my
$smtp
=
$cache
->
{
smtp
};
$smtp
->
disconnect
if
$smtp
;
$smtp
->
disconnect
if
$smtp
;
clear_request_cache
();
clear_request_cache
();
Bugzilla::
Bug
->
CLEANUP
();
# These are both set by CGI.pm but need to be undone so that
# These are both set by CGI.pm but need to be undone so that
# Apache can actually shut down its children if it needs to.
# Apache can actually shut down its children if it needs to.
...
...
Bugzilla/Attachment.pm
View file @
d3a58e04
...
@@ -46,6 +46,7 @@ use Bugzilla::Hook;
...
@@ -46,6 +46,7 @@ use Bugzilla::Hook;
use
File::
Copy
;
use
File::
Copy
;
use
List::
Util
qw(max)
;
use
List::
Util
qw(max)
;
use
Scalar::
Util
qw(weaken isweak)
;
use
Storable
qw(dclone)
;
use
Storable
qw(dclone)
;
use
parent
qw(Bugzilla::Object)
;
use
parent
qw(Bugzilla::Object)
;
...
@@ -140,8 +141,14 @@ the bug object to which the attachment is attached
...
@@ -140,8 +141,14 @@ the bug object to which the attachment is attached
=cut
=cut
sub
bug
{
sub
bug
{
my
(
$self
)
=
@_
;
require
Bugzilla::
Bug
;
require
Bugzilla::
Bug
;
return
$_
[
0
]
->
{
bug
}
//
=
Bugzilla::
Bug
->
new
({
id
=>
$_
[
0
]
->
bug_id
,
cache
=>
1
});
return
$self
->
{
bug
}
if
defined
$self
->
{
bug
};
# note $bug exists as a strong reference to keep $self->{bug} defined until the end of this method
my
$bug
=
$self
->
{
bug
}
=
Bugzilla::
Bug
->
new
({
id
=>
$_
[
0
]
->
bug_id
,
cache
=>
1
});
weaken
(
$self
->
{
bug
})
unless
isweak
(
$self
->
{
bug
});
return
$bug
;
}
}
=over
=over
...
...
Bugzilla/Bug.pm
View file @
d3a58e04
...
@@ -34,7 +34,7 @@ use Bugzilla::BugUserLastVisit;
...
@@ -34,7 +34,7 @@ use Bugzilla::BugUserLastVisit;
use
List::
MoreUtils
qw(firstidx uniq part)
;
use
List::
MoreUtils
qw(firstidx uniq part)
;
use
List::
Util
qw(min max first)
;
use
List::
Util
qw(min max first)
;
use
Storable
qw(dclone)
;
use
Storable
qw(dclone)
;
use
Scalar::
Util
qw(blessed)
;
use
Scalar::
Util
qw(blessed
weaken
)
;
use
parent
qw(Bugzilla::Object Exporter)
;
use
parent
qw(Bugzilla::Object Exporter)
;
@
Bugzilla::Bug::
EXPORT
=
qw(
@
Bugzilla::Bug::
EXPORT
=
qw(
...
@@ -43,6 +43,9 @@ use parent qw(Bugzilla::Object Exporter);
...
@@ -43,6 +43,9 @@ use parent qw(Bugzilla::Object Exporter);
editable_bug_fields
editable_bug_fields
)
;
)
;
# This hash keeps a weak copy of every bug created.
my
%
CLEANUP
;
#####################################################################
#####################################################################
# Constants
# Constants
#####################################################################
#####################################################################
...
@@ -361,6 +364,9 @@ sub new {
...
@@ -361,6 +364,9 @@ sub new {
return
$error_self
;
return
$error_self
;
}
}
$CLEANUP
{
$self
->
id
}
=
$self
;
weaken
(
$CLEANUP
{
$self
->
id
});
return
$self
;
return
$self
;
}
}
...
@@ -375,6 +381,18 @@ sub object_cache_key {
...
@@ -375,6 +381,18 @@ sub object_cache_key {
return
$key
.
','
.
Bugzilla
->
user
->
id
;
return
$key
.
','
.
Bugzilla
->
user
->
id
;
}
}
# This is called by Bugzilla::_cleanup() at the end of requests in a persistent environment
# (such as mod_perl)
sub
CLEANUP
{
foreach
my
$bug
(
values
%
CLEANUP
)
{
# $bug will be undef if there are no other references to it.
next
unless
$bug
;
delete
$bug
->
{
depends_on_obj
};
delete
$bug
->
{
blocks_obj
};
}
%
CLEANUP
=
();
}
sub
check
{
sub
check
{
my
$class
=
shift
;
my
$class
=
shift
;
my
(
$param
,
$field
)
=
@_
;
my
(
$param
,
$field
)
=
@_
;
...
@@ -3696,6 +3714,7 @@ sub comments {
...
@@ -3696,6 +3714,7 @@ sub comments {
foreach
my
$comment
(
@
{
$self
->
{
'comments'
}
})
{
foreach
my
$comment
(
@
{
$self
->
{
'comments'
}
})
{
$comment
->
{
count
}
=
$count
++
;
$comment
->
{
count
}
=
$count
++
;
$comment
->
{
bug
}
=
$self
;
$comment
->
{
bug
}
=
$self
;
weaken
(
$comment
->
{
bug
});
# XXX - hack for MySQL. Convert [U+....] back into its Unicode
# XXX - hack for MySQL. Convert [U+....] back into its Unicode
# equivalent for characters above U+FFFF as MySQL older than 5.5.3
# equivalent for characters above U+FFFF as MySQL older than 5.5.3
# cannot store them, see Bugzilla::Comment::_check_thetext().
# cannot store them, see Bugzilla::Comment::_check_thetext().
...
...
Bugzilla/Comment.pm
View file @
d3a58e04
...
@@ -21,7 +21,7 @@ use Bugzilla::User;
...
@@ -21,7 +21,7 @@ use Bugzilla::User;
use
Bugzilla::
Util
;
use
Bugzilla::
Util
;
use
List::
Util
qw(first)
;
use
List::
Util
qw(first)
;
use
Scalar::
Util
qw(blessed)
;
use
Scalar::
Util
qw(blessed
weaken isweak
)
;
###############################
###############################
#### Initialization ####
#### Initialization ####
...
@@ -232,8 +232,11 @@ sub collapsed {
...
@@ -232,8 +232,11 @@ sub collapsed {
sub
bug
{
sub
bug
{
my
$self
=
shift
;
my
$self
=
shift
;
require
Bugzilla::
Bug
;
require
Bugzilla::
Bug
;
$self
->
{
bug
}
||=
new
Bugzilla::
Bug
(
$self
->
bug_id
);
return
$self
->
{
bug
};
# note $bug exists as a strong reference to keep $self->{bug} defined until the end of this method
my
$bug
=
$self
->
{
bug
}
||=
new
Bugzilla::
Bug
(
$self
->
bug_id
);
weaken
(
$self
->
{
bug
})
unless
isweak
(
$self
->
{
bug
});
return
$bug
;
}
}
sub
is_about_attachment
{
sub
is_about_attachment
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment