php-general Digest 9 Sep 2010 12:26:27 -0000 Issue 6931
Topics (messages 307888 through 307901):
Broken pipes, time outs, PHP, and mail
307888 by: Dave M G
307891 by: Bob McConnell
307892 by: [email protected]
307893 by: Dave M G
307894 by: [email protected]
307896 by: Bob McConnell
307898 by: Dave M G
307901 by: Bob McConnell
Re: logical AND assignments
307889 by: David Harkness
307897 by: David Harkness
Reformat array result.
307890 by: Paul Halliday
307895 by: chris h
Re: Filestat.c erorrs when building php-5.3.3 on solaris
307899 by: Tom Rogers
307900 by: Tom Rogers
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
PHP Gurus,
I have a set of scripts that sends out emails to a list of about 150
people. Sometimes it works fine.
Other times, it dies part way through the list, and in my error logs I
get this output:
fputs() [<a href='function.fputs'>function.fputs</a>]: send of 22 bytes
failed with errno=32 Broken pipe /public_html/class.smtp.php 489
The code that sends the mail is derived from here:
http://www.phpclasses.org/browse/file/920.html
It's mostly rock solid code, so far as I know, so I suspect the problem
to more with my server settings or something.
That said, I don't know what differentiates a failed mailing and a
successful one.
After a Google search, it seems "broken pipes" are a matter of time
outs. That's about as far as I understand it, though.
Can anyone throw me a tip as to how I might diagnose this problem?
Thank you for any advice.
--
Dave M G
--- End Message ---
--- Begin Message ---
From: Dave M G
> I have a set of scripts that sends out emails to a list of about 150
> people. Sometimes it works fine.
>
> Other times, it dies part way through the list, and in my error logs I
> get this output:
>
> fputs() [<a href='function.fputs'>function.fputs</a>]: send of 22
bytes
> failed with errno=32 Broken pipe /public_html/class.smtp.php 489
>
> The code that sends the mail is derived from here:
> http://www.phpclasses.org/browse/file/920.html
>
> It's mostly rock solid code, so far as I know, so I suspect the
problem
> to more with my server settings or something.
>
> That said, I don't know what differentiates a failed mailing and a
> successful one.
>
> After a Google search, it seems "broken pipes" are a matter of time
> outs. That's about as far as I understand it, though.
>
> Can anyone throw me a tip as to how I might diagnose this problem?
"Broken pipe" is a euphemism for "Network error". There are any number
of causes including the remote server closing the socket, a switch or
hub between here and there is bogged down by backup traffic, or a
segment your connection passes through became too busy with higher
priority video traffic. The actual details are difficult to determine
and none of the administrators involved will ever admit they had a
problem. In most cases the TCP/IP error will simply tell you it timed
out waiting for a response. Your code should be able to re-open the
connection at this point and resend the message that triggered the
error. Then resume working on the rest of your list.
Bob McConnell
--- End Message ---
--- Begin Message ---
Could it be that there are connection limits on the remote server?
Thanks,
Ash
http://www.ashleysheridan.co.uk
----- Reply message -----
From: "Bob McConnell" <[email protected]>
Date: Wed, Sep 8, 2010 18:24
Subject: [PHP] Broken pipes, time outs, PHP, and mail
To: <[email protected]>
From: Dave M G
> I have a set of scripts that sends out emails to a list of about 150
> people. Sometimes it works fine.
>
> Other times, it dies part way through the list, and in my error logs I
> get this output:
>
> fputs() [<a href='function.fputs'>function.fputs</a>]: send of 22
bytes
> failed with errno=32 Broken pipe /public_html/class.smtp.php 489
>
> The code that sends the mail is derived from here:
> http://www.phpclasses.org/browse/file/920.html
>
> It's mostly rock solid code, so far as I know, so I suspect the
problem
> to more with my server settings or something.
>
> That said, I don't know what differentiates a failed mailing and a
> successful one.
>
> After a Google search, it seems "broken pipes" are a matter of time
> outs. That's about as far as I understand it, though.
>
> Can anyone throw me a tip as to how I might diagnose this problem?
"Broken pipe" is a euphemism for "Network error". There are any number
of causes including the remote server closing the socket, a switch or
hub between here and there is bogged down by backup traffic, or a
segment your connection passes through became too busy with higher
priority video traffic. The actual details are difficult to determine
and none of the administrators involved will ever admit they had a
problem. In most cases the TCP/IP error will simply tell you it timed
out waiting for a response. Your code should be able to re-open the
connection at this point and resend the message that triggered the
error. Then resume working on the rest of your list.
Bob McConnell
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Bob,
Thank you for replying.
Your code should be able to re-open the
connection at this point and resend the message that triggered the
error. Then resume working on the rest of your list.
Unfortunately, it seems that this is not happening. The loop that sends
out individual mail dies, and the remaining mails stop being sent.
Is there perhaps some way I can force the PHP code to ignore the one
mailing that failed and continue with the rest?
--
Dave M G
--- End Message ---
--- Begin Message ---
In order to help we really need to have a look at the code in question. You say
the code is derived from another class you downloaded. Are you able to post the
important bits of it in an email, or put it all on a pastebin?
Thanks,
Ash
http://www.ashleysheridan.co.uk
----- Reply message -----
From: "Dave M G" <[email protected]>
Date: Wed, Sep 8, 2010 18:45
Subject: [PHP] Broken pipes, time outs, PHP, and mail
To: <[email protected]>
Bob,
Thank you for replying.
> Your code should be able to re-open the
> connection at this point and resend the message that triggered the
> error. Then resume working on the rest of your list.
Unfortunately, it seems that this is not happening. The loop that sends
out individual mail dies, and the remaining mails stop being sent.
Is there perhaps some way I can force the PHP code to ignore the one
mailing that failed and continue with the rest?
--
Dave M G
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
From: [email protected]
> Could it be that there are connection limits on the remote server?
>
> Thanks,
> Ash
Only if you are opening a new connection for each message. Any decent
SMTP client should be able to send multiple messages over a single
connection.
You could capture the traffic with Wireshark. Set the capture filter to
only grab SMTP traffic to that server's IP address. Unless it is going
through SSL/TLS, you can read the handshake messages. They will look
something like this:
-----8<--------------------------------
220 lists.php.net ESMTP Postfix
EHLO ashleysheridan.co.uk
250-mail.php.net
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250 8BITMIME
MAIL FROM:<[email protected]>
250 Ok
RCPT TO:<[email protected]>
250 Ok
-----8<--------------------------------
The lines beginning with numbers are the server's responses. All of them
should be ASCII/UTF-8 text.
There is one other possibility. According to the RFCs, the standard line
ending for email is CRLF. Make sure your system is sending both
characters after each line. There is a slim chance the server is cutting
you off after some number of bytes if you are only sending a LF.
Bob McConnell
--- End Message ---
--- Begin Message ---
Ash, Bob,
Thank you for replying.
There is one other possibility. According to the RFCs, the standard line
ending for email is CRLF. Make sure your system is sending both
characters after each line. There is a slim chance the server is cutting
you off after some number of bytes if you are only sending a LF.
This is actually a possiblity. I think I might be only using LF.
Some of the text being sent in the emails is entered via a form on a web
page. Is it possible to enforce CRLF on that text?
--
Dave M G
--- End Message ---
--- Begin Message ---
From: Dave M G
>> There is one other possibility. According to the RFCs, the standard
line
>> ending for email is CRLF. Make sure your system is sending both
>> characters after each line. There is a slim chance the server is
cutting
>> you off after some number of bytes if you are only sending a LF.
>
> This is actually a possiblity. I think I might be only using LF.
>
> Some of the text being sent in the emails is entered via a form on a
web
> page. Is it possible to enforce CRLF on that text?
You would have to scan the text when you process the form and replace
any bare LF you find with CRLF. The string sequence for that would be
"\r\n". It shouldn't be too difficult to come up with a regular
expression to find any LF not preceded by a CR and replace it.
Also, check your mail library to make sure it defines $EOL correctly as
well. I reported that as a bug in PHPMailer a while back. If it is
correct, it may actually fix the bare LF's for you.
Bob McConnell
--- End Message ---
--- Begin Message ---
The reason for "and" to have such a low precedence is so you can use it to
perform conditional processing. You can probably achieve every effect using
"&&", but you'd need more parentheses. More typically you would use "or" in
this fashion:
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
This checks if DS is defined and defines it if not.
APP_ENV != 'prod' or die('This feature must not be used in production');
If we're in production, stop execution with an error. Using || here would
try to logically or the string 'prod' with the return value of die(). Of
course, die() doesn't return, so the script would exit no matter what
APP_ENV was set to.
David
--- End Message ---
--- Begin Message ---
On Wed, Sep 8, 2010 at 9:55 AM, Peter Lind <[email protected]> wrote:
> || and && would work exactly like 'or' and 'and' in the above. ==, !=,
> === and !=== have higher precedence than || or &&
>
Ah, you're correct. The only operators between &&/|| and and/or and the
ternary ?: and assignment operators. Thus the need for the parentheses in
$Condition2 = (true and false);
to make $Condition2 false. The parentheses in
$Condition4 = (true && false);
are redundant since && has higher precedence than = (assignment).
Robert, how do the results differ from your expectations?
David
--- End Message ---
--- Begin Message ---
I have been starting at this problem blankly for a couple hours now.
Hopefully someone can help.
I have a query that returns an event count grouped by hour:
timestamp:
Array ( [0] => 2010-09-08 03 [1] => 2010-09-08 04 [2] => 2010-09-08 05
[3] => 2010-09-08 06 [4] => 2010-09-08 07 [5] => 2010-09-08 08 [6] =>
2010-09-08 09 [7] => 2010-09-08 10 [8] => 2010-09-08 11 [9] =>
2010-09-08 12 [10] => 2010-09-08 13 [11] => 2010-09-08 14 [12] =>
2010-09-08 15 [13] => 2010-09-08 16 ) 24
event count:
Array ( [0] => 1731 [1] => 885 [2] => 544 [3] => 668 [4] => 748 [5] =>
754 [6] => 933 [7] => 2422 [8] => 6713 [9] => 31925 [10] => 18827 [11]
=> 16743 [12] => 16875 [13] => 11775 )
Lets say that coming into this, I knew that the query spanned 36 hours
and started at 01:00. How can I manipulate the resulting array to
contain the missing time stamps and a value of 0.
The effect I am shooting for looks like this:
http://www.pintumbler.org/example.png
So 0 - > 23 will be static and I just walk through the array and
populate those. If we hit 23, start a new row and continue. The matrix
will always be the same though.
I think I know what needs to happen, I just cant come up with the logic.
Any push in the right direction would be appreciated.
--
Paul Halliday
Ideation | Individualization | Learner | Achiever | Analytical
http://www.pintumbler.org
--- End Message ---
--- Begin Message ---
Paul,
How are you matching the records in the "event count" array to the ones in
the timestamp array?
Is it safe to say that:
"$timestamp[ $i ]" corresponds to "$eventCount[ $i ]"?
If so, you could just iterate through the timestamp array; on each iteration
create a record in a new array that holds the timestamp and whatever the
corresponding eventCount record is. Something like:
--------------------------------
$newTimeArray = array();
foreach ($timestamps as $i => $singleTimestamp) {
$newTimeArray[ $i ] = array(
'timestamp' => $singleTimestamp,
'count' => $eventCounts[ $i ]
);
}
--------------------------------
Now if "$timestamp[ $i ]" does NOT correspond to "$eventCount[ $i ]" then I
think we'll need you to explain how that relationship works, unless I missed
something :)
Chris.
On Wed, Sep 8, 2010 at 1:02 PM, Paul Halliday <[email protected]>wrote:
> I have been starting at this problem blankly for a couple hours now.
> Hopefully someone can help.
>
> I have a query that returns an event count grouped by hour:
>
> timestamp:
> Array ( [0] => 2010-09-08 03 [1] => 2010-09-08 04 [2] => 2010-09-08 05
> [3] => 2010-09-08 06 [4] => 2010-09-08 07 [5] => 2010-09-08 08 [6] =>
> 2010-09-08 09 [7] => 2010-09-08 10 [8] => 2010-09-08 11 [9] =>
> 2010-09-08 12 [10] => 2010-09-08 13 [11] => 2010-09-08 14 [12] =>
> 2010-09-08 15 [13] => 2010-09-08 16 ) 24
>
> event count:
> Array ( [0] => 1731 [1] => 885 [2] => 544 [3] => 668 [4] => 748 [5] =>
> 754 [6] => 933 [7] => 2422 [8] => 6713 [9] => 31925 [10] => 18827 [11]
> => 16743 [12] => 16875 [13] => 11775 )
>
> Lets say that coming into this, I knew that the query spanned 36 hours
> and started at 01:00. How can I manipulate the resulting array to
> contain the missing time stamps and a value of 0.
>
> The effect I am shooting for looks like this:
>
> http://www.pintumbler.org/example.png
>
> So 0 - > 23 will be static and I just walk through the array and
> populate those. If we hit 23, start a new row and continue. The matrix
> will always be the same though.
>
> I think I know what needs to happen, I just cant come up with the logic.
>
> Any push in the right direction would be appreciated.
> --
> Paul Halliday
> Ideation | Individualization | Learner | Achiever | Analytical
> http://www.pintumbler.org
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Hi,
Thursday, September 9, 2010, 2:07:50 AM, you wrote:
SVCD> I am trying to build php-5.3.3 and getting the following error:
SVCD> /users/03333/php-5.3.3/TSRM -I/users/03333/php-5.3.3/Zend
SVCD> -I/usr/local/include -g -O2 -DZTS -c
SVCD> /users/03333/php-5.3.3/ext/standard/filestat.c -o
SVCD> ext/standard/filestat.lo
SVCD> /users/03333/php-5.3.3/ext/standard/filestat.c: In function
SVCD> `php_do_chgrp':
SVCD> /users/03333/php-5.3.3/ext/standard/filestat.c:416: error: too many
SVCD> arguments to function `getgrnam_r'
SVCD> /users/03333/php-5.3.3/ext/standard/filestat.c: In function
SVCD> `php_do_chown':
SVCD> /users/03333/php-5.3.3/ext/standard/filestat.c:517: error: too many
SVCD> arguments to function `getpwnam_r'
SVCD> make: *** [ext/standard/filestat.lo] Error 1
SVCD> I have set my ORACLE_HOME, my PATH, and my LD_LIBRARY_PATH
SVCD> And used the following configure command:
SVCD> ./configure --prefix=/app/php533 --with-apxs2=/app/apache2215/bin/apxs
SVCD> --with-zlib --with-zlib-dir=/usr/lib
SVCD> --with-png-dir=/usr/include/libpng
SVCD> --with-openssl=/shared_ro/openssl_098
SVCD> --with-oci8=/shared_ro/users.oracle/11.1.0
SVCD> I am using gmake 3.80. Can anyone give me a hint as to what I am doing
SVCD> wrong in this build?
SVCD> -Vicki Stanfield, RHCE, CISSP
From the error message it would seem the operating system's
getpwnam_r() function is not POSIX compatible.
What system are you compiling on?
--
regards,
Tom
--- End Message ---
--- Begin Message ---
Hi,
Thursday, September 9, 2010, 11:31:06 AM, you wrote:
TR> Hi,
TR> Thursday, September 9, 2010, 2:07:50 AM, you wrote:
SVCD>> I am trying to build php-5.3.3 and getting the following error:
SVCD>> /users/03333/php-5.3.3/TSRM -I/users/03333/php-5.3.3/Zend
SVCD>> -I/usr/local/include -g -O2 -DZTS -c
SVCD>> /users/03333/php-5.3.3/ext/standard/filestat.c -o
SVCD>> ext/standard/filestat.lo
SVCD>> /users/03333/php-5.3.3/ext/standard/filestat.c: In function
SVCD>> `php_do_chgrp':
SVCD>> /users/03333/php-5.3.3/ext/standard/filestat.c:416: error: too many
SVCD>> arguments to function `getgrnam_r'
SVCD>> /users/03333/php-5.3.3/ext/standard/filestat.c: In function
SVCD>> `php_do_chown':
SVCD>> /users/03333/php-5.3.3/ext/standard/filestat.c:517: error: too many
SVCD>> arguments to function `getpwnam_r'
SVCD>> make: *** [ext/standard/filestat.lo] Error 1
SVCD>> I have set my ORACLE_HOME, my PATH, and my LD_LIBRARY_PATH
SVCD>> And used the following configure command:
SVCD>> ./configure --prefix=/app/php533 --with-apxs2=/app/apache2215/bin/apxs
SVCD>> --with-zlib --with-zlib-dir=/usr/lib
SVCD>> --with-png-dir=/usr/include/libpng
SVCD>> --with-openssl=/shared_ro/openssl_098
SVCD>> --with-oci8=/shared_ro/users.oracle/11.1.0
SVCD>> I am using gmake 3.80. Can anyone give me a hint as to what I am doing
SVCD>> wrong in this build?
SVCD>> -Vicki Stanfield, RHCE, CISSP
TR> From the error message it would seem the operating system's
TR> getpwnam_r() function is not POSIX compatible.
TR> What system are you compiling on?
TR> --
TR> regards,
TR> Tom
It would seem you need to add -D_POSIX_PTHREAD_SEMANTICS to the cc
flags to get the right function.
--
regards,
Tom
--- End Message ---