Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44982 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24687 invoked from network); 15 Jul 2009 20:10:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jul 2009 20:10:00 -0000 Authentication-Results: pb1.pair.com header.from=thomas@koch.ro; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=thomas@koch.ro; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain koch.ro from 93.90.184.107 cause and error) X-PHP-List-Original-Sender: thomas@koch.ro X-Host-Fingerprint: 93.90.184.107 koch.ro Linux 2.6 Received: from [93.90.184.107] ([93.90.184.107:53168] helo=ve825703057.providerbox.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F6/68-18024-5973E5A4 for ; Wed, 15 Jul 2009 16:09:59 -0400 Received: from 156-30.79-83.cust.bluewin.ch ([83.79.30.156] helo=jona.localnet) by ve825703057.providerbox.net with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1MRAnY-0005Mv-C1; Wed, 15 Jul 2009 22:09:52 +0200 Reply-To: thomas@koch.ro To: internals@lists.php.net Date: Wed, 15 Jul 2009 22:09:44 +0200 User-Agent: KMail/1.11.4 (Linux/2.6.29-1-amd64; KDE/4.2.4; x86_64; ; ) Cc: Johannes =?iso-8859-1?q?Schl=FCter?= , gearman References: <200907141928.20591.thomas@koch.ro> <1247597559.31771.24.camel@goldfinger.johannes.nop> <200907151948.35958.thomas@koch.ro> In-Reply-To: <200907151948.35958.thomas@koch.ro> MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200907152209.44982.thomas@koch.ro> Subject: Re: [PHP-DEV] Gearman worker: smart_str trouble From: thomas@koch.ro (Thomas Koch) I defeated the segfaults! Now the monster in the next level is named smart_str. I have a smart_str to buffer the SAPI output. On the first request no output comes out. Second request gives the correct output. All following request return some bytes of garbarge. The relevant code parts: typedef struct _gearman_worker_request_struct { smart_str result; } gearman_worker_request_struct; static void gearman_worker_globals_ctor(gearman_worker_request_struct *request TSRMLS_DC) { memset( &request->result, 0, sizeof(smart_str) ); } static void gearman_worker_globals_dtor(gearman_worker_request_struct *request TSRMLS_DC) { smart_str_free(&GWR(result)); } static int php_embed_ub_write(const char *str, uint str_length TSRMLS_DC) { smart_str_appendl(&GWR(result), str, (int) str_length); return str_length; } char *php_gearman_worker_get_result(TSRMLS_D) { char *result; smart_str_0(&GWR(result)); result = strndup( GWR(result).c, GWR(result).len ); return result; } and in the sapi startup: ts_allocate_id(&gearman_worker_id, sizeof(gearman_worker_request_struct), (ts_allocate_ctor) gearman_worker_globals_ctor, (ts_allocate_dtor) gearman_worker_globals_dtor); Thanks for your patience!!! Thomas Koch, http://www.koch.ro