Edit report at http://bugs.php.net/bug.php?id=27152&edit=1

 ID:                 27152
 Updated by:         j...@php.net
 Reported by:        josh at mediascape dot com
 Summary:            fam_next_event() doesn't return the corresponding
                     request
-Status:             Open
+Status:             Bogus
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   Linux
 PHP Version:        5.0.0b3 (beta3)
 Block user comment: N
 Private report:     N

 New Comment:

This extension is in PECL nowadays.


Previous Comments:
------------------------------------------------------------------------
[2004-02-04 18:35:16] 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




------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=27152&edit=1

Reply via email to