PHP有遇到新问题:
不管使用file_get_contents() 还是 curl 都会遇到这个问题,不过,很像是一个更底层的问题:__lll_lock_wait ,涉及的系统调用为: fmutex
使用file_get_contents() 是的堆栈:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# gstack 29173 #0 0x00000031a640d174 in __lll_lock_wait () from /lib64/libpthread.so.0 #1 0x00000031a6408aca in _L_lock_1034 () from /lib64/libpthread.so.0 #2 0x00000031a640898c in pthread_mutex_lock () from /lib64/libpthread.so.0 #3 0x00002af56a975aaf in _nss_files_gethostbyname2_r () #4 0x00000031a58e9ec8 in gethostbyname2_r@@GLIBC_2.2.5 () #5 0x00000031a58bc523 in gaih_inet () from /lib64/libc.so.6 #6 0x00000031a58bd62a in getaddrinfo () from /lib64/libc.so.6 #7 0x00000000006392ee in php_network_getaddresses () #8 0x0000000000639b65 in php_network_connect_socket_to_host () #9 0x00000000006491b5 in php_tcp_sockop_set_option () #10 0x00002af568606473 in php_openssl_sockop_set_option () #11 0x000000000063cc99 in _php_stream_set_option () #12 0x0000000000647625 in php_stream_xport_connect () #13 0x0000000000647d66 in _php_stream_xport_create () #14 0x000000000060a329 in php_stream_url_wrap_http_ex () #15 0x000000000060cda8 in php_stream_url_wrap_http () #16 0x000000000063ec69 in _php_stream_open_wrapper_ex () #17 0x00000000005d337c in zif_file_get_contents () #18 0x000000000052a607 in phar_file_get_contents () #19 0x00000000006c6f69 in zend_do_fcall_common_helper_SPEC () #20 0x000000000069d78e in execute () #21 0x000000000067a0a9 in zend_execute_scripts () #22 0x0000000000628908 in php_execute_script () #23 0x0000000000701fee in main () |
使用curl时的堆栈:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# gstack 2681 #0 0x00000031a640d174 in __lll_lock_wait () from /lib64/libpthread.so.0 #1 0x00000031a6408aca in _L_lock_1034 () from /lib64/libpthread.so.0 #2 0x00000031a640898c in pthread_mutex_lock () from /lib64/libpthread.so.0 #3 0x00002b582ef07aaf in _nss_files_gethostbyname2_r () #4 0x00000031a58e9ec8 in gethostbyname2_r@@GLIBC_2.2.5 () #5 0x00000031a58bc523 in gaih_inet () from /lib64/libc.so.6 #6 0x00000031a58bd62a in getaddrinfo () from /lib64/libc.so.6 #7 0x00002b582e863b70 in Curl_getaddrinfo () from /usr/lib64/libcurl.so.3 #8 0x00002b582e840e2d in Curl_resolv () from /usr/lib64/libcurl.so.3 #9 0x00002b582e84f7ce in Curl_connect () from /usr/lib64/libcurl.so.3 #10 0x00002b582e85fc1c in ?? () from /usr/lib64/libcurl.so.3 #11 0x00002b582e8600c2 in curl_multi_perform () from /usr/lib64/libcurl.so.3 #12 0x00002b582e61f2f0 in zif_curl_multi_exec () #13 0x00000000006c6f69 in zend_do_fcall_common_helper_SPEC () #14 0x000000000069d78e in execute () #15 0x000000000067a0a9 in zend_execute_scripts () #16 0x0000000000628908 in php_execute_script () #17 0x0000000000701fee in main () |
分析:
应该和域名解析有关
这里都用到了 getaddrinfo() 函数了,于是怀疑问题出现在getaddrinfo() 上,使用gethostbyname() 测试了一下,没有在遇到类似问题,但是后来又在另外机器上发现如下错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
(gdb) bt #0 0x002ed402 in __kernel_vsyscall () #1 0x00681a1e in __lll_mutex_lock_wait () from /lib/libpthread.so.0 #2 0x0067d870 in _L_mutex_lock_85 () from /lib/libpthread.so.0 #3 0x0067d3bd in pthread_mutex_lock () from /lib/libpthread.so.0 #4 0x00b16b22 in _nss_files_gethostbyname_r () from /lib/libnss_files.so.2 #5 0x005e9b57 in gethostbyname_r@@GLIBC_2.1.2 () from /lib/libc.so.6 #6 0x004275e0 in my_gethostbyname_r () from /usr/local/mysql/lib/mysql/libmysqlclient.so.14 #7 0x0043524c in mysql_real_connect () from /usr/local/mysql/lib/mysql/libmysqlclient.so.14 #8 0x00847478 in pdo_mysql_handle_factory (dbh=0xa048034, driver_options=0xa273eb8) at /tmp/php5.3.3_update/php-5.3.3/ext/pdo_mysql/mysql_driver.c:736 #9 0x00fb0266 in zim_PDO_dbh_constructor (ht=4, return_value=0xa272010, return_value_ptr=0x0, this_ptr=0xa273e5c, return_value_used=0) at /data0/software/php-5.3.3/ext/pdo/pdo_dbh.c:378 #10 0x01168d59 in zend_do_fcall_common_helper_SPEC (execute_data=0xa168ef8) at /data0/software/php-5.3.3/Zend/zend_vm_execute.h:316 #11 0x01142ce8 in execute (op_array=0xa2707e8) at /data0/software/php-5.3.3/Zend/zend_vm_execute.h:107 #12 0x011211d7 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /data0/software/php-5.3.3/Zend/zend.c:1194 #13 0x010d0a5e in php_execute_script (primary_file=0xbfdabf20) at /data0/software/php-5.3.3/main/main.c:2261 #14 0x011a07ab in php_handler (r=0xa15a860) at /data0/software/php-5.3.3/sapi/apache2handler/sapi_apache2.c:669 #15 0x08077009 in ap_run_handler (r=0xa15a860) at config.c:157 #16 0x0807a18e in ap_invoke_handler (r=0xa15a860) at config.c:376 #17 0x08085168 in ap_process_request (r=0xa15a860) at http_request.c:282 #18 0x0808235b in ap_process_http_connection (c=0xa103128) at http_core.c:190 #19 0x0807e149 in ap_run_process_connection (c=0xa103128) at connection.c:43 #20 0x0808974d in child_main (child_num_arg=<value optimized out>) at prefork.c:662 #21 0x08089a27 in make_child (s=0x9e54fa0, slot=770) at prefork.c:758 #22 0x0808a380 in ap_mpm_run (_pconf=0x9e530a8, plog=0x9e81160, s=0x9e54fa0) at prefork.c:893 #23 0x080648b5 in main (argc=166006944, argv=0xa100f48) at main.c:740 (gdb) |