Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ia7 v1.5.720 and HTTP 1.1, forking improvements #728

Merged
merged 31 commits into from
Aug 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b82daa4
IA7 v1.5.650 - json speech now enabled by default, forking fixes
hplato Aug 11, 2017
7c42218
IA7 v1.5.670 - persistent banners
hplato Aug 12, 2017
49aa421
IA7 v1.5.700 - cookie support for notification preferences
hplato Aug 12, 2017
5b278e3
Fixed debug case and fixed issue with Arm Away not updating the paren…
Aug 12, 2017
d998b8a
HTTP 1.1 Update #1
Aug 12, 2017
c3d0791
Merge pull request #10 from hplato/ia7
Aug 12, 2017
826bad4
Merge pull request #12 from waynieack/HTTP_Updates
hplato Aug 13, 2017
de6b5b2
Updated more code to use HTTP1.1 with Content-Length
Aug 13, 2017
ccca893
Merge branch 'master' into ia7
hplato Aug 13, 2017
fd8efdf
IA7 v1.5.720 - default notifications and slider layout
hplato Aug 14, 2017
e2f76ab
Merge pull request #13 from waynieack/HTTP_Updates
hplato Aug 14, 2017
eb728cd
fixed font path for weather icons
hplato Aug 24, 2017
fc2e940
IA7 v1.5.800 - voice_cmd set_link support
hplato Aug 24, 2017
e5e77bd
Cleaned up logging, added shutdown back to ajax.pm until the issues w…
Aug 24, 2017
7a74942
Merge pull request #14 from waynieack/HTTP_Updates
hplato Aug 24, 2017
8c30bbb
IA7 v1.5.810 - ia5 content padding
hplato Aug 25, 2017
ea3e96e
Merge branch 'ia7' of https://github.com/hplato/misterhouse into ia7
hplato Aug 25, 2017
8ee4840
Fixed issue with table updates and fixed a bug with MH crashing on th…
Aug 25, 2017
0d3637f
prevent crashes in table_data with bad data
hplato Aug 25, 2017
f73030e
removed gzip from json_server
hplato Aug 25, 2017
25f17d6
fix json_server with http1.1 and data tables
hplato Aug 25, 2017
f372330
Merge branch 'master' into ia7
hplato Aug 25, 2017
1ce3d41
collections.json 1.4 new humidity icon
hplato Aug 25, 2017
7730a04
IA7 v1.5.830 - minor improvements to email, mobile tables
hplato Aug 25, 2017
91caa45
More HTTP performance updates in json_server
Aug 27, 2017
9534c87
Merge pull request #15 from waynieack/HTTP_Updates
hplato Aug 27, 2017
2a115f5
More HTTP performance updates
Aug 27, 2017
1a99ad7
Merge pull request #16 from waynieack/HTTP_Updates
hplato Aug 27, 2017
b44bec9
added in Debug{fork} option
hplato Aug 29, 2017
df49c6b
Added connection: close headers until connection persistence issues a…
Aug 29, 2017
1cb682e
Merge pull request #17 from waynieack/HTTP_Updates
hplato Aug 29, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions bin/mh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ my ( $user_code, $user_code_last_good );
my ( %objects_by_object_name, %file_by_object_name, %files_by_webname );
my ( %object_names_by_file, %object_names_by_type, %object_names_by_webname, $pause_mode );
my ( @Server_Ports, @Generic_Devices, %Local_Addresses, @Local_Addresses, %Passwords, @Password_Allow_Clients );
my ( %proxy_servers, %app_parms );
my ( %proxy_servers, %app_parms, %waiter_flags );
my ( $CON_IN, $CON_OUT );

my ( $state, $temp ); # Some generic useful vars
Expand Down Expand Up @@ -2556,16 +2556,20 @@ sub check_for_socket_data_http {

# See if there is a http request
my $nfound = &socket_has_data( $Socket_Ports{http}{sock} );
#print "http: below nfound ....\n" if $Debug{http};
last unless $nfound > 0; # nfound = -1 means an error occurred
#print "http: below last unless nfound ....\n" if $Debug{http};
my $sock = $Socket_Ports{http}{sock}->accept();
#print "http: below sock ....\n" if $Debug{http};
last unless $sock; # Can be undef it socket was killed
#print "http: below last unless sock ....\n" if $Debug{http};
$sock->autoflush(1); # Not sure if this does anything?
$Socket_Ports{http}{socka} = $sock;

( $leave_socket_open_passes, $leave_socket_open_action ) = &http_process_request($sock);

my $time_diff = time - $time_check;
print "http: c=$loop_count td=$time_diff sop=$leave_socket_open_passes soa=$leave_socket_open_action.\n"
print "http: c=$loop_count td=$time_diff sop=$leave_socket_open_passes soa=$leave_socket_open_action. while loop\n"
if $Debug{http};

if ($leave_socket_open_action) {
Expand All @@ -2580,6 +2584,7 @@ sub check_for_socket_data_http {
# We must sleep here for a bit, or else Netscape sometimes
# says 'Document contains no data'. Guess we don't need this anymore :)
# select undef, undef, undef, .010;
#print "http: closing socket - ". $Info{'http_socket'}->peer ." ....\n" if $Debug{http};
&socket_close('http');
}
}
Expand Down Expand Up @@ -6695,12 +6700,16 @@ sub sig_handler_pipe {
sub sig_child_death {

# my $pid = wait;
# print "reaped $pid" . ($? ? " with exit $?" : '');
# print "reaped $pid" . ($? ? " with exit $?" : '');
# Harvest potentially more than one dead child
use POSIX ":sys_wait_h";
local ($!, $?);

my $pid;
do {
$pid = waitpid( -1, WNOHANG );
print "***PID MH reaped $pid" . ($? ? " with exit $?" : '') . "\n" if $Debug{fork};

} until $pid <= 0;

# $pid = waitpid(-1, &WNOHANG);
Expand Down Expand Up @@ -6813,9 +6822,8 @@ sub socket_has_data {
my $loopmax = 8;
do {
($nfound) = select( $rbit, undef, undef, $timeout );
last
if $nfound == -1
and !( $!{EINTR} ); # break out of the retry loop if an error did occur but not EINTR
#&::print_log("http: in socket_has_data do loop");
last if $nfound == -1 and !( $!{EINTR} ); # break out of the retry loop if an error did occur but not EINTR
$loopmax--;
} until ( $loopmax == 0 or ( $nfound >= 0 ) );

Expand Down Expand Up @@ -7757,6 +7765,18 @@ sub log_inc {
print_log( 'Perl @INC contains: ' . join( ", ", @INC ) );
}

sub set_waiter_flags {
my ($flag,$value) = @_;
$waiter_flags{$flag} = $value;
}

sub get_waiter_flags {
my ($flag) = @_;
$waiter_flags{$flag} = 0 unless (exists $waiter_flags{$flag});
return $waiter_flags{$flag};
}


#---------------------------------------------------------------------------

# Lets do it. Note, we put this at the bottom so
Expand Down
55 changes: 33 additions & 22 deletions code/common/ia7_notifications.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
#@ IA7 v1.1 : Enables speech notifications to browsers.
#@ also includes some sample code of how to use other notifications

if ( $Startup or $Reload ) {
if ( !defined $Info{IPAddress_local} ) {
print_log "json_server.pl: \$Info{IPAddress_local} not defined. Json speech disabled";
}
else {
print_log "IA7 Speech Notifications enabled";
&Speak_parms_add_hook( \&json_speech_enable );
}
}
#if ( $Startup or $Reload ) {
# if ( !defined $Info{IPAddress_local} ) {
# print_log "json_server.pl: \$Info{IPAddress_local} not defined. Json speech disabled";
# }
# else {
# print_log "IA7 Speech Notifications enabled";
# #&Speak_parms_add_hook( \&json_speech_enable );
# }
#}

$v_ia7_test_sound = new Voice_Cmd("Test playing a sound");
$v_ia7_test_banner = new Voice_Cmd("Test [blue,green,yellow,red] Banner Notification");
Expand All @@ -29,18 +29,29 @@
&json_notification( "sound", {%data} );
}

sub json_speech_enable {
my ($parms) = @_;
push @{ $parms->{web_hook} }, \&file_ready_for_ia7;
}

sub file_ready_for_ia7 {
my (%parms) = @_;
my %data;
$data{mode} = $parms{mode};
$data{url} = "http://" . $Info{IPAddress_local} . ":" . $config_parms{http_port} . "/" . $parms{web_file};
$data{text} = $parms{raw_text};
$data{client} = $parms{requestor};
&json_notification( "speech", {%data} );
}

#sub json_speech_enable {
# my ($parms) = @_;
# push( @{ $parms->{web_hook} }, \&file_ready_for_ia7);
#}

#sub file_ready_for_ia7 {
# my (%parms) = @_;
# my %data;
# $data{mode} = $parms{mode};
# $data{url} = "http://" . $Info{IPAddress_local} . ":" . $config_parms{http_port} . "/" . $parms{web_file};
# $data{text} = $parms{raw_text};
# $data{client} = $parms{requestor};
# if (defined $Info{IPAddress_local}) {
# if ((defined $parms{forked}) and $parms{forked} ) {
# #if it's a child process we can't access the global @json_notifications array, so send a webservice call to the master process
# my $MHParent = $Info{IPAddress_local} . ":" . $config_parms{http_port};
# my $cmd = "get_url -quiet \"http://$MHParent/SUB?ia7_notify(\'speech',$data{mode},'$data{text}',$data{url})\" /dev/null";
# run "$cmd" unless (defined $config_parms{disable_json_speech} and $config_parms{disable_json_speech});
# } else {
# &json_notification( "speech", {%data} );
# }
# }
#}

4 changes: 2 additions & 2 deletions data/web/collections.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"name" : "Rain Rate"
},
"meta" : {
"version" : "1.3"
"version" : "1.4"
},
"4" : {
"icon" : "fa-lightbulb-o",
Expand Down Expand Up @@ -425,7 +425,7 @@
},
"120" : {
"name" : "Indoor Humidity",
"icon" : "wi-sprinkles",
"icon" : "wi-humidity",
"link" : "/ia7/#path=/rrd?now-6hour?indoor_humid"
},
"91" : {
Expand Down
Loading