5 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
} elsif ($follow_flag == "1"){
print "[$i] Scanning $tmp_url\n";
if ($thread_count < $thread_max) {
push @threads, threads->new(\&CLIENT_get_links_threads, $tmp_url, $i, "threads_links.txt");
$thread_count++;
} elsif ($thread_count == $thread_max){
print "\n&linktiefe_scanner_threads(): Max Threads reached: joining them!\n\n" if ($debug == "1");
foreach (@threads) { eval { $_->join; } && warn $@ if $@; };
$thread_count = "0";
} elsif ($#working_links == $link_count) {
print "\n&linktiefe_scanner_threads(): Last Link in Array - Threads: joining them!\n\n" if ($debug == "1");
foreach (@threads) { eval { $_->join; } && warn $@ if $@; };
}
# ...
# here do something with the links (spider / mirror )
# ...
} else {
QuoteHallo,
ich arbeite an einem spider und arbeite mit threads.Für x bis threads_max erstellt er einen thread und startet das scannen in &client_get_links_threads;
wenn max_threads erreicht wird, führt er jeweils join durch ...
wenn ich das script laufen lassen konsumierts soviel speicher das ein Out of Memory kommt.
was mache ich falsch?wie kann ich es verbessern, sodass keine memory leaks mehr auftreten?
MfG
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# wenn wir fremde links nicht folgen sollen
if ( ($follow_flag == "0") && ($is_same == "1") ) {
# tue hier nun was wenn wir nur hostgleiche sachen scannen sollen
print "[$i] Scanning $tmp_url\n";
if ($thread_count < $thread_max) {
push @threads, threads->new(\&CLIENT_get_links_threads, $tmp_url, $i, "threads_links.txt");
$thread_count++;
} elsif ($thread_count == $thread_max){
print "\n&linktiefe_scanner_threads(): Max Threads reached: joining them!\n\n" if ($debug == "1");
foreach (@threads) { eval { $_->join; } or warn $@ if $@; };
$thread_count = "0";
} elsif ($#working_links == $link_count) {
print "\n&linktiefe_scanner_threads(): Last Link in Array - Threads: joining them!\n\n" if ($debug == "1");
foreach (@threads) { eval { $_->join; } or warn $@ if $@; };
}
# ...
# here do something with the links (spider / mirror )
# ...
# wenn wir fremde links folgen sollen
} elsif ($follow_flag == "1"){
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
my ($url, $current_depth, $file) = @_;
my ($obj_spider, $html, @links, $link, $tid);
$obj_spider = Spider::Easyspider->new($config);
$html = $obj_spider->http_get($url);
@links = $obj_spider->get_links($html);
open(LINKS, ">>$file") or die "&CLIENT_get_links_threads: Cannot open $file to add links: $!\n";
flock(LINKS,LOCK_EX);
foreach $link (@links) {
print LINKS "$current_depth $link\n";
}
close LINKS or warn "&CLIENT_get_links_threads: Cannot close $file: $!\n";
flock(LINKS,LOCK_UN);
# speicher freigeben
undef $obj_spider;
undef @links;
undef $html;
return 1;
} # sub CLIENT_get_links_threads {}
5 Einträge, 1 Seite |