file_get_contents fails on debian (lenny) server - php

Not sure if it's because it's out of life, but it has been running a website and working until very recently (1 week) - the server hasn't been updated, so am not sure what happened to break the script.
Here's a test script that I've been running (and fails) on the debian server:
<?php
$url = "http://www.andyloughran.co.uk/test.html";
echo $url."\n";
$test = file_get_contents($url);
echo $test;
That should normally return 'ndy test' or something similar.
However, on the debian box it's just timing out.
I've checked and I can wget the file:
<?php
exec('wget http://www.andyloughran.co.uk/test.html');
so am not sure what is it in file_get_contents that isn't working.
I've checked and allow_fopen_url is set to On.
I could do with advice not just on fixing this problem, but working out how to debug the php in order to be able to identify the problem myself in the future.
Curl is not really an option at the moment, as I'm more interested in working out why it's stopped working, rather than an alternative.
Thanks!
Here's the strace error:
open("/dev/urandom", O_RDONLY) = 3
read(3, "\202\231\320\206"..., 4) = 4
close(3) = 0
open("/dev/urandom", O_RDONLY) = 3
read(3, "cdO\37"..., 4) = 4
close(3) = 0
brk(0x9133000) = 0x9133000
open("http_test.php", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7837000
read(3, "<?php\n\nini_set('display_errors', "..., 4096) = 187
_llseek(3, 0, [0], SEEK_SET) = 0
time(NULL) = 1348748612
fstat64(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
fstat64(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7836000
_llseek(0, 0, 0xbfae579c, SEEK_CUR) = -1 ESPIPE (Illegal seek)
fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7835000
_llseek(1, 0, 0xbfae579c, SEEK_CUR) = -1 ESPIPE (Illegal seek)
fstat64(2, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
_llseek(2, 0, 0xbfae579c, SEEK_CUR) = -1 ESPIPE (Illegal seek)
getcwd("/root"..., 4096) = 6
time(NULL) = 1348748612
lstat64("/root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat64("/root/http_test.php", {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfae3798) = -1 ENOTTY (Inappropriate ioctl for device)
read(3, "<?php\n\nini_set('display_errors', "..., 8192) = 187
read(3, ""..., 4096) = 0
read(3, ""..., 8192) = 0
close(3) = 0
munmap(0xb7837000, 4096) = 0
write(1, "http://www.andyloughran.co.uk/tes"..., 40http://www.andyloughran.co.uk/test.html
) = 40
socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = 3
close(3) = 0
socket(PF_NETLINK, SOCK_RAW, 0) = 3
bind(3, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
getsockname(3, {sa_family=AF_NETLINK, pid=28901, groups=00000000}, [12]) = 0
time(NULL) = 1348748612
sendto(3, "\24\0\0\0\26\0\1\3DEdP\0\0\0\0\0\0\0\0"..., 20, 0, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 20
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"0\0\0\0\24\0\2\0DEdP\345p\0\0\2\10\200\376\1\0\0\0\10\0\1\0\177\0\0\1\10"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 156
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"#\0\0\0\24\0\2\0DEdP\345p\0\0\n\200\200\376\1\0\0\0\24\0\1\0\0\0\0\0\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 64
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"\24\0\0\0\3\0\2\0DEdP\345p\0\0\0\0\0\0\1\0\0\0\24\0\1\0\0\0\0\0\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 20
close(3) = 0
stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=95, ...}) = 0
open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=141, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7837000
read(3, "127.0.0.1 localhost.localdomain l"..., 4096) = 141
read(3, ""..., 4096) = 0
close(3) = 0
munmap(0xb7837000, 4096) = 0
open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=141, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7837000
read(3, "127.0.0.1 localhost.localdomain l"..., 4096) = 141
read(3, ""..., 4096) = 0
close(3) = 0
munmap(0xb7837000, 4096) = 0
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=32850, ...}) = 0
mmap2(NULL, 32850, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7820000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libnss_dns.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\220\v\0\0004\0\0\0x"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=17880, ...}) = 0
mmap2(NULL, 20616, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xca5000
mmap2(0xca9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3) = 0xca9000
close(3) = 0
munmap(0xb7820000, 32850) = 0
stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=95, ...}) = 0
gettimeofday({1348748612, 441933}, NULL) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, 28) = 0
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
gettimeofday({1348748612, 442194}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}])
send(3, "2k\1\0\0\1\0\0\0\0\0\0\3www\fandyloughran\2co\2"..., 40, MSG_NOSIGNAL) = 40
poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
ioctl(3, FIONREAD, [102]) = 0
recvfrom(3, "2k\201\200\0\1\0\0\0\1\0\0\3www\fandyloughran\2co\2"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, [16]) = 102
close(3) = 0
gettimeofday({1348748612, 755352}, NULL) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, 28) = 0
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
gettimeofday({1348748612, 755589}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}])
send(3, "\312-\1\0\0\1\0\0\0\0\0\0\3www\fandyloughran\2co\2"..., 56, MSG_NOSIGNAL) = 56
poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
ioctl(3, FIONREAD, [121]) = 0
recvfrom(3, "\312-\201\203\0\1\0\0\0\1\0\0\3www\fandyloughran\2co\2"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, [16]) = 121
close(3) = 0
stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=95, ...}) = 0
gettimeofday({1348748613, 222946}, NULL) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, 28) = 0
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
gettimeofday({1348748613, 223253}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}])
send(3, "\254Q\1\0\0\1\0\0\0\0\0\0\3www\fandyloughran\2co\2"..., 40, MSG_NOSIGNAL) = 40
poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
ioctl(3, FIONREAD, [56]) = 0
recvfrom(3, "\254Q\201\200\0\1\0\1\0\0\0\0\3www\fandyloughran\2co\2"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, [16]) = 56
close(3) = 0
gettimeofday({1348748613, 400717}, NULL) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("85.119.82.243")}, 16) = -1 EINPROGRESS (Operation now in progress)
poll([{fd=3, events=POLLIN|POLLOUT|POLLERR|POLLHUP}], 1, 60000) = 1 ([{fd=3, revents=POLLOUT}])
getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
fcntl64(3, F_SETFL, O_RDWR) = 0
send(3, "GET /test.html HTTP/1.0\r\n"..., 25, MSG_DONTWAIT) = 25
send(3, "Host: www.andyloughran.co.uk\r\n"..., 30, MSG_DONTWAIT) = 30
send(3, "User-Agent: PHP\r\n"..., 17, MSG_DONTWAIT) = 17
send(3, "\r\n"..., 2, MSG_DONTWAIT) = 2
poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 60000^C <unfinished ...>

allow_url_fopen = On in php.ini
Check your DNS, ping www.andyloughran.co.uk
Throw the server out of the nearest window.

I had the same problemn a while ago. It was a DNS problem. Restarting the Webserver helped.

file_get_contents won't work with a URI.
Just try this:
$Stuff = file_get_contents($_SERVER['DOCUMENT_ROOT']."path/filename");
file_get_contents will be happy to "see" a local and accessible path. It will present you the file contents as a kind of "function-thank-you" ;)

Related

How to write the following switch case with less lines of code?

How do I write the following switch case code using less lines? It is taking up a lot of space and lines but I'm unsure what's the better way of writing this.
This is a function where I am calculating the price which I have set in WordPress backend according to the various distance range.
if the distance is less than 300 miles, I have a fixed rate set in the backend for various distance range and if it is greater than 300 miles, then I want to use price per mile. The code does exactly what I need but I feel there can be more compact way of writing this?
Thanks in advance!
Following is the code:
function calculatePrice($distance_value_complete, $fixed_rate, $variable_rate) {
if (floatval($distance_value_complete) < 300 ):
switch (true) {
case floatval($distance_value_complete) < 2:
$vehicle_price1 = $fixed_rate['upto_2_mile'];
break;
case ( (floatval($distance_value_complete) >= 2) && (floatval($distance_value_complete) < 4) ):
$vehicle_price1 = $fixed_rate['from_2_to_4_miles'];
break;
case ( (floatval($distance_value_complete) >= 4) && (floatval($distance_value_complete) < 9) ):
$vehicle_price1 = $fixed_rate['from_4_to_9_miles'];
break;
case ( (floatval($distance_value_complete) >= 9) && (floatval($distance_value_complete) < 14) ):
$vehicle_price1 = $fixed_rate['from_9_to_14_miles'];
break;
case ( (floatval($distance_value_complete) >= 14) && (floatval($distance_value_complete) < 19) ):
$vehicle_price1 = $fixed_rate['from_14_to_19_miles'];
break;
case ( (floatval($distance_value_complete) >= 19) && (floatval($distance_value_complete) < 25) ):
$vehicle_price1 = $fixed_rate['from_19_to_25_miles'];
break;
case ( (floatval($distance_value_complete) >= 25) && (floatval($distance_value_complete) < 29) ):
$vehicle_price1 = $fixed_rate['from_25_to_29_miles'];
break;
case ( (floatval($distance_value_complete) >= 29) && (floatval($distance_value_complete) < 35) ):
$vehicle_price1 = $fixed_rate['from_29_to_35_miles'];
break;
case ( (floatval($distance_value_complete) >= 35) && (floatval($distance_value_complete) < 40) ):
$vehicle_price1 = $fixed_rate['from_35_to_40_miles'];
break;
case ( (floatval($distance_value_complete) >= 40) && (floatval($distance_value_complete) < 45) ):
$vehicle_price1 = $fixed_rate['from_40_to_45_miles'];
break;
case ( (floatval($distance_value_complete) >= 45) && (floatval($distance_value_complete) < 50) ):
$vehicle_price1 = $fixed_rate['from_45_to_50_miles'];
break;
case ( (floatval($distance_value_complete) >= 50) && (floatval($distance_value_complete) < 56) ):
$vehicle_price1 = $fixed_rate['from_50_to_56_miles'];
break;
case ( (floatval($distance_value_complete) >= 56) && (floatval($distance_value_complete) < 62) ):
$vehicle_price1 = $fixed_rate['from_56_to_62_miles'];
break;
case ( (floatval($distance_value_complete) >= 62) && (floatval($distance_value_complete) < 70) ):
$vehicle_price1 = $fixed_rate['from_62_to_70_miles'];
break;
case ( (floatval($distance_value_complete) >= 70) && (floatval($distance_value_complete) < 80) ):
$vehicle_price1 = $fixed_rate['from_70_to_80_miles'];
break;
case ( (floatval($distance_value_complete) >= 80) && (floatval($distance_value_complete) < 90) ):
$vehicle_price1 = $fixed_rate['from_80_to_90_miles'];
break;
case ( (floatval($distance_value_complete) >= 90) && (floatval($distance_value_complete) < 100) ):
$vehicle_price1 = $fixed_rate['from_90_to_100_miles'];
break;
case ( (floatval($distance_value_complete) >= 100) && (floatval($distance_value_complete) < 110) ):
$vehicle_price1 = $fixed_rate['from_100_to_110_miles'];
break;
case ( (floatval($distance_value_complete) >= 110) && (floatval($distance_value_complete) < 120) ):
$vehicle_price1 = $fixed_rate['from_110_to_120_miles'];
break;
case ( (floatval($distance_value_complete) >= 120) && (floatval($distance_value_complete) < 130) ):
$vehicle_price1 = $fixed_rate['from_120_to_130_miles'];
break;
case ( (floatval($distance_value_complete) >= 130) && (floatval($distance_value_complete) < 140) ):
$vehicle_price1 = $fixed_rate['from_130_to_140_miles'];
break;
case ( (floatval($distance_value_complete) >= 140) && (floatval($distance_value_complete) < 150) ):
$vehicle_price1 = $fixed_rate['from_140_to_150_miles'];
break;
case ( (floatval($distance_value_complete) >= 150) && (floatval($distance_value_complete) < 160) ):
$vehicle_price1 = $fixed_rate['from_150_to_160_miles'];
break;
case ( (floatval($distance_value_complete) >= 160) && (floatval($distance_value_complete) < 170) ):
$vehicle_price1 = $fixed_rate['from_160_to_170_miles'];
break;
case ( (floatval($distance_value_complete) >= 170) && (floatval($distance_value_complete) < 180) ):
$vehicle_price1 = $fixed_rate['from_170_to_180_miles'];
break;
case ( (floatval($distance_value_complete) >= 180) && (floatval($distance_value_complete) < 190) ):
$vehicle_price1 = $fixed_rate['from_180_to_190_miles'];
break;
case ( (floatval($distance_value_complete) >= 190) && (floatval($distance_value_complete) < 200) ):
$vehicle_price1 = $fixed_rate['from_190_to_200_miles'];
break;
case ( (floatval($distance_value_complete) >= 200) && (floatval($distance_value_complete) < 210) ):
$vehicle_price1 = $fixed_rate['from_200_to_210_miles'];
break;
case ( (floatval($distance_value_complete) >= 210) && (floatval($distance_value_complete) < 220) ):
$vehicle_price1 = $fixed_rate['from_210_to_220_miles'];
break;
case ( (floatval($distance_value_complete) >= 220) && (floatval($distance_value_complete) < 230) ):
$vehicle_price1 = $fixed_rate['from_220_to_230_miles'];
break;
case ( (floatval($distance_value_complete) >= 230) && (floatval($distance_value_complete) < 240) ):
$vehicle_price1 = $fixed_rate['from_230_to_240_miles'];
break;
case ( (floatval($distance_value_complete) >= 240) && (floatval($distance_value_complete) < 250) ):
$vehicle_price1 = $fixed_rate['from_240_to_250_miles'];
break;
case ( (floatval($distance_value_complete) >= 250) && (floatval($distance_value_complete) < 260) ):
$vehicle_price1 = $fixed_rate['from_250_to_260_miles'];
break;
case ( (floatval($distance_value_complete) >= 260) && (floatval($distance_value_complete) < 270) ):
$vehicle_price1 = $fixed_rate['from_260_to_270_miles'];
break;
case ( (floatval($distance_value_complete) >= 270) && (floatval($distance_value_complete) < 280) ):
$vehicle_price1 = $fixed_rate['from_270_to_280_miles'];
break;
case ( (floatval($distance_value_complete) >= 280) && (floatval($distance_value_complete) < 290) ):
$vehicle_price1 = $fixed_rate['from_280_to_290_miles'];
break;
case ( (floatval($distance_value_complete) >= 290) && (floatval($distance_value_complete) < 300) ):
$vehicle_price1 = $fixed_rate['from_290_to_300_miles'];
break;
}
else:
switch (true) {
case floatval($distance_value_complete) >= 300:
$vehicle_price1 = floatval($distance_value_complete) * $variable_rate['from_300_and_above'];
break;
}
endif;
return $vehicle_price1;
}
Simply rather not use a switch in such cases, where you have to deal with complex comparison expressions:
<?php
function calculatePrice($distance_value_complete, $fixed_rate, $variable_rate)
{
$distance_completed = floatval($distance_value_complete);
static $minimum_distance = 2;
static $maximum_distance = 300;
if ($distance_completed >= $maximum_distance) {
return $distance_completed * $variable_rate['from_' . $maximum_distance . '_and_above'];;
}
if ($distance_completed < $minimum_distance) {
return $fixed_rate['upto_' . $minimum_distance . '_mile'];
}
static $fixed_distances = array(
4, 9, 14, 19, 25, 29, 35, 40, 45, 50, 56, 62, 70, 80, 90, 100,
110, 120, 130, 140, 150, 160, 170, 180, 190, 200,
210, 220, 230, 240, 250, 260, 270, 280, 290, 300
);
$last_distance = $minimum_distance;
foreach ($fixed_distances as $distance) {
if ($distance_completed < $distance) {
return $fixed_rate['from_' . $last_distance . '_to_' . $distance . '_miles'];
}
$last_distance = $distance;
}
// This should never happen, unless you modify $fixed_distances and forget to change the early return conditions
throw new \Exception(sprintf('Distance %f out of range', $distance_completed));
}
Test results:
0 = upto_2_mile
1 = upto_2_mile
2 = from_2_to_4_miles
3 = from_2_to_4_miles
4 = from_4_to_9_miles
5 = from_4_to_9_miles
6 = from_4_to_9_miles
7 = from_4_to_9_miles
8 = from_4_to_9_miles
9 = from_9_to_14_miles
10 = from_9_to_14_miles
11 = from_9_to_14_miles
12 = from_9_to_14_miles
13 = from_9_to_14_miles
14 = from_14_to_19_miles
15 = from_14_to_19_miles
16 = from_14_to_19_miles
17 = from_14_to_19_miles
18 = from_14_to_19_miles
19 = from_19_to_25_miles
20 = from_19_to_25_miles
21 = from_19_to_25_miles
22 = from_19_to_25_miles
23 = from_19_to_25_miles
24 = from_19_to_25_miles
25 = from_25_to_29_miles
26 = from_25_to_29_miles
27 = from_25_to_29_miles
28 = from_25_to_29_miles
29 = from_29_to_35_miles
30 = from_29_to_35_miles
31 = from_29_to_35_miles
32 = from_29_to_35_miles
33 = from_29_to_35_miles
34 = from_29_to_35_miles
35 = from_35_to_40_miles
36 = from_35_to_40_miles
37 = from_35_to_40_miles
38 = from_35_to_40_miles
39 = from_35_to_40_miles
40 = from_40_to_45_miles
41 = from_40_to_45_miles
42 = from_40_to_45_miles
43 = from_40_to_45_miles
44 = from_40_to_45_miles
45 = from_45_to_50_miles
46 = from_45_to_50_miles
47 = from_45_to_50_miles
48 = from_45_to_50_miles
49 = from_45_to_50_miles
50 = from_50_to_56_miles
51 = from_50_to_56_miles
52 = from_50_to_56_miles
53 = from_50_to_56_miles
54 = from_50_to_56_miles
55 = from_50_to_56_miles
56 = from_56_to_62_miles
57 = from_56_to_62_miles
58 = from_56_to_62_miles
59 = from_56_to_62_miles
60 = from_56_to_62_miles
61 = from_56_to_62_miles
62 = from_62_to_70_miles
63 = from_62_to_70_miles
64 = from_62_to_70_miles
65 = from_62_to_70_miles
66 = from_62_to_70_miles
67 = from_62_to_70_miles
68 = from_62_to_70_miles
69 = from_62_to_70_miles
70 = from_70_to_80_miles
71 = from_70_to_80_miles
72 = from_70_to_80_miles
73 = from_70_to_80_miles
74 = from_70_to_80_miles
75 = from_70_to_80_miles
76 = from_70_to_80_miles
77 = from_70_to_80_miles
78 = from_70_to_80_miles
79 = from_70_to_80_miles
80 = from_80_to_90_miles
81 = from_80_to_90_miles
82 = from_80_to_90_miles
83 = from_80_to_90_miles
84 = from_80_to_90_miles
85 = from_80_to_90_miles
86 = from_80_to_90_miles
87 = from_80_to_90_miles
88 = from_80_to_90_miles
89 = from_80_to_90_miles
90 = from_90_to_100_miles
91 = from_90_to_100_miles
92 = from_90_to_100_miles
93 = from_90_to_100_miles
94 = from_90_to_100_miles
95 = from_90_to_100_miles
96 = from_90_to_100_miles
97 = from_90_to_100_miles
98 = from_90_to_100_miles
99 = from_90_to_100_miles
100 = from_100_to_110_miles
101 = from_100_to_110_miles
102 = from_100_to_110_miles
103 = from_100_to_110_miles
104 = from_100_to_110_miles
105 = from_100_to_110_miles
106 = from_100_to_110_miles
107 = from_100_to_110_miles
108 = from_100_to_110_miles
109 = from_100_to_110_miles
110 = from_110_to_120_miles
111 = from_110_to_120_miles
112 = from_110_to_120_miles
113 = from_110_to_120_miles
114 = from_110_to_120_miles
115 = from_110_to_120_miles
116 = from_110_to_120_miles
117 = from_110_to_120_miles
118 = from_110_to_120_miles
119 = from_110_to_120_miles
120 = from_120_to_130_miles
121 = from_120_to_130_miles
122 = from_120_to_130_miles
123 = from_120_to_130_miles
124 = from_120_to_130_miles
125 = from_120_to_130_miles
126 = from_120_to_130_miles
127 = from_120_to_130_miles
128 = from_120_to_130_miles
129 = from_120_to_130_miles
130 = from_130_to_140_miles
131 = from_130_to_140_miles
132 = from_130_to_140_miles
133 = from_130_to_140_miles
134 = from_130_to_140_miles
135 = from_130_to_140_miles
136 = from_130_to_140_miles
137 = from_130_to_140_miles
138 = from_130_to_140_miles
139 = from_130_to_140_miles
140 = from_140_to_150_miles
141 = from_140_to_150_miles
142 = from_140_to_150_miles
143 = from_140_to_150_miles
144 = from_140_to_150_miles
145 = from_140_to_150_miles
146 = from_140_to_150_miles
147 = from_140_to_150_miles
148 = from_140_to_150_miles
149 = from_140_to_150_miles
150 = from_150_to_160_miles
151 = from_150_to_160_miles
152 = from_150_to_160_miles
153 = from_150_to_160_miles
154 = from_150_to_160_miles
155 = from_150_to_160_miles
156 = from_150_to_160_miles
157 = from_150_to_160_miles
158 = from_150_to_160_miles
159 = from_150_to_160_miles
160 = from_160_to_170_miles
161 = from_160_to_170_miles
162 = from_160_to_170_miles
163 = from_160_to_170_miles
164 = from_160_to_170_miles
165 = from_160_to_170_miles
166 = from_160_to_170_miles
167 = from_160_to_170_miles
168 = from_160_to_170_miles
169 = from_160_to_170_miles
170 = from_170_to_180_miles
171 = from_170_to_180_miles
172 = from_170_to_180_miles
173 = from_170_to_180_miles
174 = from_170_to_180_miles
175 = from_170_to_180_miles
176 = from_170_to_180_miles
177 = from_170_to_180_miles
178 = from_170_to_180_miles
179 = from_170_to_180_miles
180 = from_180_to_190_miles
181 = from_180_to_190_miles
182 = from_180_to_190_miles
183 = from_180_to_190_miles
184 = from_180_to_190_miles
185 = from_180_to_190_miles
186 = from_180_to_190_miles
187 = from_180_to_190_miles
188 = from_180_to_190_miles
189 = from_180_to_190_miles
190 = from_190_to_200_miles
191 = from_190_to_200_miles
192 = from_190_to_200_miles
193 = from_190_to_200_miles
194 = from_190_to_200_miles
195 = from_190_to_200_miles
196 = from_190_to_200_miles
197 = from_190_to_200_miles
198 = from_190_to_200_miles
199 = from_190_to_200_miles
200 = from_200_to_210_miles
201 = from_200_to_210_miles
202 = from_200_to_210_miles
203 = from_200_to_210_miles
204 = from_200_to_210_miles
205 = from_200_to_210_miles
206 = from_200_to_210_miles
207 = from_200_to_210_miles
208 = from_200_to_210_miles
209 = from_200_to_210_miles
210 = from_210_to_220_miles
211 = from_210_to_220_miles
212 = from_210_to_220_miles
213 = from_210_to_220_miles
214 = from_210_to_220_miles
215 = from_210_to_220_miles
216 = from_210_to_220_miles
217 = from_210_to_220_miles
218 = from_210_to_220_miles
219 = from_210_to_220_miles
220 = from_220_to_230_miles
221 = from_220_to_230_miles
222 = from_220_to_230_miles
223 = from_220_to_230_miles
224 = from_220_to_230_miles
225 = from_220_to_230_miles
226 = from_220_to_230_miles
227 = from_220_to_230_miles
228 = from_220_to_230_miles
229 = from_220_to_230_miles
230 = from_230_to_240_miles
231 = from_230_to_240_miles
232 = from_230_to_240_miles
233 = from_230_to_240_miles
234 = from_230_to_240_miles
235 = from_230_to_240_miles
236 = from_230_to_240_miles
237 = from_230_to_240_miles
238 = from_230_to_240_miles
239 = from_230_to_240_miles
240 = from_240_to_250_miles
241 = from_240_to_250_miles
242 = from_240_to_250_miles
243 = from_240_to_250_miles
244 = from_240_to_250_miles
245 = from_240_to_250_miles
246 = from_240_to_250_miles
247 = from_240_to_250_miles
248 = from_240_to_250_miles
249 = from_240_to_250_miles
250 = from_250_to_260_miles
251 = from_250_to_260_miles
252 = from_250_to_260_miles
253 = from_250_to_260_miles
254 = from_250_to_260_miles
255 = from_250_to_260_miles
256 = from_250_to_260_miles
257 = from_250_to_260_miles
258 = from_250_to_260_miles
259 = from_250_to_260_miles
260 = from_260_to_270_miles
261 = from_260_to_270_miles
262 = from_260_to_270_miles
263 = from_260_to_270_miles
264 = from_260_to_270_miles
265 = from_260_to_270_miles
266 = from_260_to_270_miles
267 = from_260_to_270_miles
268 = from_260_to_270_miles
269 = from_260_to_270_miles
270 = from_270_to_280_miles
271 = from_270_to_280_miles
272 = from_270_to_280_miles
273 = from_270_to_280_miles
274 = from_270_to_280_miles
275 = from_270_to_280_miles
276 = from_270_to_280_miles
277 = from_270_to_280_miles
278 = from_270_to_280_miles
279 = from_270_to_280_miles
280 = from_280_to_290_miles
281 = from_280_to_290_miles
282 = from_280_to_290_miles
283 = from_280_to_290_miles
284 = from_280_to_290_miles
285 = from_280_to_290_miles
286 = from_280_to_290_miles
287 = from_280_to_290_miles
288 = from_280_to_290_miles
289 = from_280_to_290_miles
290 = from_290_to_300_miles
291 = from_290_to_300_miles
292 = from_290_to_300_miles
293 = from_290_to_300_miles
294 = from_290_to_300_miles
295 = from_290_to_300_miles
296 = from_290_to_300_miles
297 = from_290_to_300_miles
298 = from_290_to_300_miles
299 = from_290_to_300_miles
300 = from_300_and_above
301 = from_300_and_above
302 = from_300_and_above
303 = from_300_and_above
304 = from_300_and_above
305 = from_300_and_above
306 = from_300_and_above
307 = from_300_and_above
308 = from_300_and_above
309 = from_300_and_above
310 = from_300_and_above
311 = from_300_and_above
312 = from_300_and_above
313 = from_300_and_above
314 = from_300_and_above
315 = from_300_and_above
316 = from_300_and_above
317 = from_300_and_above
318 = from_300_and_above
319 = from_300_and_above
320 = from_300_and_above
321 = from_300_and_above
322 = from_300_and_above
323 = from_300_and_above
324 = from_300_and_above
325 = from_300_and_above
326 = from_300_and_above
327 = from_300_and_above
328 = from_300_and_above
329 = from_300_and_above
330 = from_300_and_above
331 = from_300_and_above
332 = from_300_and_above
333 = from_300_and_above
334 = from_300_and_above
335 = from_300_and_above
336 = from_300_and_above
337 = from_300_and_above
338 = from_300_and_above
339 = from_300_and_above
340 = from_300_and_above
341 = from_300_and_above
342 = from_300_and_above
343 = from_300_and_above
344 = from_300_and_above
345 = from_300_and_above
346 = from_300_and_above
347 = from_300_and_above
348 = from_300_and_above
349 = from_300_and_above
350 = from_300_and_above```
Since you have a rate name depending on a single int value I would create an array that maps all the available rates, then pass it to a function with the value you are checking, something like this ( map is not complete, php7.2 required )
$conditionMap = [
[
'value' => 'upto_2_mile',
'condition' => '<2'
],
[
'value' => 'from_2_to_4_miles',
'condition' => '<4'
],
[
'value' => 'from_4_to_9_miles',
'condition' => '<9'
],
[
'value' => 'from_9_to_14_miles',
'condition' => '<14'
],
[
'value' => 'from_14_to_19_miles',
'condition' => '<19'
],
[
'value' => 'from_19_to_25_miles',
'condition' => '<25'
],
[
'value' => 'from_25_to_29_miles',
'condition' => '<29'
]
];
function getRate(int $value, array $conditionMap) : string {
$rate = 'Not found';
foreach ($conditionMap as $condition) {
$phpString = sprintf("return %s %s;", $value, $condition['condition']);
$evaluation = eval($phpString);
if($evaluation) {
$rate = $condition['value'];
break;
}
}
return $rate;
}
// TEST
for($i = 0; $i<=30; $i++) {
var_dump(sprintf("With value %s: %s", $i, getRate($i, $conditionMap)));
}
If you run this script you should obtain the result below
string(25) "With value 0: upto_2_mile"
string(25) "With value 1: upto_2_mile"
string(31) "With value 2: from_2_to_4_miles"
string(31) "With value 3: from_2_to_4_miles"
string(31) "With value 4: from_4_to_9_miles"
string(31) "With value 5: from_4_to_9_miles"
string(31) "With value 6: from_4_to_9_miles"
string(31) "With value 7: from_4_to_9_miles"
string(31) "With value 8: from_4_to_9_miles"
string(32) "With value 9: from_9_to_14_miles"
string(33) "With value 10: from_9_to_14_miles"
string(33) "With value 11: from_9_to_14_miles"
string(33) "With value 12: from_9_to_14_miles"
string(33) "With value 13: from_9_to_14_miles"
string(34) "With value 14: from_14_to_19_miles"
string(34) "With value 15: from_14_to_19_miles"
string(34) "With value 16: from_14_to_19_miles"
string(34) "With value 17: from_14_to_19_miles"
string(34) "With value 18: from_14_to_19_miles"
string(34) "With value 19: from_19_to_25_miles"
string(34) "With value 20: from_19_to_25_miles"
string(34) "With value 21: from_19_to_25_miles"
string(34) "With value 22: from_19_to_25_miles"
string(34) "With value 23: from_19_to_25_miles"
string(34) "With value 24: from_19_to_25_miles"
string(34) "With value 25: from_25_to_29_miles"
string(34) "With value 26: from_25_to_29_miles"
string(34) "With value 27: from_25_to_29_miles"
string(34) "With value 28: from_25_to_29_miles"
string(24) "With value 29: Not found"
string(24) "With value 30: Not found"

PHP uses rdkafka to produce messages that hang for 100ms

when i use rdkafka produce message in php, The program will hang 100ms
My code reference is this website https://switchcaseblog.wordpress.com/2017/01/20/how-to-get-php-and-kafka-to-play-nicely-and-not-do-it-slowly/
php version: PHP 7.0.13
rdkafka version:
version => 3.0.5
build date => Dec 23 2017 20:38:03
librdkafka version (runtime) => 0.11.3
produce config:
'request.required.acks' => 0,
'message.timeout.ms' => 300,
'queue.buffering.max.ms' => 1,
'message.max.bytes' => 3000000,
'socket.keepalive.enable' => true
so i strace the php process, The following code:
21:05:07.395746 fcntl(4, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
21:05:07.395799 fcntl(4, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
21:05:07.395828 munmap(0x7f9036659000, 1106) = 0
21:05:07.395853 close(5) = 0
21:05:07.396263 futex(0x7f902be5e580, FUTEX_WAKE_PRIVATE, 2147483647) = 0
21:05:07.396484 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
21:05:07.396531 mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f900641a000
21:05:07.396577 mprotect(0x7f900641a000, 4096, PROT_NONE) = 0
21:05:07.396614 clone(child_stack=0x7f9006e19e90, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f9006e1a9d0, tls=0x7f9006e1a700, child_tidptr=0x7f9006e1a9d0) = 22018
21:05:07.396696 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], ~[KILL STOP RTMIN RT_1], 8) = 0
21:05:07.396764 pipe([5, 6]) = 0
21:05:07.396833 fcntl(5, F_GETFL) = 0 (flags O_RDONLY)
21:05:07.396858 fcntl(5, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
21:05:07.396880 fcntl(6, F_GETFL) = 0x1 (flags O_WRONLY)
21:05:07.396902 fcntl(6, F_SETFL, O_WRONLY|O_NONBLOCK) = 0
21:05:07.396926 mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f9005a19000
21:05:07.396962 mprotect(0x7f9005a19000, 4096, PROT_NONE) = 0
21:05:07.397013 clone(child_stack=0x7f9006418e90, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f90064199d0, tls=0x7f9006419700, child_tidptr=0x7f90064199d0) = 22019
21:05:07.397107 rt_sigprocmask(SIG_SETMASK, ~[KILL STOP RTMIN RT_1], NULL, 8) = 0
21:05:07.397137 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
21:05:07.397191 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
21:05:07.397219 pipe([7, 8]) = 0
21:05:07.397245 fcntl(7, F_GETFL) = 0 (flags O_RDONLY)
21:05:07.397268 fcntl(7, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
21:05:07.397290 fcntl(8, F_GETFL) = 0x1 (flags O_WRONLY)
21:05:07.397311 fcntl(8, F_SETFL, O_WRONLY|O_NONBLOCK) = 0
21:05:07.397335 mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f9005018000
21:05:07.397372 mprotect(0x7f9005018000, 4096, PROT_NONE) = 0
21:05:07.397421 clone(child_stack=0x7f9005a17e90, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f9005a189d0, tls=0x7f9005a18700, child_tidptr=0x7f9005a189d0) = 22020
21:05:07.397469 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
21:05:07.397507 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
21:05:07.397534 pipe([9, 10]) = 0
21:05:07.397560 fcntl(9, F_GETFL) = 0 (flags O_RDONLY)
21:05:07.397582 fcntl(9, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
21:05:07.397604 fcntl(10, F_GETFL) = 0x1 (flags O_WRONLY)
21:05:07.397626 fcntl(10, F_SETFL, O_WRONLY|O_NONBLOCK) = 0
21:05:07.397650 mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f9004616000
21:05:07.397687 mprotect(0x7f9004616000, 4096, PROT_NONE) = 0
21:05:07.397733 clone(child_stack=0x7f9005015e90, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f90050169d0, tls=0x7f9005016700, child_tidptr=0x7f90050169d0) = 22021
21:05:07.397781 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
21:05:07.398147 write(1, "\350\200\227\346\227\2666\346\257\253\347\247\222", 13耗时6毫秒) = 13
21:05:07.398203 write(1, "\n", 1
) = 1
21:05:07.398318 close(2) = 0
21:05:07.398347 close(1) = 0
21:05:07.398372 munmap(0x7f903665a000, 4096) = 0
21:05:07.398433 close(0) = 0
21:05:07.398456 munmap(0x7f903665b000, 4096) = 0
21:05:07.398490 futex(0x212e19c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, {1514034307, 399482000}, ffffffff) = -1 ETIMEDOUT (Connection timed out)
21:05:07.399575 futex(0x212e170, FUTEX_WAKE_PRIVATE, 1) = 0
21:05:07.399602 futex(0x212e19c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 3, {1514034307, 400596000}, ffffffff) = -1 ETIMEDOUT (Connection timed out)
21:05:07.400684 futex(0x212e170, FUTEX_WAKE_PRIVATE, 1) = 0
21:05:07.400710 futex(0x212e19c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 5, {1514034307, 401704000}, ffffffff) = 0
21:05:07.401209 futex(0x212e170, FUTEX_WAKE_PRIVATE, 1) = 0
21:05:07.401268 futex(0x212e25c, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x212e258, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
21:05:07.401316 futex(0x7f9006e1a9d0, FUTEX_WAIT, 22018, NULL) = 0
21:05:07.502855 munmap(0x7f8ff75ff000, 10489856) = 0
21:05:07.503046 fcntl(4, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
21:05:07.503295 munmap(0x7f9006e1b000, 67108864) = 0
21:05:07.503417 close(4) = 0
21:05:07.503530 munmap(0x7f902be63000, 2182736) = 0
21:05:07.503580 munmap(0x7f902bbac000, 2844152) = 0
21:05:07.503662 munmap(0x7f902c078000, 2186600) = 0
21:05:07.503776 munmap(0x7f902c954000, 2129096) = 0
21:05:07.503811 munmap(0x7f902c740000, 2176864) = 0
21:05:07.503842 munmap(0x7f902c503000, 2343352) = 0
21:05:07.503891 munmap(0x7f902c28e000, 2574912) = 0
21:05:07.503939 munmap(0x3e5ea00000, 2109528) = 0
21:05:07.503988 munmap(0x7f902cb5c000, 2111520) = 0
21:05:07.504095 munmap(0x7f902cd60000, 2108464) = 0
21:05:07.504151 munmap(0x7f902cf63000, 2129280) = 0
21:05:07.504242 munmap(0x7f902d7ec000, 2155960) = 0
21:05:07.504277 munmap(0x7f902d581000, 2533392) = 0
21:05:07.504332 munmap(0x7f902d9fb000, 2163080) = 0
21:05:07.504421 munmap(0x7f900ae1b000, 2113976) = 0
21:05:07.504479 munmap(0x7f900b020000, 2113944) = 0
21:05:07.504524 munmap(0x7f900b225000, 2126432) = 0
21:05:07.504560 munmap(0x7f900b42d000, 2113976) = 0
21:05:07.504601 munmap(0x7f900b9a6000, 2117960) = 0
21:05:07.504630 munmap(0x7f900b632000, 3618944) = 0
21:05:07.504668 futex(0x7f902dedc040, FUTEX_WAKE_PRIVATE, 2147483647) = 0
21:05:07.504712 munmap(0x7f902dc0c000, 2956168) = 0
21:05:07.504857 munmap(0x7f902e8b1000, 2514584) = 0
21:05:07.504918 munmap(0x7f902e58d000, 3293152) = 0
21:05:07.504966 munmap(0x7f902e0eb000, 4856016) = 0
21:05:07.505086 munmap(0x7f902dede000, 2150272) = 0
21:05:07.505151 munmap(0x7f902ed31000, 2144104) = 0
21:05:07.505194 munmap(0x7f902eb17000, 2202200) = 0
strace -c php scritp.php
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
95.15 0.001000 59 17 3 futex
4.85 0.000051 0 742 615 open
0.00 0.000000 0 97 read
0.00 0.000000 0 9 write
0.00 0.000000 0 129 close
0.00 0.000000 0 77 49 stat
0.00 0.000000 0 148 fstat
0.00 0.000000 0 57 1 lstat
0.00 0.000000 0 2 poll
0.00 0.000000 0 8 3 lseek
0.00 0.000000 0 259 1 mmap
0.00 0.000000 0 127 mprotect
Futex takes about 100ms, how to solve it
who can help me? thanks
谁能帮忙解答下,哈哈

Unable to send mail through sendmail using neither terminal nor PHP linux

I have installed sendmail on my linux machine(Linux Mint) and I followed : how to configure sendmail on ubuntu on Stack Overflow.
I got no errors till the end and I successfully restarted the sendmail.
To check I tried using telnet. Here's the terminal print
hackathon mail # telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 hackathon ESMTP Sendmail 8.14.4/8.14.4/Debian-4.1ubuntu1; Sat, 7 Mar 2015 14:59:26 +0530; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
HELO server
250 hackathon Hello localhost [127.0.0.1], pleased to meet you
MAIL from : localhostmailbox#gmail.com
250 2.1.0 localhostmailbox#gmail.com... Sender ok
RCPT to : naveenchaudhary2010#hotmail.com
250 2.1.5 naveenchaudhary2010#hotmail.com... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
Subject : Test mail
.
250 2.0.0 t279TQBC024546 Message accepted for delivery
quit
221 2.0.0 hackathon closing connection
Connection closed by foreign host.
Though telnet says message accepted to deliver, but I see no mail neither in Inbox or Junk of recepient, nor in the sent folder of sender.
I tried using php also.
php.ini settings :
; For Win32 only.
; http://php.net/smtp
SMTP=smtp.gmail.com
; http://php.net/smtp-port
smtp_port=587
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = localhostmailbox#gmail.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =
Here's the PHP code :
<?php
$to = "naveenchaudhary2010#hotmail.com";
$subject = "test";
$body = "This is a text";
$headers = 'From : "localhost" localhostmailbox#gmail.com';
$return_val = mail($to,$subject,$body,$headers);
if($return_val)
echo "sent";
else
echo "Failure :".$return_val;
?>
This is also sending the error.I tried printing the return value of mail() which is null.
Please help, this is my 7th hour wasted since morning and still no success till now.
EDIT
Dump of strace
2558 <... time resumed> NULL) = 1425817211
13250 <... read resumed> "127.0.0.1\tlocalhost\n127.0.1.1\thackathon\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes"..., 4096) = 224
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], <unfinished ...>
13250 close(4 <unfinished ...>
2558 <... rt_sigprocmask resumed> [ALRM], 8) = 0
13250 <... close resumed> ) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0} <unfinished ...>
13250 munmap(0xb77a6000, 4096) = 0
13250 fcntl64(8, F_GETFL) = 0x2 (flags O_RDWR)
13250 dup(8) = 4
13250 fcntl64(4, F_GETFL) = 0x2 (flags O_RDWR)
13250 getsockname(8, {sa_family=AF_INET, sin_port=htons(25), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=224, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "127.0.0.1\tlocalhost\n127.0.1.1\thackathon\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes"..., 4096) = 224
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 getegid32() = 126
13250 setgroups32(1, [126]) = 0
13250 ioctl(8, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0xbf855618) = -1 ENOTTY (Inappropriate ioctl for device)
13250 getpeername(8, {sa_family=AF_INET, sin_port=htons(51828), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
13250 open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)\n# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN\nnameserver 127.0.1.1\nsearch 8.8.8.8\n", 4096) = 187
13250 read(5, "", 4096) = 0
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
13250 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=224, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "127.0.0.1\tlocalhost\n127.0.1.1\thackathon\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes"..., 4096) = 224
13250 read(5, "", 4096) = 0
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 getsockname(8, {sa_family=AF_INET, sin_port=htons(25), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 open("/etc/services", O_RDONLY|O_CLOEXEC) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=19558, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "# Network services, Internet style\n#\n# Note that it is presently the policy of IANA to assign a single well-known\n# port number for both TCP and UDP; hence, officially ports have two entries\n# even if"..., 4096) = 4096
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
13250 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
13250 time(NULL) = 1425817211
13250 rt_sigaction(SIGALRM, {0x80e56d0, [], SA_RESTART}, {0x80e56d0, [], SA_RESTART}, 8) = 0
13250 alarm(5) = 0
13250 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
13250 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 5
13250 bind(5, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
13250 connect(5, {sa_family=AF_INET, sin_port=htons(113), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused)
13250 close(5) = 0
13250 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
13250 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
13250 kill(13250, SIGALRM) = 0
13250 --- SIGALRM {si_signo=SIGALRM, si_code=SI_USER, si_pid=13250, si_uid=0} ---
13250 alarm(0) = 5
13250 time(NULL) = 1425817211
13250 time(NULL) = 1425817211
13250 sigreturn() (mask []) = 0
13250 getsockopt(8, SOL_IP, IP_OPTIONS, "", [0]) = 0
13250 time(NULL) = 1425817211
13250 time(NULL) = 1425817211
13250 open("/proc/loadavg", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
13250 read(5, "0.56 0.24 0.22 1/414 13250\n", 1024) = 27
13250 close(5) = 0
13250 time(NULL) = 1425817211
13250 stat64("/etc/mail/access.db", {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 lstat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13250 geteuid32() = 0
13250 lstat64("/etc", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
13250 geteuid32() = 0
13250 lstat64("/etc/mail", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, ...}) = 0
13250 geteuid32() = 0
13250 open("/etc/mail/access.db", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(5, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 time(NULL) = 1425817211
13250 open("/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) = 6
13250 read(6, "0-1\n", 8192) = 4
13250 close(6) = 0
13250 stat64("/etc/mail/access.db", {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 open("/etc/mail/access.db", O_RDONLY|O_LARGEFILE) = 6
13250 fcntl64(6, F_GETFD) = 0
13250 fcntl64(6, F_SETFD, FD_CLOEXEC) = 0
13250 read(6, "\0\0\0\0\1\0\0\0\0\0\0\0a\25\6\0\t\0\0\0\0\20\0\0\0\10\0\0\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0_\v\20\0\6\10\0\0\321\326B\375\245^\0\0\0\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\27\20\0\0\321\215h^\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 512) = 512
13250 open("DB_CONFIG", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
13250 stat64("/var/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
13250 time(NULL) = 1425817211
13250 clock_gettime(CLOCK_REALTIME, {1425817211, 773188844}) = 0
13250 clock_gettime(CLOCK_REALTIME, {1425817211, 773264483}) = 0
13250 open("/etc/mail/access.db", O_RDONLY|O_LARGEFILE) = 7
13250 fcntl64(7, F_GETFD) = 0
13250 fcntl64(7, F_SETFD, FD_CLOEXEC) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 pread64(7, "\0\0\0\0\1\0\0\0\0\0\0\0a\25\6\0\t\0\0\0\0\20\0\0\0\10\0\0\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0_\v\20\0\6\10\0\0\321\326B\375\245^\0\0\0\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\27\20\0\0\321\215h^\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 0) = 4096
13250 close(5) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 pread64(7, "\0\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\22\0C\17\0\r\353\17\351\17\324\17\322\17\306\17\300\17\260\17\251\17\235\17\226\17\212\17\203\17r\17l\17W\17U\17J\17C\17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 4096) = 4096
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 pread64(7, "\0\0\0\0\1\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\34\0\363\16\0\r\361\17\357\17\333\17\331\17\315\17\312\17\273\17\271\17\245\17\243\17\227\17\224\17\204\17}\17k\17e\17V\17T\17#\17>\0172\17-\17%\17\36\17\22\17\v\17\372\16\363\16\0\0\0\0\0\0\0\20\0\0\321\215h^\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 8192) = 4096
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 open("/etc/hosts.allow", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=425, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "sendmail: all\n# /etc/hosts.allow: list of hosts that are allowed to access the system.\n# See the manual pages hosts_access(5) and hosts_options(5).\n#\n# Example: ALL: LOCAL #some_n"..., 4096) = 425
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 dup2(4, 1) = 1
13250 time(NULL) = 1425817211
13250 stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=265, ...}) = 0
13250 time(NULL) = 1425817211
13250 stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=265, ...}) = 0
13250 open("/proc/loadavg", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
13250 read(5, "0.56 0.24 0.22 1/414 13250\n", 1024) = 27
13250 close(5) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 getpeername(8, {sa_family=AF_INET, sin_port=htons(51828), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 getsockname(8, {sa_family=AF_INET, sin_port=htons(25), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(4, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
13250 fcntl64(8, F_GETFL) = 0x2 (flags O_RDWR)
13250 fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
13250 fstat64(8, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
13250 select(9, [8], NULL, NULL, {0, 0}) = 0 (Timeout)
13250 write(4, "220 hackathon ESMTP Sendmail 8.14.4/8.14.4/Debian-4.1ubuntu1; Sun, 8 Mar 2015 17:50:11 +0530; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]\r\n", 165) = 165
13250 read(8, 0x8bd35d8, 4096) = -1 EAGAIN (Resource temporarily unavailable)
13250 gettimeofday({1425817211, 849076}, NULL) = 0
13250 select(9, [8], NULL, [8], {300, 0} <unfinished ...>
2558 <... select resumed> ) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817216
2558 time(NULL) = 1425817216
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.60 0.26 0.23 1/414 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817216
2558 time(NULL) = 1425817216
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.60 0.26 0.23 1/414 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817216
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0} <unfinished ...>
13250 <... select resumed> ) = 1 (in [8], left {292, 398402})
13250 gettimeofday({1425817219, 450896}, NULL) = 0
13250 read(8, "HELO server\r\n", 4096) = 13
13250 fcntl64(4, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
13250 fcntl64(4, F_SETFL, O_RDWR) = 0
13250 fcntl64(8, F_GETFL) = 0x2 (flags O_RDWR)
13250 fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
13250 select(9, [8], NULL, NULL, {0, 0}) = 0 (Timeout)
13250 write(4, "250 hackathon Hello localhost [127.0.0.1], pleased to meet you\r\n", 64) = 64
13250 read(8, 0x8bd35d8, 4096) = -1 EAGAIN (Resource temporarily unavailable)
13250 gettimeofday({1425817219, 451708}, NULL) = 0
13250 select(9, [8], NULL, [8], {300, 0} <unfinished ...>
2558 <... select resumed> ) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817221
2558 time(NULL) = 1425817221
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.55 0.25 0.23 1/414 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817221
2558 time(NULL) = 1425817221
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.55 0.25 0.23 1/414 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817221
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0}) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817226
2558 time(NULL) = 1425817226
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.51 0.25 0.22 4/413 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817226
2558 time(NULL) = 1425817226
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.51 0.25 0.22 4/413 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817226
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0}) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817231
2558 time(NULL) = 1425817231
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.55 0.26 0.23 1/412 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817231
2558 time(NULL) = 1425817231
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.55 0.26 0.23 1/412 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817231
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0}) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817236
2558 time(NULL) = 1425817236
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.50 0.26 0.23 1/412 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817236
2558 time(NULL) = 1425817236
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.50 0.26 0.23 1/412 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817236
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0}) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817241
2558 time(NULL) = 1425817241
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.46 0.25 0.23 1/411 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817241
2558 time(NULL) = 1425817241
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.46 0.25 0.23 1/411 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817241
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0} <unfinished ...>
13250 <... select resumed> ) = 1 (in [8], left {275, 280004})
13250 gettimeofday({1425817244, 171941}, NULL) = 0
13250 read(8, "MAIL from :localhostmailbox#gmail.com\r\n", 4096) = 39
13250 time(NULL) = 1425817244
13250 time(NULL) = 1425817244
13250 stat64("/etc/mail/service.switch", {st_mode=S_IFREG|0644, st_size=149, ...}) = 0
13250 lstat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13250 geteuid32() = 0
13250 lstat64("/etc", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
13250 geteuid32() = 0
13250 lstat64("/etc/mail", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, ...}) = 0
13250 geteuid32() = 0
13250 open("/etc/mail/service.switch", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=149, ...}) = 0
13250 fcntl64(5, F_GETFL) = 0 (flags O_RDONLY)
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=149, ...}) = 0
13250 read(5, "# /etc/mail/nsswitch.conf\n#\n# This is the format that sendmail expects (no colon after the service)\n# \npasswd\t\tfiles\nhosts\t\tfiles dns\naliases\t\tfiles\n", 4096) = 149
13250 read(5, "", 4096) = 0
13250 close(5) = 0
13250 open("/etc/hosts", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=224, ...}) = 0
13250 read(5, "127.0.0.1\tlocalhost\n127.0.1.1\thackathon\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes"..., 4096) = 224
13250 read(5, "", 4096) = 0
13250 close(5) = 0
13250 stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
13250 socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 5
13250 connect(5, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.1.1")}, 16) = 0
13250 gettimeofday({1425817244, 174299}, NULL) = 0
13250 poll([{fd=5, events=POLLOUT}], 1, 0) = 1 ([{fd=5, revents=POLLOUT}])
13250 send(5, "*\311\1\0\0\1\0\0\0\0\0\0\5gmail\3com\0\0\34\0\1", 27, MSG_NOSIGNAL) = 27
13250 poll([{fd=5, events=POLLIN}], 1, 5000) = 1 ([{fd=5, revents=POLLIN}])
13250 recvfrom(5, "*\311\201\200\0\1\0\1\0\4\0\4\5gmail\3com\0\0\34\0\1\300\f\0\34\0\1\0\0\0002\0\20$\4h\0#\2\10\2\0\0\0\0\0\0\20\25\300\f\0\2\0\1\0\0\17\0\0\r\3ns4\6google\300\22\300\f\0\2\0\1\0\0\17\0\0\6\3ns3\300G\300\f\0\2\0\1\0\0\17\0\0\6\3ns2\300G\300\f\0\2\0\1\0\0\17\0\0\6\3ns1\300G\300\200\0\1\0\1\0\0\2B\0\4\330\357 \n\300n\0\1\0\1\0\0\2B\0\4\330\357\"\n\300\\\0\1\0\1\0\0\2B\0\4\330\357$\n\300C\0\1\0\1\0\0\2B\0\4\330\357&\n", 8192, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.1.1")}, [16]) = 198
13250 close(5) = 0
13250 time(NULL) = 1425817244
13250 time(NULL) = 1425817244
13250 fcntl64(4, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
13250 fcntl64(4, F_SETFL, O_RDWR) = 0
13250 fcntl64(8, F_GETFL) = 0x2 (flags O_RDWR)
13250 fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
13250 select(9, [8], NULL, NULL, {0, 0}) = 0 (Timeout)
13250 write(4, "250 2.1.0 localhostmailbox#gmail.com... Sender ok\r\n", 51) = 51
13250 read(8, 0x8bd35d8, 4096) = -1 EAGAIN (Resource temporarily unavailable)

Why my Drupal is intermittently slow? Stracing shows a lot of repeated sendto calls

One of the Drupal sites I manage occasionally loads very slowly. If I strace PHP-FPM while this happens, I see a lot of poll/recvfrom/sendto system calls with what appears to be the same content:
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24589, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\207\2\0\0\3INSERT INTO menu_router\n "..., 651, MSG_DONTWAIT, NULL, 0) = 651
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24578, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\\\2\0\0\3INSERT INTO menu_router\n "..., 608, MSG_DONTWAIT, NULL, 0) = 608
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24567, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "T\2\0\0\3INSERT INTO menu_router\n "..., 600, MSG_DONTWAIT, NULL, 0) = 600
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24556, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "2\2\0\0\3INSERT INTO menu_router\n "..., 566, MSG_DONTWAIT, NULL, 0) = 566
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24545, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\37\2\0\0\3INSERT INTO menu_router\n "..., 547, MSG_DONTWAIT, NULL, 0) = 547
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24534, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\r\2\0\0\3INSERT INTO menu_router\n "..., 529, MSG_DONTWAIT, NULL, 0) = 529
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24523, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "B\2\0\0\3INSERT INTO menu_router\n "..., 582, MSG_DONTWAIT, NULL, 0) = 582
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24512, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, ":\2\0\0\3INSERT INTO menu_router\n "..., 574, MSG_DONTWAIT, NULL, 0) = 574
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24501, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "(\2\0\0\3INSERT INTO menu_router\n "..., 556, MSG_DONTWAIT, NULL, 0) = 556
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24490, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "4\2\0\0\3INSERT INTO menu_router\n "..., 568, MSG_DONTWAIT, NULL, 0) = 568
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24479, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "(\2\0\0\3INSERT INTO menu_router\n "..., 556, MSG_DONTWAIT, NULL, 0) = 556
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24468, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, " \2\0\0\3INSERT INTO menu_router\n "..., 548, MSG_DONTWAIT, NULL, 0) = 548
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24457, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, ",\2\0\0\3INSERT INTO menu_router\n "..., 560, MSG_DONTWAIT, NULL, 0) = 560
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24446, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\30\2\0\0\3INSERT INTO menu_router\n "..., 540, MSG_DONTWAIT, NULL, 0) = 540
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24435, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "6\2\0\0\3INSERT INTO menu_router\n "..., 570, MSG_DONTWAIT, NULL, 0) = 570
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24424, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\253\2\0\0\3INSERT INTO menu_router\n "..., 687, MSG_DONTWAIT, NULL, 0) = 687
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24413, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\206\6\0\0\3INSERT INTO menu_router\n "..., 1674, MSG_DONTWAIT, NULL, 0) = 1674
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24402, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "!\2\0\0\3INSERT INTO menu_router\n "..., 549, MSG_DONTWAIT, NULL, 0) = 549
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24391, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "3\2\0\0\3INSERT INTO menu_router\n "..., 567, MSG_DONTWAIT, NULL, 0) = 567
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24380, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "$\2\0\0\3INSERT INTO menu_router\n "..., 552, MSG_DONTWAIT, NULL, 0) = 552
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24369, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "*\2\0\0\3INSERT INTO menu_router\n "..., 558, MSG_DONTWAIT, NULL, 0) = 558
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24358, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "9\2\0\0\3INSERT INTO menu_router\n "..., 573, MSG_DONTWAIT, NULL, 0) = 573
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24347, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "*\2\0\0\3INSERT INTO menu_router\n "..., 558, MSG_DONTWAIT, NULL, 0) = 558
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24336, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "-\2\0\0\3INSERT INTO menu_router\n "..., 561, MSG_DONTWAIT, NULL, 0) = 561
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24325, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\33\2\0\0\3INSERT INTO menu_router\n "..., 543, MSG_DONTWAIT, NULL, 0) = 543
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24314, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\6\2\0\0\3INSERT INTO menu_router\n "..., 522, MSG_DONTWAIT, NULL, 0) = 522
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928 <unfinished ...>
All of timeouts are reasonable so I don't think that's the issue. Since the server configuration is identical to my other sites, I think it's a code issue, but I'm not sure what in PHP can cause this.
It's Drupal 6.28 and PHP 5.5.20.
Your recvfrom/sendto are just MySQL queries, so it's nothing wrong with it.
Inserting into menu_router table indicates that Drupal is rebuilding this table (see: menu_rebuild() API);
This function will clear and populate the {menu_router} table, add entries
to {menu_links} for new router items, and then remove stale items from
{menu_links}.
This is either triggered by menu_rebuild_needed variable (if set), or by external modules (such as Devel), or simply in your theme settings you've enabled 'Rebuild theme registry on every page.' option.
Usually rebuilding menu is one-time process on clear cache. If above suggestions won't help, you need to check which module/code exactly calling menu_rebuild() (in includes/menu.inc) by placing there breakpoint and printing backtrace.
One way of doing (if Devel is present), is using dd(), e.g.
function menu_rebuild() {
dd(debug_backtrace()); // Adding temporary debug line.
Then check your /tmp/drupal_debug.txt file for backtrace details.

failed (104: Connection reset by peer)

We are using the php5-fpm and nginx.
# nginx -v
nginx version: nginx/1.1.19
*
# php -v
PHP 5.3.27-1~dotdeb.0 with Suhosin-Patch (cli) (built: Jul 25 2013 19:30:39)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
*
Got the following error,
2013/08/21 20:00:20 [error] 12740#0: *46 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.17.7.12, server: fe.test.local, request: "GET /search?gender=female&ageFrom=20&ageTo=32&religionId=&casteId=&countryId=&heightFrom=&heightTo=&profileImageStatus=%28y+p%29&search=Search HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "fe.test.local", referrer: "http://fe.test.local/
PHP5-FPM configuration,
# grep ^[^\;] /etc/php5/fpm/php-fpm.conf
[global]
pid = /var/run/php5-fpm.pid
error_log = /var/log/php5-fpm.log
log_level = notice
process_control_timeout = 30
include=/etc/php5/fpm/pool.d/*.conf
# grep ^[^\;] /etc/php5/fpm/pool.d/www.conf
[www]
listen = /var/run/php5-fpm.sock
listen.backlog = -1
user = www-data
group = www-data
pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 6
rlimit_files = 131072
rlimit_core = unlimited
chdir = /
Nginx fascgi configuration part
location ~ \.php$
{
fastcgi_index index.php;
include fastcgi_params;
fastcgi_connect_timeout 120;
fastcgi_send_timeout 600;
fastcgi_read_timeout 600;
fastcgi_buffers 8 256k;
fastcgi_buffer_size 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
client_max_body_size 20M;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
# strace -f -s 8000 -p 12761
Process 12761 attached - interrupt to quit
epoll_wait(9, {}, 1, 944) = 0
epoll_wait(9, {}, 1, 1000) = 0
epoll_wait(9, {}, 1, 1000) = 0
epoll_wait(9, 269f530, 1, 1000) = -1 EINTR (Interrupted system call)
--- SIGCHLD (Child exited) # 0 (0) ---
write(6, "C", 1) = 1
rt_sigreturn(0x6) = -1 EINTR (Interrupted system call)
epoll_wait(9, {{EPOLLIN, {u32=15427040, u64=15427040}}}, 1, 122) = 1
read(4, "C", 1) = 1
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 127}], WNOHANG|WSTOPPED, NULL) = 12826
write(3, "[21-Aug-2013 19:33:37] WARNING: [pool www] child 12826 exited with code 127 after 275.844033 seconds from start\n", 112) = 112
clone(Process 12832 attached (waiting for parent)
Process 12832 resumed (parent 12761 ready)
child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fd7a31cfa10) = 12832
[pid 12832] set_robust_list(0x7fd7a31cfa20, 0x18) = 0
[pid 12832] dup2(1, 2) = 2
[pid 12832] close(3) = 0
[pid 12832] dup2(7, 0) = 0
[pid 12832] geteuid() = 0
[pid 12832] setrlimit(RLIMIT_NOFILE, {rlim_cur=128*1024, rlim_max=128*1024}) = 0
[pid 12832] setrlimit(RLIMIT_CORE, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
[pid 12832] chdir("/") = 0
[pid 12832] setgid(33) = 0
[pid 12832] open("/proc/sys/kernel/ngroups_max", O_RDONLY) = 3
[pid 12832] read(3, "65536\n", 31) = 6
[pid 12832] close(3) = 0
[pid 12832] open("/etc/group", O_RDONLY|O_CLOEXEC) = 3
[pid 12832] lseek(3, 0, SEEK_CUR) = 0
[pid 12832] fstat(3, {st_mode=S_IFREG|0644, st_size=777, ...}) = 0
[pid 12832] mmap(NULL, 777, PROT_READ, MAP_SHARED, 3, 0) = 0x7fd7a31c1000
[pid 12832] lseek(3, 777, SEEK_SET) = 777
[pid 12832] fstat(3, {st_mode=S_IFREG|0644, st_size=777, ...}) = 0
[pid 12832] munmap(0x7fd7a31c1000, 777) = 0
[pid 12832] close(3) = 0
[pid 12832] setgroups(1, [33]) = 0
[pid 12832] setuid(33) = 0
[pid 12832] prctl(PR_SET_DUMPABLE, 1) = 0
[pid 12832] close(4) = 0
[pid 12832] close(6) = 0
[pid 12832] rt_sigaction(SIGTERM, {SIG_DFL, [], SA_RESTORER, 0x7fd7a02234a0}, NULL, 8) = 0
[pid 12832] rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7fd7a02234a0}, NULL, 8) = 0
[pid 12832] rt_sigaction(SIGUSR1, {SIG_DFL, [], SA_RESTORER, 0x7fd7a02234a0}, NULL, 8) = 0
[pid 12832] rt_sigaction(SIGUSR2, {SIG_DFL, [], SA_RESTORER, 0x7fd7a02234a0}, NULL, 8) = 0
[pid 12832] rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER, 0x7fd7a02234a0}, NULL, 8) = 0
[pid 12832] rt_sigaction(SIGQUIT, {0x7633f0, [], SA_RESTORER|SA_RESTART, 0x7fd7a02234a0}, NULL, 8) = 0
[pid 12832] close(7) = 0
[pid 12832] accept(0,
[pid 12761] write(3, "[21-Aug-2013 19:33:37] NOTICE: [pool www] child 12832 started\n", 62) = 62
[pid 12761] wait4(-1, 0x7fff07258a7c, WNOHANG|WSTOPPED, NULL) = 0
[pid 12761] read(4, 0x7fff07258b5f, 1) = -1 EAGAIN (Resource temporarily unavailable)
[pid 12761] epoll_wait(9, {}, 1, 108) = 0
[pid 12761] epoll_wait(9, {}, 1, 1000) = 0
[pid 12761] epoll_wait(9, 269f530, 1, 1000) = -1 EINTR (Interrupted system call)
[pid 12761] --- SIGCHLD (Child exited) # 0 (0) ---
[pid 12761] write(6, "C", 1) = 1
[pid 12761] rt_sigreturn(0x6) = -1 EINTR (Interrupted system call)
[pid 12761] epoll_wait(9, {{EPOLLIN, {u32=15427040, u64=15427040}}}, 1, 769) = 1
[pid 12761] read(4, "C", 1) = 1
[pid 12761] wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 127}], WNOHANG|WSTOPPED, NULL) = 12830
[pid 12761] write(3, "[21-Aug-2013 19:33:39] WARNING: [pool www] child 12830 exited with code 127 after 10.053632 seconds from start\n", 111) = 111
[pid 12761] clone(Process 12833 attached
child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fd7a31cfa10) = 12833
[pid 12761] write(3, "[21-Aug-2013 19:33:39] NOTICE: [pool www] child 12833 started\n", 62) = 62
[pid 12761] wait4(-1, 0x7fff07258a7c, WNOHANG|WSTOPPED, NULL) = 0
[pid 12761] read(4, 0x7fff07258b5f, 1) = -1 EAGAIN (Resource temporarily unavailable)
[pid 12761] epoll_wait(9,
[pid 12833] set_robust_list(0x7fd7a31cfa20, 0x18) = 0
[pid 12833] dup2(1, 2) = 2
[pid 12833] close(3) = 0
[pid 12833] dup2(7, 0) = 0
[pid 12833] geteuid() = 0
[pid 12833] setrlimit(RLIMIT_NOFILE, {rlim_cur=128*1024, rlim_max=128*1024}) = 0
[pid 12833] setrlimit(RLIMIT_CORE, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
[pid 12833] chdir("/") = 0
[pid 12833] setgid(33) = 0
[pid 12833] open("/proc/sys/kernel/ngroups_max", O_RDONLY) = 3
[pid 12833] read(3, "65536\n", 31) = 6
[pid 12833] close(3) = 0
[pid 12833] open("/etc/group", O_RDONLY|O_CLOEXEC) = 3
[pid 12833] lseek(3, 0, SEEK_CUR) = 0
[pid 12833] fstat(3, {st_mode=S_IFREG|0644, st_size=777, ...}) = 0
[pid 12833] mmap(NULL, 777, PROT_READ, MAP_SHARED, 3, 0) = 0x7fd7a31c1000
[pid 12833] lseek(3, 777, SEEK_SET) = 777
[pid 12833] fstat(3, {st_mode=S_IFREG|0644, st_size=777, ...}) = 0
[pid 12833] munmap(0x7fd7a31c1000, 777) = 0
[pid 12833] close(3) = 0
[pid 12833] setgroups(1, [33]) = 0
[pid 12833] setuid(33) = 0
[pid 12833] prctl(PR_SET_DUMPABLE, 1) = 0
[pid 12833] close(4) = 0
[pid 12833] close(6) = 0
[pid 12833] rt_sigaction(SIGTERM, {SIG_DFL, [], SA_RESTORER, 0x7fd7a02234a0}, NULL, 8) = 0
[pid 12833] rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7fd7a02234a0}, NULL, 8) = 0
[pid 12833] rt_sigaction(SIGUSR1, {SIG_DFL, [], SA_RESTORER, 0x7fd7a02234a0}, NULL, 8) = 0
[pid 12833] rt_sigaction(SIGUSR2, {SIG_DFL, [], SA_RESTORER, 0x7fd7a02234a0}, NULL, 8) = 0
[pid 12833] rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER, 0x7fd7a02234a0}, NULL, 8) = 0
[pid 12833] rt_sigaction(SIGQUIT, {0x7633f0, [], SA_RESTORER|SA_RESTART, 0x7fd7a02234a0}, NULL, 8) = 0
[pid 12833] close(7) = 0
[pid 12833] accept(0,
[pid 12761] {}, 1, 766) = 0
[pid 12761] epoll_wait(9, {}, 1, 1000) = 0`enter code here`
[pid 12761] epoll_wait(9, {}, 1, 1000) = 0
The above nginx error indicate that issue is related to the fastcgi(php-fpm).
After enabling the "catch_workers_output" on /etc/php5/fpm/pool.d/www.conf
Got the relevant error on php5-fpm.log. Now understand that issue is related to AMQP module.
[21-Aug-2013 23:32:57] WARNING: [pool www] child 16091 said into stderr: "php-fpm: pool www: symbol lookup error: /usr/lib/php5/20090626/amqp.so: undefined symbol: amqp_open_socket"
Issue has been fixed afterrecompiled and install amqp module

Categories