|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 9 Dec 2006 03:34:01 -0000 Issue 4504
php-general-digest-help
lists.php.net
Date: Fri Dec 08 2006 - 21:34:01 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 9 Dec 2006 03:34:01 -0000 Issue 4504
Topics (messages 245651 through 245664):
Re: signal handling
245651 by: Jochem Maas
245654 by: Stut
245655 by: Roman Neuhauser
245656 by: Mustafa Aras Koktas
Re: How to be sure to use SSL
245652 by: Jochem Maas
245653 by: Stut
Load Extensions
245657 by: Igor Kravchenko
245658 by: Jim Lucas
245659 by: Igor Kravchenko
245662 by: Jim Lucas
245663 by: Igor Kravchenko
php and DB2
245660 by: afan.afan.net
245661 by: Kristen G. Thorson
245664 by: tedd
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Roman Neuhauser wrote:
> # manager
phidot.com / 2006-12-02 02:01:35 +0200:
>> Hello
>>
>> Despite all of my results to succeed, i can not make this work. What i want
>> to do is to write a simple socket server in PHP. My current example just
>> prints the same character, you send to server from keyboard. It is
>> successfull in forking, and generates child as people connect. However in
>> any way the client exits, the child process remains defunct on system. I am
>> trying to use signal handling, but some comments say through hanging
>> sockets, it is not possible to handle signals.
>>
>> How can i stop this from happening, i am attaching the code i am working on,
>> the 2 signals added at the bottom are just for test there, i tried all other
>> signal types. Sending a posix_kill(posix_getpid(), SIGKILL) to the process
>> when the client exits does not kill it too, it still is defunct.
>>
>> My code: http://pastey.net/2910
>
> The parent needs to wait(2) for its children. http://php.net/pcntl_wait
hi Roman,
have I understood correctly that using pcntl_wait() means you can't do anything in
the parent process until all children are dead?
this seems strange. probably I'm mis-understanding and need to reread [alot of] stuff.
but if it is true how do you go about tackling the signal handling in child processes
AND at the same time have the parent process do something useful like ...
interact/direct child processes, do other management tasks whilst child processes are running?
maybe I'm misunderstanding the whole concept - it's nice to have that newbie feeling again ;-)
>
attached mail follows:
Jochem Maas wrote:
> Roman Neuhauser wrote:
>
>> The parent needs to wait(2) for its children. http://php.net/pcntl_wait
>>
>
> have I understood correctly that using pcntl_wait() means you can't do anything in
> the parent process until all children are dead?
>
> this seems strange. probably I'm mis-understanding and need to reread [alot of] stuff.
>
> but if it is true how do you go about tackling the signal handling in child processes
> AND at the same time have the parent process do something useful like ...
> interact/direct child processes, do other management tasks whilst child processes are running?
>
> maybe I'm misunderstanding the whole concept - it's nice to have that newbie feeling again ;-)
I have a system that forks to 'do work'. The main script sits in an
infinite loop waiting for work, when it gets some it forks to process it.
In that loop I have the following at the end...
while (pcntl_wait($status, WNOHANG)) > 0)
$workers--;
That takes care of cleaning up finished processes while running.
If the loop ends for any reason (e.g. it got stopped by a status
change), I do...
$started = time();
while ($workers > 0 and (time() - $started) < 300)
{
pcntl_wait($status, WNOHANG);
$workers--;
sleep(1);
}
That sits waiting for up to 5 minutes for all processes to end.
-Stut
**
attached mail follows:
# jochem
iamjochem.com / 2006-12-08 15:36:52 +0100:
> Roman Neuhauser wrote:
> > # manager
phidot.com / 2006-12-02 02:01:35 +0200:
> >> [...] to write a simple socket server in PHP. My current example just
> >> prints the same character, you send to server from keyboard. It is
> >> successfull in forking, and generates child as people connect. However in
> >> any way the client exits, the child process remains defunct on system.
> > The parent needs to wait(2) for its children. http://php.net/pcntl_wait
>
> have I understood correctly that using pcntl_wait() means you can't do anything in
> the parent process until all children are dead?
no.
> but if it is true how do you go about tackling the signal handling in child processes
> AND at the same time have the parent process do something useful like ...
> interact/direct child processes, do other management tasks whilst child processes are running?
do whatever you want, either have a SIGCLD handler, or check one of the
wait(2)-family functions every now and then (and make sure to use
WNOHANG).
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
attached mail follows:
Roman, Stut and Jochem, thanks for the comments and recommendations on the
subject.
I have installed my signal as pcntl_signal(SIGCHLD, SIG_IGN) without a
specific function handler and it is closing child processes now. I could not
use the pcntl_wait because it is available after PHP 5.0 i guess.
-----Original Message-----
From: Roman Neuhauser [mailto:neuhauser
sigpipe.cz]
Sent: Friday, December 08, 2006 7:02 PM
To: Jochem Maas
Cc: php-general
lists.php.net
Subject: Re: [PHP] signal handling
# jochem
iamjochem.com / 2006-12-08 15:36:52 +0100:
> Roman Neuhauser wrote:
> > # manager
phidot.com / 2006-12-02 02:01:35 +0200:
> >> [...] to write a simple socket server in PHP. My current example just
> >> prints the same character, you send to server from keyboard. It is
> >> successfull in forking, and generates child as people connect. However
in
> >> any way the client exits, the child process remains defunct on system.
> > The parent needs to wait(2) for its children.
http://php.net/pcntl_wait
>
> have I understood correctly that using pcntl_wait() means you can't do
anything in
> the parent process until all children are dead?
no.
> but if it is true how do you go about tackling the signal handling in
child processes
> AND at the same time have the parent process do something useful like ...
> interact/direct child processes, do other management tasks whilst child
processes are running?
do whatever you want, either have a SIGCLD handler, or check one of the
wait(2)-family functions every now and then (and make sure to use
WNOHANG).
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
Alain Roger wrote:
> Richard,
>
> as i wrote you before, i've gotthe following suggestion to implement before
> to run the rest of my PHP code.
>
> if($_SERVER['HTTPS']!='on')
> {
> header('location:https://www.mysite.com');
> exit;
> }
> ...
>
> but i do not know if it's enough.
it is enough - but I'd like to clean it up for you just a tiny bit:
1. use isset on thwe var your checking
2. strtolower() the var your checking to cover your ass on even the weirdest
webserver SAPIs (I have seen the values of 'On' and 'on' for $_SERVER['HTTPS'])
3. 'Location: ' not 'location:' (1 more 'location' and I'm a realestate agent, ack dang too late ;-)
if(!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on') {
header('Location: https://www.mysite.com');
exit;
}
>
> Alain
>
>
> On 12/2/06, Richard Lynch <ceo
l-i-e.com> wrote:
>>
>> On Sat, December 2, 2006 2:17 am, Alain Roger wrote:
>> > I would like to know how can i be sure to make customer use the SSL
>> > all the
>> > time.
>> > all the time in my PHP code, i write links as relative links, so
>> > without
>> > HTTPS.
>> >
>> > I was thinking to check everything if the port is the SSL port
>> > (default :
>> > 443), but it does not mean that protocol is HTTPS.
>> > So, how do you ensure that customer uses SSL protocol all the time ?
>>
>> I was asking myself that same question last week, but I searched on
>> http://php.net for the answer.
>>
>> Did you try that?
>>
>> :-)
>>
>> --
>> Some people have a "gift" link here.
>> Know what I want?
>> I want you to buy a CD from some starving artist.
>> http://cdbaby.com/browse/from/lynch
>> Yeah, I get a buck. So?
>>
>>
>
>
attached mail follows:
Alain Roger wrote:
> but i do not know if it's enough.
Sorry it doesn't use PHP, but this is what I do if the client wants an
entire site to always use SSL. In the web server config for the non-ssl
site, put a permanent redirection to the SSL site. For Apache I use the
following vhost...
<VirtualHost 10.10.10.5:80>
ServerName domain.com
ServerAlias www.domain.com
Redirect permanent / https://www.domain.com/
</VirtualHost>
Works great, and it retains the full URL they were aiming for. For
example, if they go to http://domain.com/somewhere they end up at
https://www.domain.com/somewhere.
I'm sure something similar is possible in most web servers.
-Stut
attached mail follows:
Can someone help me with this, please? I cannot load extensions.
I setup php5 in the c:\php folder. I specified extension_dir =
"C:\php\ext".
Everything else is setup correctly because php works. for me, I can load
phpinfo file.
It would not load extensions.
I am going nuts here. Please anyone, what can it be????
Thank you.
attached mail follows:
Igor Kravchenko wrote:
> Can someone help me with this, please? I cannot load extensions.
>
> I setup php5 in the c:\php folder. I specified extension_dir =
> "C:\php\ext".
>
> Everything else is setup correctly because php works. for me, I can load
> phpinfo file.
>
> It would not load extensions.
>
> I am going nuts here. Please anyone, what can it be????
>
> Thank you.
>
>
run the phpinfo() command in a script and see where your php.ini file is
located.
make sure you are editing the correct file.
jl
attached mail follows:
Thank you for your reply.
I have only one php.ini. I checked it.
Now, I found in the evenet log viewer that I have lots of messages like:
"Module compiled with module API=20060613, debug=0, thread-safety=1
PHP compiled with module API=20020429, debug=0, thread-safety=1
These options need to match"
And
" PHP Warning: Unknown(): Unable to load dynamic library
'C:\php\ext\php_mysqli.dll' - The specified procedure could not be found.
in Unknown on line 0."
Any ideas?
The file is there and this is the correct path.
Thank you.
ILK.
"Jim Lucas" <lists
cmsws.com> wrote in message
news:4579C92A.8020907
cmsws.com...
> Igor Kravchenko wrote:
>> Can someone help me with this, please? I cannot load extensions.
>>
>> I setup php5 in the c:\php folder. I specified extension_dir =
>> "C:\php\ext".
>>
>> Everything else is setup correctly because php works. for me, I can load
>> phpinfo file.
>>
>> It would not load extensions.
>>
>> I am going nuts here. Please anyone, what can it be????
>>
>> Thank you.
>>
> run the phpinfo() command in a script and see where your php.ini file is
> located.
>
> make sure you are editing the correct file.
>
> jl
attached mail follows:
Igor Kravchenko wrote:
> Thank you for your reply.
>
> I have only one php.ini. I checked it.
>
> Now, I found in the evenet log viewer that I have lots of messages like:
>
> "Module compiled with module API=20060613, debug=0, thread-safety=1
>
> PHP compiled with module API=20020429, debug=0, thread-safety=1
>
> These options need to match"
>
> And
>
> " PHP Warning: Unknown(): Unable to load dynamic library
> 'C:\php\ext\php_mysqli.dll' - The specified procedure could not be found.
>
> in Unknown on line 0."
>
> Any ideas?
>
> The file is there and this is the correct path.
>
> Thank you.
>
> ILK.
>
>
>
>
>
> "Jim Lucas" <lists
cmsws.com> wrote in message
> news:4579C92A.8020907
cmsws.com...
>
>> Igor Kravchenko wrote:
>>
>>> Can someone help me with this, please? I cannot load extensions.
>>>
>>> I setup php5 in the c:\php folder. I specified extension_dir =
>>> "C:\php\ext".
>>>
>>> Everything else is setup correctly because php works. for me, I can load
>>> phpinfo file.
>>>
>>> It would not load extensions.
>>>
>>> I am going nuts here. Please anyone, what can it be????
>>>
>>> Thank you.
>>>
>>>
>> run the phpinfo() command in a script and see where your php.ini file is
>> located.
>>
>> make sure you are editing the correct file.
>>
>> jl
>>
>
>
The "These options need to match" warning is talking about the version of php that it was compiled against. They look like timestamps to me. So,I will assume you are trying to use a different version of php then what the extension was compiled against.
Find out what version of PHP you are using and what version of PHP the extension was compiled for and you might then have your answer.
jl
attached mail follows:
Thank you.
I removed php folder - everything except php.ini file and replaced with the
new downloaded version and it started working.
Thank you for your help.
"Jim Lucas" <lists
cmsws.com> wrote in message
news:4579D0F3.2060005
cmsws.com...
> Igor Kravchenko wrote:
>> Thank you for your reply.
>>
>> I have only one php.ini. I checked it.
>>
>> Now, I found in the evenet log viewer that I have lots of messages like:
>>
>> "Module compiled with module API=20060613, debug=0, thread-safety=1
>>
>> PHP compiled with module API=20020429, debug=0, thread-safety=1
>>
>> These options need to match"
>>
>> And
>>
>> " PHP Warning: Unknown(): Unable to load dynamic library
>> 'C:\php\ext\php_mysqli.dll' - The specified procedure could not be found.
>>
>> in Unknown on line 0."
>>
>> Any ideas?
>>
>> The file is there and this is the correct path.
>>
>> Thank you.
>>
>> ILK.
>>
>>
>>
>>
>>
>> "Jim Lucas" <lists
cmsws.com> wrote in message
>> news:4579C92A.8020907
cmsws.com...
>>
>>> Igor Kravchenko wrote:
>>>
>>>> Can someone help me with this, please? I cannot load extensions.
>>>>
>>>> I setup php5 in the c:\php folder. I specified extension_dir =
>>>> "C:\php\ext".
>>>>
>>>> Everything else is setup correctly because php works. for me, I can
>>>> load phpinfo file.
>>>>
>>>> It would not load extensions.
>>>>
>>>> I am going nuts here. Please anyone, what can it be????
>>>>
>>>> Thank you.
>>>>
>>>>
>>> run the phpinfo() command in a script and see where your php.ini file is
>>> located.
>>>
>>> make sure you are editing the correct file.
>>>
>>> jl
>>
>>
>
> The "These options need to match" warning is talking about the version of
> php that it was compiled against. They look like timestamps to me. So,I
> will assume you are trying to use a different version of php then what the
> extension was compiled against.
>
> Find out what version of PHP you are using and what version of PHP the
> extension was compiled for and you might then have your answer.
>
> jl
attached mail follows:
hi to all,
my IT director got an idea to replace mysql with DB2. more
"power/flexibility/stability/security..."
though, for our needs, I think mysql is just fine and enough. the business
we are doing is promotional products and all online orders we have are
ONLY from our sales people. with 200-300 orders per day and averge of 5
items per order I think we really don't need that replacement.
though, don't know how php works with DB2 (assuming same quality as with
mysql).
can anybody give me some ideas and "reasons" to present to boss to NOT
replace mysql with DB2?
thanks.
-afan
attached mail follows:
> -----Original Message-----
> From: afan
afan.net [mailto:afan
afan.net]
> Sent: Friday, December 08, 2006 3:39 PM
> To: php-general
lists.php.net
> Subject: [PHP] php and DB2
>
> hi to all,
> my IT director got an idea to replace mysql with DB2. more
> "power/flexibility/stability/security..."
> though, for our needs, I think mysql is just fine and enough. the
business
> we are doing is promotional products and all online orders we have are
> ONLY from our sales people. with 200-300 orders per day and averge of
5
> items per order I think we really don't need that replacement.
> though, don't know how php works with DB2 (assuming same quality as
with
> mysql).
>
> can anybody give me some ideas and "reasons" to present to boss to NOT
> replace mysql with DB2?
>
> thanks.
>
> -afan
>
I don't know how close the syntax between MySQL and DB2 is, but I
suspect you're looking at quite a bit of rewrite. Unless your
application was written specifically to work with either, I doubt it
will simply be a matter of plugging in a new database.
attached mail follows:
At 9:38 PM +0100 12/8/06, afan
afan.net wrote:
>hi to all,
>my IT director got an idea to replace mysql with DB2. more
>"power/flexibility/stability/security..."
>though, for our needs, I think mysql is just fine and enough. the business
>we are doing is promotional products and all online orders we have are
>ONLY from our sales people. with 200-300 orders per day and averge of 5
>items per order I think we really don't need that replacement.
>though, don't know how php works with DB2 (assuming same quality as with
>mysql).
>
>can anybody give me some ideas and "reasons" to present to boss to NOT
>replace mysql with DB2?
>
>thanks.
>
>-afan
Afan:
These people will give you sound advice:
http://lists.nyphp.org/mailman/listinfo/mysql
Ask them.
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]