Skip to content

Commit

Permalink
Add Perltidy configuration and build target
Browse files Browse the repository at this point in the history
Also does an initial run.
  • Loading branch information
zwoop committed Mar 8, 2019
1 parent 40f94cc commit 97aac1e
Show file tree
Hide file tree
Showing 19 changed files with 1,304 additions and 1,342 deletions.
14 changes: 14 additions & 0 deletions .perltidyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This is a simple of a .perltidyrc configuration file
-l=132 # Line length
-i=4 # 4-space indentation
-nlp # Line up params
-ce # cuddle the braces
-tso # Tight secret ops
-nsfs # No space for semicolon
-pt=2 # tight parens
-bt=2 # tight braces
-sbt=2 # tight brackets
-bbt=2 # tight code brackets
-nbbc # No blank lines before comment lines
-otr # No break between a comma and an opening token
-sbl # Empty lane for sub's opening brace
5 changes: 4 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ autopep8:
# If you make changes to directory structures, you must update this as well.
#
.PHONY: clang-format-src clang-format-example clang-format-iocore clang-format-lib clang-format-mgmt \
clang-format-plugins clang-format-proxy clang-format-tools
clang-format-plugins clang-format-proxy clang-format-tools perltidy

clang-format: clang-format-src clang-format-example clang-format-iocore clang-format-lib clang-format-mgmt \
clang-format-plugins clang-format-proxy clang-format-tools clang-format-tests
Expand Down Expand Up @@ -152,6 +152,9 @@ clang-format-tools:
clang-format-tests:
@$(top_srcdir)/tools/clang-format.sh $(top_srcdir)/tests

perltidy:
perltidy -q -b -bext='/' `find . -name \*.pm -o -name \*.pl`

help:
@echo 'all default target for building the package'
@echo 'asf-dist recreate source package'
Expand Down
68 changes: 34 additions & 34 deletions ci/jenkins/ats_conf.pl
Original file line number Diff line number Diff line change
Expand Up @@ -32,69 +32,69 @@
#$recedit->append(line => "CONFIG proxy.config.crash_log_helper STRING /home/admin/bin/invoker_wrap.sh");

# Port setup
$recedit->set(conf => "proxy.config.http.server_ports", val => "80 80:ipv6 443:ssl 443:ipv6:ssl");
$recedit->set(conf => "proxy.config.admin.autoconf_port", val => "48083");
$recedit->set(conf => "proxy.config.http.server_ports", val => "80 80:ipv6 443:ssl 443:ipv6:ssl");
$recedit->set(conf => "proxy.config.admin.autoconf_port", val => "48083");
$recedit->set(conf => "proxy.config.process_manager.mgmt_port", val => "48084");

# Threads
$recedit->set(conf => "proxy.config.exec_thread.autoconfig", val => "0");
$recedit->set(conf => "proxy.config.exec_thread.limit", val => "8");
$recedit->set(conf => "proxy.config.exec_thread.limit", val => "8");
$recedit->set(conf => "proxy.config.cache.threads_per_disk", val => "8");
$recedit->set(conf => "proxy.config.accept_threads", val => "0");
$recedit->set(conf => "proxy.config.exec_thread.affinity", val => "1");
$recedit->set(conf => "proxy.config.accept_threads", val => "0");
$recedit->set(conf => "proxy.config.exec_thread.affinity", val => "1");

# TLS
#$recedit->set(conf => "proxy.config.ssl.server.cipher_suite", val => "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2:!RC4");
$recedit->set(conf => "proxy.config.ssl.hsts_max_age", val => "17280000");
#$recedit->set(conf => "proxy.config.ssl.max_record_size", val => "-1");
$recedit->set(conf => "proxy.config.ssl.session_cache", val => "2");
$recedit->set(conf => "proxy.config.ssl.ocsp.enabled", val => "1");
$recedit->set(conf => "proxy.config.ssl.session_cache", val => "2");
$recedit->set(conf => "proxy.config.ssl.ocsp.enabled", val => "1");
$recedit->set(conf => "proxy.config.http2.stream_priority_enabled", val => "1");

# Cache setup
$recedit->set(conf => "proxy.config.cache.ram_cache.size", val => "1536M");
$recedit->set(conf => "proxy.config.cache.ram_cache_cutoff", val => "4M");
$recedit->set(conf => "proxy.config.cache.limits.http.max_alts", val => "4");
$recedit->set(conf => "proxy.config.cache.dir.sync_frequency", val => "600"); # 10 minutes intervals
$recedit->set(conf => "proxy.config.cache.ram_cache.size", val => "1536M");
$recedit->set(conf => "proxy.config.cache.ram_cache_cutoff", val => "4M");
$recedit->set(conf => "proxy.config.cache.limits.http.max_alts", val => "4");
$recedit->set(conf => "proxy.config.cache.dir.sync_frequency", val => "600"); # 10 minutes intervals
$recedit->set(conf => "proxy.config.http.cache.ignore_client_cc_max_age", val => "1");
$recedit->set(conf => "proxy.config.allocator.hugepages", val => "1");
$recedit->set(conf => "proxy.config.allocator.hugepages", val => "1");

# HTTP caching related stuff
$recedit->set(conf => "proxy.config.http.cache.required_headers", val => "1");
$recedit->set(conf => "proxy.config.http.insert_request_via_str", val => "1");
$recedit->set(conf => "proxy.config.http.insert_response_via_str", val => "2");
$recedit->set(conf => "proxy.config.http.negative_caching_enabled", val => "1");
$recedit->set(conf => "proxy.config.http.cache.required_headers", val => "1");
$recedit->set(conf => "proxy.config.http.insert_request_via_str", val => "1");
$recedit->set(conf => "proxy.config.http.insert_response_via_str", val => "2");
$recedit->set(conf => "proxy.config.http.negative_caching_enabled", val => "1");
$recedit->set(conf => "proxy.config.http.negative_caching_lifetime", val => "60");
$recedit->set(conf => "proxy.config.http.chunking.size", val => "64k");
$recedit->set(conf => "proxy.config.url_remap.pristine_host_hdr", val => "1");
$recedit->set(conf => "proxy.config.http.chunking.size", val => "64k");
$recedit->set(conf => "proxy.config.url_remap.pristine_host_hdr", val => "1");

# Timeouts
$recedit->set(conf => "proxy.config.http.keep_alive_no_activity_timeout_in", val => "300");
$recedit->set(conf => "proxy.config.http.keep_alive_no_activity_timeout_out", val => "300");
$recedit->set(conf => "proxy.config.http.keep_alive_no_activity_timeout_in", val => "300");
$recedit->set(conf => "proxy.config.http.keep_alive_no_activity_timeout_out", val => "300");
$recedit->set(conf => "proxy.config.http.transaction_no_activity_timeout_out", val => "180");
$recedit->set(conf => "proxy.config.http.transaction_no_activity_timeout_in", val => "180");
$recedit->set(conf => "proxy.config.http.transaction_active_timeout_in", val => "180");
$recedit->set(conf => "proxy.config.http.transaction_active_timeout_out", val => "180");
$recedit->set(conf => "proxy.config.http.accept_no_activity_timeout", val => "30");
$recedit->set(conf => "proxy.config.http.transaction_no_activity_timeout_in", val => "180");
$recedit->set(conf => "proxy.config.http.transaction_active_timeout_in", val => "180");
$recedit->set(conf => "proxy.config.http.transaction_active_timeout_out", val => "180");
$recedit->set(conf => "proxy.config.http.accept_no_activity_timeout", val => "30");

# DNS / HostDB
$recedit->set(conf => "proxy.config.cache.hostdb.sync_frequency", val => "0");
$recedit->set(conf => "proxy.config.cache.hostdb.sync_frequency", val => "0");

# Logging
$recedit->set(conf => "proxy.config.log.logging_enabled", val => "3");
$recedit->set(conf => "proxy.config.log.max_space_mb_for_logs", val => "4096");
$recedit->set(conf => "proxy.config.log.max_space_mb_headroom", val => "64");
$recedit->set(conf => "proxy.config.log.logging_enabled", val => "3");
$recedit->set(conf => "proxy.config.log.max_space_mb_for_logs", val => "4096");
$recedit->set(conf => "proxy.config.log.max_space_mb_headroom", val => "64");

# Network
$recedit->set(conf => "proxy.config.net.connections_throttle", val => "10000");
$recedit->set(conf => "proxy.config.net.sock_send_buffer_size_in", val => "4M");
$recedit->set(conf => "proxy.config.net.connections_throttle", val => "10000");
$recedit->set(conf => "proxy.config.net.sock_send_buffer_size_in", val => "4M");
$recedit->set(conf => "proxy.config.net.sock_recv_buffer_size_out", val => "4M");
$recedit->set(conf => "proxy.config.net.poll_timeout", val => "30");
$recedit->set(conf => "proxy.config.net.poll_timeout", val => "30");

# Local additions (typically not found in the records.config.default)
$recedit->set(conf => "proxy.config.dns.dedicated_thread", val => "0");
$recedit->set(conf => "proxy.config.http_ui_enabled", val => "3");
$recedit->set(conf => "proxy.config.http.server_max_connections", val =>"250");
$recedit->set(conf => "proxy.config.dns.dedicated_thread", val => "0");
$recedit->set(conf => "proxy.config.http_ui_enabled", val => "3");
$recedit->set(conf => "proxy.config.http.server_max_connections", val => "250");

#$recedit->set(conf => "proxy.config.mlock_enabled", val => "2");

Expand Down
1 change: 1 addition & 0 deletions ci/rat-regex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
.*\.gold$
^\.gitignore$
^\.gitmodules$
^\.perltidyrc$
^\.indent.pro$
^\.vimrc$
^\.clang-.*$
Expand Down
11 changes: 5 additions & 6 deletions lib/perl/examples/forw_proxy_conf.pl
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,23 @@

use Apache::TS::Config::Records;


############################################################################
# Simple script, to show some minimum configuration changes typical for
# a forward proxy.
my $fn = $ARGV[0] || "/usr/local/etc/trafficserver/records.config";
my $recedit = new Apache::TS::Config::Records(file => $fn);

# Definitely tweak the memory config
$recedit->set(conf => "proxy.config.cache.ram_cache.size", val => "2048M");
$recedit->set(conf => "proxy.config.cache.ram_cache.size", val => "2048M");

# These puts the server in forward proxy mode only.
$recedit->set(conf => "proxy.config.url_remap.remap_required", val => "0");
$recedit->set(conf => "proxy.config.reverse_proxy.enabled", val => "0");
$recedit->set(conf => "proxy.config.url_remap.remap_required", val => "0");
$recedit->set(conf => "proxy.config.reverse_proxy.enabled", val => "0");

# Fine tuning, you might or might not want these
$recedit->set(conf => "proxy.config.http.transaction_active_timeout_in", val => "1800");
$recedit->set(conf => "proxy.config.dns.dedicated_thread", val => "1");
$recedit->set(conf => "proxy.config.http.normalize_ae_gzip", val => "1");
$recedit->set(conf => "proxy.config.dns.dedicated_thread", val => "1");
$recedit->set(conf => "proxy.config.http.normalize_ae_gzip", val => "1");

# Write out the new config file (this won't overwrite your config
$recedit->write(file => "$fn.new");
61 changes: 29 additions & 32 deletions lib/perl/lib/Apache/TS/AdminClient.pm
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,16 @@ use constant {
TS_ERR_FAIL => 12
};


# Semi-intelligent way of finding the mgmtapi socket.
sub _find_socket {
sub _find_socket
{
my $path = shift || "";
my $name = shift || "mgmtapi.sock";
my @sockets_def = (
$path,
Apache::TS::PREFIX . '/' . Apache::TS::REL_RUNTIMEDIR . '/' . 'mgmtapi.sock',
'/usr/local/var/trafficserver',
'/usr/local/var/run/trafficserver',
'/usr/local/var/run',
'/var/trafficserver',
'/var/run/trafficserver',
'/var/run',
$path, Apache::TS::PREFIX . '/' . Apache::TS::REL_RUNTIMEDIR . '/' . 'mgmtapi.sock',
'/usr/local/var/trafficserver', '/usr/local/var/run/trafficserver',
'/usr/local/var/run', '/var/trafficserver',
'/var/run/trafficserver', '/var/run',
'/opt/ats/var/trafficserver',
);

Expand All @@ -104,14 +100,14 @@ sub _find_socket {
#
# Constructor
#
sub new {
sub new
{
my ($class, %args) = @_;
my $self = {};

$self->{_socket_path} = _find_socket($args{socket_path});
$self->{_socket} = undef;
croak
"Unable to locate socket, please pass socket_path with the management api socket location to Apache::TS::AdminClient"
$self->{_socket} = undef;
croak "Unable to locate socket, please pass socket_path with the management api socket location to Apache::TS::AdminClient"
if (!$self->{_socket_path});
if ((!-r $self->{_socket_path}) or (!-w $self->{_socket_path}) or (!-S $self->{_socket_path})) {
croak "Unable to open $self->{_socket_path} for reads or writes";
Expand All @@ -128,39 +124,41 @@ sub new {
#
# Destructor
#
sub DESTROY {
sub DESTROY
{
my $self = shift;
return $self->close_socket();
}

#
# Open the socket (Unix domain)
#
sub open_socket {
sub open_socket
{
my $self = shift;
my %args = @_;

if (defined($self->{_socket})) {
if ($args{force} || $args{reopen}) {
$self->close_socket();
}
else {
} else {
return undef;
}
}

$self->{_socket} = IO::Socket::UNIX->new(
Type => SOCK_STREAM,
Peer => $self->{_socket_path}
) or croak("Error opening socket - $@");
) or croak("Error opening socket - $@");

return undef unless defined($self->{_socket});
$self->{_select}->add($self->{_socket});

return $self;
}

sub close_socket {
sub close_socket
{
my $self = shift;

# if socket doesn't exist, return as there's nothing to do.
Expand All @@ -177,10 +175,11 @@ sub close_socket {
#
# Do reads()'s on our Unix domain socket, takes an optional timeout, in ms's.
#
sub _do_read {
my $self = shift;
my $timeout = shift || 1/1000.0; # 1ms by default
my $res = "";
sub _do_read
{
my $self = shift;
my $timeout = shift || 1 / 1000.0; # 1ms by default
my $res = "";

while ($self->{_select}->can_read($timeout)) {
my $rc = $self->{_socket}->sysread($res, 1024, length($res));
Expand All @@ -199,14 +198,14 @@ sub _do_read {
return $res || undef;
}


#
# Get (read) a stat out of the local manager. Note that the assumption is
# that you are calling this with an existing stats "name".
#
sub get_stat {
sub get_stat
{
my ($self, $stat) = @_;
my $res = "";
my $res = "";

return undef unless defined($self->{_socket});
return undef unless $self->{_select}->can_write(10);
Expand All @@ -219,7 +218,7 @@ sub get_stat {
my $msg = pack("ll/Z", TS_RECORD_GET, $stat);
$self->{_socket}->print(pack("l/a", $msg));
$res = $self->_do_read();
return undef unless defined($res); # Don't proceed on read failure.
return undef unless defined($res); # Don't proceed on read failure.

# The response format is:
# MGMT_MARSHALL_INT: message length
Expand All @@ -235,12 +234,10 @@ sub get_stat {
if ($type == TS_REC_INT || $type == TS_REC_COUNTER) {
my ($ival) = unpack("q", $value);
return $ival;
}
elsif ($type == TS_REC_FLOAT) {
} elsif ($type == TS_REC_FLOAT) {
my ($fval) = unpack("f", $value);
return $fval;
}
elsif ($type == TS_REC_STRING) {
} elsif ($type == TS_REC_STRING) {
my ($sval) = unpack("Z*", $value);
return $sval;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/perl/lib/Apache/TS/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ our $VERSION = "1.0";

# Constants
use constant {
TS_CONF_UNMODIFIED => 0,
TS_CONF_MODIFIED => 1,
TS_CONF_REMOVED => 2
TS_CONF_UNMODIFIED => 0,
TS_CONF_MODIFIED => 1,
TS_CONF_REMOVED => 2
};
Loading

0 comments on commit 97aac1e

Please sign in to comment.