aboutsummaryrefslogtreecommitdiff
path: root/lib/Arctica/Core/JABus
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-09-18 12:43:20 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-09-18 12:43:20 +0200
commit674e65785dcf26adddd65c6c410e0a49efe5f088 (patch)
treeb66223bd3f27a1aa73bf760bce2fe022829463f2 /lib/Arctica/Core/JABus
parent85667be79db5df8bbf9082cb560d0cd46e4b196f (diff)
parentfb59da853fab3545c9531367e097babc87e53101 (diff)
downloadperl-Arctica-Core-JABus-Socket-674e65785dcf26adddd65c6c410e0a49efe5f088.tar.gz
perl-Arctica-Core-JABus-Socket-674e65785dcf26adddd65c6c410e0a49efe5f088.tar.bz2
perl-Arctica-Core-JABus-Socket-674e65785dcf26adddd65c6c410e0a49efe5f088.zip
Merge branch 'theqvd-json_read_fix'HEADmaster
Attributes GH PR #1: https://github.com/ArcticaProject/perl-Arctica-Core-JABus-Socket/pull/1
Diffstat (limited to 'lib/Arctica/Core/JABus')
-rw-r--r--lib/Arctica/Core/JABus/Socket.pm33
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/Arctica/Core/JABus/Socket.pm b/lib/Arctica/Core/JABus/Socket.pm
index 2ec46fe..fe9e12f 100644
--- a/lib/Arctica/Core/JABus/Socket.pm
+++ b/lib/Arctica/Core/JABus/Socket.pm
@@ -514,7 +514,20 @@ sub _server_handle_conn {
} elsif ( $client_conn_cond >= 'in' ) {
if ($self->{'clients'}{$client_id}{'io_obj'}) {
- my $bytes_read = sysread($self->{'clients'}{$client_id}{'io_obj'},my $in_data,16384);
+ my $bytes_read = 0;
+ my $in_data = "";
+
+ BugOUT(9,"JABus Server _handle_conn()->READ starting");
+ while($in_data !~ /\n$/s) {
+ my $rb = sysread($self->{'clients'}{$client_id}{'io_obj'}, $in_data, 16384, length($in_data));
+ last if ($rb == 0 && $in_data eq "");
+
+ $bytes_read += $rb;
+
+ BugOUT(9,"JABus Server _handle_conn()->BUFFER: '$in_data'");
+ }
+
+ BugOUT(9,"JABus Server _handle_conn()->READ completed, $bytes_read bytes read.");
$self->{'total_bytes_read'} += $bytes_read;
$self->{'clients'}{$client_id}{'bytes_read'}
@@ -709,7 +722,21 @@ sub _client_handle_conn {
return 0;
} elsif ( $connection_cond >= 'in' ) {
if ($self->{'the_socket'}) {
- my $bytes_read = sysread($self->{'the_socket'},my $in_data,16384);
+ my $bytes_read = 0;
+ my $in_data = "";
+
+ BugOUT(9,"JABus Server _handle_conn()->READ starting");
+ while($in_data !~ /\n$/s) {
+ my $rb = sysread($self->{'the_socket'}, $in_data, 16384, length($in_data));
+ last if ($rb == 0 && $in_data eq "");
+
+ $bytes_read += $rb;
+
+ BugOUT(9,"JABus Server _handle_conn()->BUFFER: '$in_data'");
+ }
+
+ BugOUT(9,"JABus Server _handle_conn()->READ completed, $bytes_read bytes read.");
+
$self->{'bytes_read'} += $bytes_read;
@@ -720,6 +747,8 @@ foreach my $in_data_line (split(/\n/,$in_data)) {
if ($in_data_line =~ /JAB/) {
my $jData;
+ BugOUT(9,"JABus::Socket _client_handle_conn()->Received JSON: '$in_data_line'");
+
eval {
$jData = decode_json($in_data_line);
} or warn("JABus _client_handle_conn()->DONE (Got some garbage instead of JSON!)");