pb: ezodf's daemon create zombies

Author Message

Alexandre Mironenkov

Tuesday 10 February 2009 3:19:57 am

Hi !

My problem is that daemon.php processes creates zombies after each conversion .doc to odt.

Someone has a solution pls ?

"/extension/ezodf/daemon.php" :

<?php
//
//
// Created on: <07-Jul-2005 10:14:34 bf>
//
// SOFTWARE NAME: eZ Publish
// SOFTWARE RELEASE: 4.0.1
// BUILD VERSION: 22260
// COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
// SOFTWARE LICENSE: GNU General Public License v2.0
// NOTICE: >
//   This program is free software; you can redistribute it and/or
//   modify it under the terms of version 2.0  of the GNU General
//   Public License as published by the Free Software Foundation.
//
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of version 2.0 of the GNU General
//   Public License along with this program; if not, write to the Free
//   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//   MA 02110-1301, USA.
//
//

/*

Needs the following in PHP Configuration

  --enable-cli
  --enable-pcntl
  --enable-sockets

*/

$host = "127.0.0.1";
$port = 9090;
$ooexecutable = "ooffice";
$maxClients = 3;
$display = ':99';


set_time_limit( 0 );

$socket = socket_create( AF_INET, SOCK_STREAM, 0) or die( "Could not create socket\n" );
$result = socket_bind( $socket, $host, $port ) or die( "Could not bind to socket\n" );
$result = socket_listen( $socket, $maxClients ) or die( "Could not set up socket listener\n" );

print( "Started OpenOffice.org daemon\n" );

function convert_to( $sourceFileName, $convertCommand, $destinationFileName )
{
    global $ooexecutable;
    global $display;

    print( "Converting document with $convertCommand\n" );

    switch ( $convertCommand )
    {
        case "convertToPDF":
        case "convertToOOo":
        case "convertToDoc":
        {
            $result = shell_exec( $ooexecutable . " -writer -invisible -display " . $display . " 'macro:///eZconversion.Module1." . $convertCommand . "(\"$sourceFileName\", \"$destinationFileName\")'" );
            echo "$result\n";
        }break;

        default:
        {
            echo "Unknown command $convertCommand";
            return "(1)-Unknown command $convertCommand";
        }break;
    }

    if ( !file_exists( $destinationFileName ) )
    {
        return "(3) - Unknown failure converting document \n $result";
    }

    return true;
}


while ( $spawn = socket_accept( $socket ))
{
    print( "got new connection\n" );
    $pid = pcntl_fork();
    if ( $pid != 0)
    {
        // In the main process
        socket_close( $spawn );
    }
    else
    {
        // We are in the forked child process
        socket_write( $spawn, "eZ Publish document conversion daemon\n");

        // Parse input
        $input = socket_read( $spawn, 1024 );

        $inputParts = explode( " ", $input );

        $command = trim( $inputParts[0] );
        $fileName = trim( $inputParts[1] );
        $destName = trim( $inputParts[2] );


        if ( file_exists( $fileName ) )
        {
            $result = convert_to( $fileName, $command, $destName );
            if ( !( $result === true ) )
            {
                echo( "Error: $result" );
                socket_write( $spawn, "Error: $result" );
            }
            else
            {
                echo( "Conversion ok. FilePath: $destName" );
                socket_write( $spawn, "FilePath: $destName" );
            }
        }
        else
        {
            echo( "Error: (2)-File not found" );
            socket_write( $spawn, "Error: (2)-File not found" );
        }

        socket_close( $spawn );
        die('Data Recieved on child ' . posix_getpid(). "\n");
    }
}

socket_close( $socket );
?>

Ɓukasz Serwatka

Tuesday 10 February 2009 3:45:51 am

Hi,

You can try method described here.
http://svn.ez.no/svn/extensions/ezodf/trunk/doc/README.daemon

Let us know if problem persists. If yes please describe it in details as well as provide step-by-step instructions how to reproduce it and report in issue tracker on http://issues.ez.no

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Alexandre Mironenkov

Tuesday 10 February 2009 7:46:23 am

I added pcntl_waitpid ($ pid, $ status, WUNTRACED);

...
    if ( $pid != 0)

    {
        // In the main process

        socket_close( $spawn );
	pcntl_waitpid($pid, $status, WUNTRACED);

    }
...

I'll see how it will evolve.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 01:14:25
Script start
Timing: Jan 31 2025 01:14:25
Module start 'layout'
Timing: Jan 31 2025 01:14:25
Module start 'content'
Timing: Jan 31 2025 01:14:27
Module end 'content'
Timing: Jan 31 2025 01:14:27
Script end

Main resources:

Total runtime1.3483 sec
Peak memory usage8,192.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.1406151.2109
Module start 'layout' 0.00540.0039 739.3516220.6875
Module start 'content' 0.00931.3382 960.03914,461.9219
Module end 'content' 1.34750.0008 5,421.960911.8438
Script end 1.3483  5,433.8047 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.2705160.0002
Check MTime0.00130.0940160.0001
Mysql Total
Database connection0.00060.044010.0006
Mysqli_queries1.260193.4542570.0221
Looping result0.00050.0385550.0000
Template Total1.288895.620.6444
Template load0.00210.157120.0011
Template processing1.286795.425620.6433
Template load and register function0.00120.088610.0012
states
state_id_array0.00200.145610.0020
state_identifier_array0.00240.177920.0012
Override
Cache load0.00160.1199180.0001
Sytem overhead
Fetch class attribute can translate value0.00140.101820.0007
Fetch class attribute name0.00250.188640.0006
XML
Image XML parsing0.00180.130420.0009
class_abstraction
Instantiating content class attribute0.00000.000940.0000
General
dbfile0.00340.2523180.0002
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 14
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs