Skip to content

Commit

Permalink
fix: Fix blocked logger event during netscan on win32
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bougard committed Dec 19, 2023
1 parent 4b6fc32 commit b556f8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ core:
for trusted clients
* Update local target API to support getFullPath() & setFullPath() calls
* Handle '.' local target when run as a service to save inventories in vardir
* Reduce internal IPC event supported size
* To optimize IPC support, read all event messages before triggering events

inventory:
* PR #531: Add SentinelOne Antivirus support on Linux, thanks to @MarcSamD
Expand Down Expand Up @@ -55,6 +57,7 @@ toolbox:
* Fix wrong remote inventory results when using a short timeout for quickier detection
* Handle agent folder as vardir folder when agent is running as a service
* Fix netscan task fails to submit remote inventories with JSON protocol
* Fix locking on logger IPC events when running netscan for server target on win32

injector:
* fix #537: Make -x, --xml-ua & --json-ua options equivalent and update help text
Expand Down
9 changes: 7 additions & 2 deletions lib/GLPI/Agent/Daemon.pm
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ sub handleChildren {
my $child = $self->{_fork}->{$pid};

# Check if any forked process is communicating
my @messages;
delete $child->{in} unless $child->{in} && $child->{in}->opened;
while ($child->{in} && $child->{pollin} && $child->{poll} && &{$child->{poll}}($child->{pollin})) {
my $msg = " " x 5;
Expand All @@ -465,14 +466,17 @@ sub handleChildren {
if $child->{in}->sysread($len, 2);
if ($len) {
my $event;
$self->_trigger_event($event)
push @messages, $event
if $child->{in}->sysread($event, $len);
}
}
}
$count++;
}

# Trigger events after they have been read
map { $self->_trigger_event($_) } @messages;

# Check if any forked process has been finished
waitpid($pid, WNOHANG)
or next;
Expand Down Expand Up @@ -638,7 +642,8 @@ sub forked_process_event {
return unless $self->forked() && defined($event);

return unless length($event);
if (length($event) > 65535) {
# On MSWin32, syswrite can block if header+size+event is greater than 512 bytes
if (length($event) > 505) {
my ($type) = split(",", $event)
or return;
$type = substr($event, 0, 64) if length($type) > 64;
Expand Down

0 comments on commit b556f8a

Please sign in to comment.