|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-02-03 12:36 UTC] cmb@php.net
-Status: Open
+Status: Wont fix
-Assigned To:
+Assigned To: cmb
[2021-02-03 12:36 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 17:00:01 2025 UTC |
Description: ------------ [root@localhost examples]# /usr/local/php-zts/bin/php SQLWorker.php localhost root "" test "select now()" PHP Warning: mysql_connect(): No such file or directory in /root/pthreads/pthreads-2.0.10/examples/SQLWorker.php on line 42 Segmentation fault (core dumped) But, SharingResources.php works well. More: [root@localhost examples]# /usr/local/php-zts/bin/php -v PHP 5.6.11 (cli) (built: Jul 15 2015 04:45:02) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies phpinfo() PHP Version => 5.6.11 System => Linux localhost.localdomain 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 Build Date => Jul 15 2015 04:38:47 Configure Command => './configure' '--prefix=/usr/local/php-zts' '--with-config-file-path=/usr/local/php-zts/etc' '--enable-fpm' '--with-fpm-user=apache' '--with-fpm-group=apa che' '--enable-mbstring' '--enable-xml' '--with-mysql' '--with-mysqli' '--with-iconv-dir' '--enable-maintainer-zts' '--enable-zip' '--enable-pcntl' '--enable-sockets' Server API => Command Line Interface Virtual Directory Support => enabled Test script: --------------- <?php class SQLQuery extends Stackable { public function __construct($sql) { $this->sql = $sql; } public function run() { /** included in 0.0.37 is access to the real worker object for stackables **/ if ($this->worker->isReady()) { $result = mysql_query($this->sql, $this->worker->getConnection()); if ($result) { while(($row = mysql_fetch_assoc($result))){ /** $this->rows[]=$row; segfaults */ /** you could array_merge, but the fastest thing to do is what I'm doing here */ /** even when the segfault is fixed this will still be the best thing to do as writing to the object scope will always cause locking */ /** but the method scope isn't shared, just like the global scope **/ $rows[]=$row; } mysql_free_result($result); } else printf("%s got no result\n", __CLASS__); } else printf("%s not ready\n", $this->worker->getConnection()); $this->rows = $rows; $this->notify(); } protected function getResults() { return $this->rows; } } class SQLWorker extends Worker { public $mysql; public function __construct($host, $user, $pass, $db) { $this->host = $host; $this->user = $user; $this->pass = $pass; $this->db = $db; $this->ready = false; $this->name = null; } public function run() { $this->setName(sprintf("%s (%lu)", __CLASS__, $this->getThreadId())); if (($this->mysql = mysql_connect($this->host, $this->user, $this->pass))) { $this->ready = (boolean) mysql_select_db($this->db, $this->mysql); } } public function getConnection(){ return $this->mysql; } protected function isReady($flag = null) { if (is_null($flag)) { return $this->ready; } else $this->ready = $flag; } public function setName($name) { $this->name = $name;} public function getName() { return $this->name; } } if (count($argv) == 6) { $sql = new SQLWorker($argv[1], $argv[2], $argv[3], $argv[4]); $sql->start(); $query = new SQLQuery($argv[5]); $sql->stack($query); $query->wait(); print_r($query->getResults()); } else printf("usage: {$argv[0]} hostname username password database query\n"); ?> Expected result: ---------------- 1111 Actual result: -------------- 0000