Branch Coverage

blib/lib/Net/Clacks/Server.pm
Criterion Covered Total %
branch 0 418 0.0


line true false branch
89 0 0 if (defined $ENV{'CLACKS_SIMULATED_TIME_OFFSET'})
107 0 0 unless (defined $self->{'initHasRun'} and $self->{'initHasRun'})
125 0 0 if ($self->{'persistance'})
133 0 0 if ($self->{'shutdowntime'} and $self->{'shutdowntime'} < &Net::Clacks::Server::time())
139 0 0 if ($self->{'savecache'} and $now > $self->{'lastsavecache'} + $self->{'persistanceinterval'})
146 0 0 if (defined $self->{'config'}{'master'}{'socket'} or defined $self->{'config'}{'master'}{'ip'})
154 0 0 unless (scalar keys %{$$self{"clients"};})
168 0 0 if ($buf eq "\r") { }
0 0 elsif ($buf eq "\n") { }
171 0 0 if $self->{'clients'}{$cid}{'buffer'} eq ""
184 0 0 if ($self->{'interclackslock'} and not $self->{'clients'}{$cid}{'interclacksclient'})
192 0 0 if $self->{'clients'}{$cid}{'inmessages'}[0]{'releasetime'} > $now
197 0 0 if ($inmsg =~ /^CLACKS\ (.+)/u)
211 0 0 unless ($self->{'clients'}{$cid}{'authok'})
215 0 0 unless ($self->{'nodebug'})
226 0 0 if ($self->{'discardafterlogging'})
232 0 0 if ($inmsg =~ /^OVERHEAD\ /u) { }
0 0 elsif ($self->_handleMessageDirect($cid, $inmsg)) { }
0 0 elsif ($self->_handleMessageCaching($cid, $inmsg)) { }
0 0 elsif ($self->_handleMessageControl($cid, $inmsg)) { }
249 0 0 if ($self->{'sendinterclacks'})
251 0 0 if ($cid eq $interclackscid or not $self->{'clients'}{$interclackscid}{'interclacks'})
263 0 0 if ($self->{'nextcachecleanup'} < $now)
272 0 0 if ($self->{'workCount'}) { }
0 0 elsif ($self->{'usleep'} < $self->{'config'}{'throttle'}{'maxsleep'}) { }
277 0 0 if ($self->{'usleep'})
301 0 0 unless ($self->{'persistance'})
309 0 0 if ($self->{'savecache'} == 1)
318 0 0 if ($self->{'savecache'} == 2)
327 0 0 unless defined $val
331 0 0 unless defined $val
338 0 0 unless length $buffer
346 0 0 if ($Net::Clacks::Server::EVAL_ERROR or not $ok)
364 0 0 unless open my $fh, "<", $fname
377 0 0 unless open my $fh, ">", $fname
390 0 0 if (-f $self->{'config'}{'persistancefile'})
395 0 0 if (not $loadok and -f $previousfname)
398 0 0 if ($loadok)
402 0 0 if (not $loadok and -f $tempfname)
405 0 0 if ($loadok)
410 0 0 if (not $loadok) { }
421 0 0 if (defined $self->{'initHasRun'} and $self->{'initHasRun'})
427 0 0 if (defined $ENV{'PC_CONFIG_PATHS'}) { }
438 0 0 if ($path ne "" and not $path =~ m[/$]u)
442 0 0 unless -f $fullfname
448 0 0 unless $varname =~ /^PC\_/u
457 0 0 if (not defined $filedata or $filedata eq "")
467 0 0 if (defined $config->{'hosts'}{$hname})
475 0 0 unless (defined $self->{'config'}{'throttle'}{'maxsleep'})
478 0 0 unless (defined $self->{'config'}{'throttle'}{'step'})
484 0 0 unless (defined $self->{'config'}{'ssl'} and defined $self->{'config'}{'ssl'}{'cert'} and defined $self->{'config'}{'ssl'}{'key'})
489 0 0 unless (-f $self->{'config'}{'ssl'}{'cert'})
492 0 0 unless (-f $self->{'config'}{'ssl'}{'key'})
496 0 0 unless (defined $self->{'config'}{'username'})
499 0 0 unless (defined $self->{'config'}{'password'})
504 0 0 if (defined $self->{'config'}{'persistancefile'}) { }
510 0 0 if (not defined $self->{'config'}{'persistanceinterval'}) { }
516 0 0 unless (defined $self->{'config'}{'interclacksreconnecttimeout'})
520 0 0 unless (defined $self->{'config'}{'authtimeout'})
524 0 0 unless (defined $self->{'config'}{'deletedcachetime'})
527 0 0 unless (defined $self->{'config'}{'stalecachetime'})
531 0 0 unless (defined $self->{'config'}{'cachecleaninterval'})
551 0 0 if (defined $config->{'ip'})
552 0 0 unless (defined $config->{'port'})
559 0 0 unless my $tcp = "IO::Socket::IP"->new("LocalHost", $ip, "LocalPort", $config->{'port'}, "Listen", 1, "Blocking", 0, "ReuseAddr", 1, "Proto", "tcp")
570 0 0 if (defined $config->{'socket'} or defined $self->{'config'}{'master'}{'socket'})
576 0 0 unless ($udsloaded)
599 0 0 if (defined $config->{'socket'})
601 0 0 if (-S $socket)
605 0 0 unless my $tcp = "IO::Socket::UNIX"->new("Type", 1, "Local", $socket, "Listen", 1)
616 0 0 if (defined $config->{'socketchmod'} and $config->{'socketchmod'} ne "")
637 0 0 unless (-f $fname)
644 0 0 if (length $data < 11)
649 0 0 if (substr($data, 0, 9) ne "\0CLACKSV3")
650 0 0 if ($alreadyupgraded)
656 0 0 unless ($self->_inplaceUpgrade($fname))
664 0 0 if (length $data < 18)
671 0 0 if (substr($data, -9, 9) ne "\0CLACKSV3")
679 0 0 if (length $data)
685 0 0 unless ($loadok)
704 0 0 if (open my $ifh, '<', $fname) { }
716 0 0 if (not defined $endline and $accesstimeline eq 'ENDBYTES') { }
724 0 0 if (not defined $line && defined $timestampline or $endline ne "ENDBYTES")
731 0 0 if ($line ne "")
737 0 0 unless ($loadok)
749 0 0 if ($timestampline ne "")
756 0 0 if (not $loadok) { }
767 0 0 if ($needupgrade) { }
0 0 elsif ($accesstimeline ne '') { }
779 0 0 if (not $loadok) { }
797 0 0 if (defined $clackscachetime{$key})
800 0 0 if (defined $clackscacheaccesstime{$key})
813 0 0 if (defined $cache{$key})
820 0 0 if (defined $clackscacheaccesstime{$key})
843 0 0 if (defined $self->{'config'}{'master'}{'socket'}) { }
848 0 0 if (not defined $self->{'clients'}{$mcid} and $self->{'nextinterclackscheck'} < $now)
854 0 0 if (defined $self->{'config'}{'master'}{'socket'}) { }
867 0 0 if (not defined $msocket) { }
872 0 0 if (ref $msocket ne "IO::Socket::UNIX")
878 0 0 unless ($encrypted)
912 0 0 if (defined $self->{'config'}{'master'}{'ip'})
930 0 0 if (defined $clientsocket)
933 0 0 if (ref $tcpsocket eq 'IO::Socket::UNIX') { }
942 0 0 if ($self->{'clients'}{$debugcid}{'mirror'})
947 0 0 if (ref $clientsocket ne "IO::Socket::UNIX")
968 0 0 unless ($encrypted)
1024 0 0 unless ($self->{'clients'}{$cid}{'socket'}->connected)
1028 0 0 if (not $self->{'clients'}{$cid}{'interclacks'}) { }
1029 0 0 if ($self->{'clients'}{$cid}{'lastping'} > 0 and $self->{'clients'}{$cid}{'lastping'} < $pingtime)
1035 0 0 if ($self->{'clients'}{$cid}{'lastping'} < $interclackspingtime)
1042 0 0 if ($self->{'clients'}{$cid}{'interclacks'} and $self->{'clients'}{$cid}{'lastinterclacksping'} < $interclackspinginterval)
1047 0 0 if (not $self->{'clients'}{$cid}{'authok'} and $self->{'clients'}{$cid}{'authtimeout'} < $now)
1054 0 0 if (scalar @{$self->{'toremove'};})
1061 0 0 if contains($cid, \@flushed)
1063 0 0 unless length $self->{'clients'}{$cid}{'outbuffer'}
1073 0 0 if (defined $self->{'clients'}{$cid})
1076 0 0 if ($self->{'clients'}{$debugcid}{'mirror'})
1078 0 0 if ($self->{'clients'}{$cid}{'interclacksclient'} and $self->{'interclackslock'})
1084 0 0 if ($self->{'clients'}{$cid}{'interclacksclient'} and $self->{'interclackslock'})
1105 0 0 if (length $self->{'clients'}{$cid}{'buffer'} > 0)
1112 0 0 if ($hasoutbufferwork)
1129 0 0 unless ($readok)
1133 0 0 if (defined $rawbuffer and length $rawbuffer)
1137 0 0 unless ($readchunksleft)
1148 0 0 if ($totalread) { }
1153 0 0 if ($self->{'clients'}{$cid}{'failcount'} > 5)
1170 0 0 if ($forceclientid ne "" and $forceclientid ne $cid)
1173 0 0 if ($cid ne $forceclientid and contains($cid, $self->{'toremove'}))
1176 0 0 if (length $self->{'clients'}{$cid}{'outbuffer'}) { }
0 0 elsif ($self->{'clients'}{$cid}{'lastmessage'} + 60 < $now) { }
1184 0 0 unless length $self->{'clients'}{$cid}{'outbuffer'}
1192 0 0 if ($Net::Clacks::Server::EVAL_ERROR)
1197 0 0 if (not $self->{'clients'}{$cid}{'socket'}->opened or $self->{'clients'}{$cid}{'socket'}->error or $Net::Clacks::Server::ERRNO ne "" and not $Net::Clacks::Server::ERRNO{'EWOULDBLOCK'})
1203 0 0 if (defined $written and $written)
1204 0 0 if (length $self->{'clients'}{$cid}{'outbuffer'} == $written) { }
1222 0 0 if ($self->{'cache'}{$ckey}{'deleted'} and $self->{'cache'}{$ckey}{'cachetime'} < $deletedtime)
1238 0 0 if (not $self->{'cache'}{$ckey}{'deleted'} and $self->{'cache'}{$ckey}{'accesstime'} < $staletime)
1264 0 0 if ($line->{'type'} eq "DEBUG" and $self->{'clients'}{$cid}{'mirror'})
1268 0 0 if ($cid eq $line->{'sender'})
1272 0 0 if ($line->{'type'} ne "DEBUG" and defined $self->{'clients'}{$cid}{'listening'}{$line->{'name'}})
1274 0 0 if ($line->{'type'} eq 'NOTIFY') { }
0 0 elsif ($line->{'type'} eq 'SET') { }
0 0 elsif ($line->{'type'} eq 'SETANDSTORE') { }
1281 0 0 if ($self->{'clients'}{$cid}{'interclacks'}) { }
1295 0 0 if $self->{'clients'}{$cid}{'outmessages'}[0]{'releasetime'} > $now
1298 0 0 if ($outmsg->{'message'} eq 'EXIT') { }
1312 0 0 if ($inmsg =~ /^OVERHEAD\ (.+?)\ (.+)/u)
1319 0 0 if (contains($key, \@flagparts)) { }
1328 0 0 if ($parsedflags{'auth_token'})
1329 0 0 if ($value eq $self->{'authtoken'}) { }
1345 0 0 unless ($self->{'clients'}{$cid}{'authok'})
1349 0 0 if ($parsedflags{'timestamp'})
1356 0 0 if ($parsedflags{'lock_for_sync'} and $self->{'clients'}{$cid}{'interclacksclient'})
1357 0 0 if ($value) { }
1370 0 0 unless (defined $self->{'cache'}{$ckey}{'cachetime'} and &looks_like_number($self->{'cache'}{$ckey}{'cachetime'}))
1373 0 0 unless (defined $self->{'cache'}{$ckey}{'accesstime'} and &looks_like_number($self->{'cache'}{$ckey}{'accesstime'}))
1376 0 0 unless (defined $self->{'cache'}{$ckey}{'deleted'} and $self->{'cache'}{$ckey}{'deleted'})
1379 0 0 unless (defined $self->{'cache'}{$ckey}{'data'})
1384 0 0 if (not $self->{'cache'}{$ckey}{'deleted'}) { }
1395 0 0 if ($parsedflags{'close_all_connections'} and $value)
1397 0 0 if ($self->{'clients'}{$closecid}{'interclacks'} and $parsedflags{'forward_message'})
1406 0 0 if ($parsedflags{'shutdown_service'})
1408 0 0 if ($value > 0)
1413 0 0 if ($parsedflags{'discard_message'})
1416 0 0 if ($parsedflags{'no_logging'})
1420 0 0 if ($parsedflags{'error_message'})
1424 0 0 if ($parsedflags{'set_interclacks_mode'})
1428 0 0 if ($value) { }
1445 0 0 unless (defined $self->{'cache'}{$ckey}{'cachetime'} and &looks_like_number($self->{'cache'}{$ckey}{'cachetime'}))
1448 0 0 unless (defined $self->{'cache'}{$ckey}{'accesstime'} and &looks_like_number($self->{'cache'}{$ckey}{'accesstime'}))
1451 0 0 unless (defined $self->{'cache'}{$ckey}{'deleted'} and $self->{'cache'}{$ckey}{'deleted'})
1454 0 0 unless (defined $self->{'cache'}{$ckey}{'data'})
1459 0 0 if (not $self->{'cache'}{$ckey}{'deleted'}) { }
1478 0 0 if $key eq "Z"
1479 0 0 if ($newflags{$overheadflags{$key}})
1483 0 0 if ($newflagstring eq "")
1487 0 0 if ($parsedflags{'forward_message'})
1489 0 0 if $cid eq $overheadcid and not $parsedflags{'return_to_sender'}
1504 0 0 if ($inmsg =~ /^KEYSYNC\ (.+?)\ (.+?)\ (.+?)\ (.+?)\=(.*)/u) { }
0 0 elsif ($inmsg =~ /^STORE\ (.+?)\=(.*)/u) { }
0 0 elsif ($inmsg =~ /^SETANDSTORE\ (.+?)\=(.*)/u) { }
0 0 elsif ($inmsg =~ /^RETRIEVE\ (.+)/u) { }
0 0 elsif ($inmsg =~ /^REMOVE\ (.+)/u) { }
0 0 elsif ($inmsg =~ /^INCREMENT\ (.+)/u) { }
0 0 elsif ($inmsg =~ /^DECREMENT\ (.+)/u) { }
0 0 elsif ($inmsg =~ /^KEYLIST/u) { }
0 0 elsif ($inmsg =~ /^CLEARCACHE/u) { }
1510 0 0 if ($atimestamp)
1514 0 0 if (not defined $self->{'cache'}{$ckey} or $ctimestamp > $self->{'cache'}{$ckey}{'cachetime'})
1522 0 0 if ($cmode eq "D")
1558 0 0 if (defined $self->{'cache'}{$ckey} and not $self->{'cache'}{$ckey}{'deleted'}) { }
1578 0 0 if ($ckey =~ /(.+)\=(.+)/u)
1584 0 0 if (defined $self->{'cache'}{$ckey} and not $self->{'cache'}{$ckey}{'deleted'} and &looks_like_number($self->{'cache'}{$ckey}{'data'}))
1599 0 0 if ($ckey =~ /(.+)\=(.+)/u)
1605 0 0 if (defined $self->{'cache'}{$ckey} and not $self->{'cache'}{$ckey}{'deleted'} and &looks_like_number($self->{'cache'}{$ckey}{'data'}))
1638 0 0 if ($inmsg =~ /^LISTEN\ (.*)/u) { }
0 0 elsif ($inmsg =~ /^UNLISTEN\ (.*)/u) { }
0 0 elsif ($inmsg =~ /^MONITOR/u) { }
0 0 elsif ($inmsg =~ /^UNMONITOR/u) { }
0 0 elsif ($inmsg =~ /^QUIT/u) { }
0 0 elsif ($inmsg =~ /^TIMEOUT/u and $self->{'clients'}{$cid}{'interclacks'}) { }
0 0 elsif ($inmsg =~ /^PING/u) { }
0 0 elsif ($inmsg =~ /^NOPING/u) { }
0 0 elsif ($inmsg =~ /^CLIENTLIST/u) { }
0 0 elsif ($inmsg =~ /^CLIENTDISCONNECT\ (.+)/u) { }
0 0 elsif ($inmsg =~ /^FLUSH\ (.+)/u) { }
1684 0 0 if (defined $self->{'clients'}{$lmccid})
1704 0 0 if ($inmsg =~ /^NOTIFY\ (.*)/u) { }
0 0 elsif ($inmsg =~ /^SET\ (.+?)\=(.*)/u) { }