Ir al contenido principal.
Enlaces relacionados:  Prensa  Compañía  Clientes  Contáctenos
Solsoft

Foros

[php-gni] More notes on thread safety for PHP


Autor Mensaje
Escrito en: 31. 10. 2005 [12:54]
braulio
Braulio Solano Rojas
registrado desde: 16.05.2008
Entradas: 2
Hi!

Jesús had you time to read the articles from Zend?

http://www.zend.com/php/internals/extension-writing1.php
http://www.zend.com/php/internals/extension-writing2.php

As you can see PHP is part a Virtual Machine like Java. In fact you can
have scripts in opcodes just ready to run. Thread safety is provided by
the Zend Engine.

Sometimes PHP is compiled for multi-threaded platforms like IIS or Apache.
That is where all those macros for thread safety are handy. When PHP is
a CGI it does not matter very much since it runs one time and variables or
functions are in their own address space and are not shared.

I believe I have an error in function php_isis_subrow_array with thread
safety. But I am not sure.

See this comment (from php_isis.h):

/* In every utility function you add that needs to use variables
in php_isis_globals, call TSRM_FETCH(); after declaring other
variables used by that function, or better yet, pass in TSRMG_CC
after the last function argument and declare your utility function
with TSRMG_DC after the last declared argument. Always refer to
the globals in your function as ISIS_G(variable). You are
encouraged to rename these macros something shorter, see
examples in any other php module directory.
*/

I saved it because I never understood it very well. In fact I believe it
is very important, but the writing is actually ambiguous to me. And as
you can see it seems there are two ways of achieving what that paragraph
means (good bye orthogonality).

In php_isis_subrow_array I believe I am not using globals from
php_isis_globals, but I am doing something wrong that makes the extension
not thread safe.

TSRM macros are used almost very well in the extension (and I have to
notice that it was the first time I was doing that kind of stuff).

There are other issues like for instance isis_terms. As you can see
results are saved in a variable like this one:

union { OpenIsisRec set; char buf[10000]; } result;

I do not know how OpenIsis library handles this. Therefore I do not know
what happens if the result is bigger than 10000 bytes. Maybe this is why
Róger asked for isis_terms_by_range, which I do not like since the
extension should be maintained as simple as possible and what can be done
in PHP land should be done there. But in this case an exception must be
made since isis_terms by itself does not work well.

Well, as you can see thread safety can be considered as avoiding
"Segmentation fault".

Saludos,

B.

------------------------------------------
Posted to Phorum via PhorumMail



¿Ha olvidado su contraseña?

Por favor introduzca su nombre de usuario o dirección de correo electrónico. Las instrucciones para restablecer la contraseña serán inmediatamente enviadas por correo electrónico.
Restablecer contraseña

Volver al formulario de inicio de sesión 


Copyright © 2003-2009, Solsoft de Costa Rica S.A.
Declaración de privacidad