php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #27152 fam_next_event() doesn't return the corresponding request
Submitted: 2004-02-04 18:35 UTC Modified: 2011-01-01 21:16 UTC
From: josh at mediascape dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.0.0b3 (beta3) OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: josh at mediascape dot com
New email:
PHP Version: OS:

 

 [2004-02-04 18:35 UTC] josh at mediascape dot com
Description:
------------
The array returned by fam_next_event() contains "filename", "code" and possibly "hostname", but it doesn't return any indicator of the FAMRequest that the event belongs to.  The underlying library returns this as the "fr" member of the FAMEvent struct -- "FAMRequest *fr;".  When monitoring multiple directories, this additional context is needed, since the filenames returned have no associated path information.

Reproduce code:
---------------
-- Sample PHP FAM client --
#! /usr/local/bin/php5
<?php
$conn = fam_open('zot-watch');
$r1 = fam_monitor_directory($conn, '/tmp');
$r2 = fam_monitor_directory($conn, '/var/tmp');

while ($event = fam_next_event($conn)) {
    print "File: $event[filename]\n";
    print "Code: $event[code]\n\n";
}
?>

-- Sample filesystem activity to trigger it --
$ touch /tmp/blib
$ touch /var/tmp/blib


Expected result:
----------------
I would expect fam_next_event() to return either the resource handle for the underlying FAMRequest structure (also returned by fam_monitor_directory() -- $r1 and $r2 in the code above), or the path argument to the fam_monitor_*() function so that the client code can reconstruct something meaningful from the returned event.

As an example, here's the modified lines inside the while() loop above, but expecting that fam_next_event() also returns the resource handle corresponding to fe->fr in the underlying struct:

    print "File: $event[filename]\n";
    print "Code: $event[code]\n";
    print "Request: $event[request]\n";
    $req = intval($event['request']);
    print "Path: ".($req == intval($r1) ?
        '/tmp' : '/var/tmp') . "\n\n";

I hesitate to produce the patch to php-5.0b3 I used to test this, only because I've never looked under PHP's hood before, and someone that knows what they're doing would likely produce the same changes at least as quickly as finding the SIGSEGV that I created in the process.

Actual result:
--------------
[Skipping the list of files that already exist for brevity]

File: blib
Code: 5

File: blib
Code: 5

-- Compared with the result from my test build --
File: blib
Code: 5
Request: Resource id #5
Path: /tmp

File: blib
Code: 5
Request: Resource id #6
Path: /var/tmp


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-01 21:16 UTC] jani@php.net
-Status: Open +Status: Bogus -Package: Feature/Change Request +Package: *General Issues
 [2011-01-01 21:16 UTC] jani@php.net
This extension is in PECL nowadays.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 09:01:34 2025 UTC