Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70125 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50157 invoked from network); 14 Nov 2013 20:30:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Nov 2013 20:30:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.45 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.45 mail-la0-f45.google.com Received: from [209.85.215.45] ([209.85.215.45:51883] helo=mail-la0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 51/D1-40965-7C235825 for ; Thu, 14 Nov 2013 15:30:01 -0500 Received: by mail-la0-f45.google.com with SMTP id eh20so2035897lab.4 for ; Thu, 14 Nov 2013 12:29:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=v+V2uQo/cw/Iz+G7qqZk9Yp6NTMrjD1pl9tTmXxYIAU=; b=d43962HQ1io7LbiTDznRGXV0+tvfTT+Xoy6s0uU1p/cFsUxLBIFXqebSnoCopTIi/x nPxxRRWlAHS1svYX0/LlYeln/6xVMfU/fx4v+RI3gaHXQFCydnrmtuCo5h3ZYAg+0gU/ rwJ7bRLF+yny6/eLRNq4Tfn7x9ZcayqqqLrK+omyCypg6p4WrEm/zaFoXk58XQ9UPdnH X8GSDKUmb20ABuBOUzwrXWtQJ4oZE6oWqPiz9Slgkfr+PIY8xh6kdZUs2u4RHC7UMBPV O4UfJjuH/Z+zL1Xj59ybdv51IK8GFTpQ+gcTqpOZ6Or6i+zBhM/89gV7AyA3UPDvHyJU EZUg== X-Received: by 10.152.116.109 with SMTP id jv13mr1924367lab.30.1384460996191; Thu, 14 Nov 2013 12:29:56 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.154.201 with HTTP; Thu, 14 Nov 2013 12:29:16 -0800 (PST) In-Reply-To: References: Date: Fri, 15 Nov 2013 05:29:16 +0900 X-Google-Sender-Auth: vRKM5QyT058I2SPhG8SK2uxBN4I Message-ID: To: Adam Harvey Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c3675ee2a50d04eb28f10c Subject: Re: [PHP-DEV] Session cache, lock and write From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c3675ee2a50d04eb28f10c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Nov 15, 2013 at 4:59 AM, Adam Harvey wrote: > On 14 November 2013 11:42, Yasuo Ohgaki wrote: > > It can ignore writing session data when session data is not changed. > > It also can remove reading session data by caching as most web > > servers support keep alive. Current session save handlers lock > > session data, but it could be unlocked. > > How do you propose to check if session data was changed? For scalar > types it's pretty easy, but it's possible for objects to alter their > properties (including the ones they're persisting) on __wakeup() =E2=80= =94 I > presume it would effectively be a comparison of what's about to be > written versus what was read initially when it comes time to write the > session? > Session data is serialized. If content has changed, the data is changed. Session could be large so I'm thinking using md5 hash to save memory. Is there any better way? > Session module could have ini settings > > - session.lock =3D On/Off (On by default. Some save handlers already h= ave > > this) > > I've got some concerns on this. I agree that it's a real issue =E2=80=94 = we do > get support issues in ##php caused by people attempting to > concurrently access open file sessions, for instance =E2=80=94 but I'm wo= rried > that this might be a shoot-yourself-in-the-foot option if we're not > careful. I'm thinking mostly of the files handler here: I presume > there would still be locking around initial read and write operations? > For files save handler, it should lock while reading/writing session data at least. Otherwise, there would be reader-writer issue. Thank you for point it out. For other save handlers, author should take into concurrency. Also, as you note, there also isn't any requirement for session > handlers to implement locking right now: if I'm implementing a custom > session handler that doesn't require locking, do I just ignore this > setting if it's not relevant? It seems slightly odd having it in the > session.* namespace if it's really only relevant for files. > Right. Files save handler locks data, but mm save handler does not. User save handler leaves locking to users. > I wonder if a better approach would be to implement an improved files > handler (under a different name) that had options for locking, caching > and the like. Say it was called "awesome_files"[0]; you might have > options like this: > > session.save_handler =3D awesome_files > session.awesome_files.lock =3D On/Off > > I'd love to have a more flexible files handler, but I don't think we > want to overspecialise the session implementation around it. The behavior can be controlled by setting, so I would like to keep single code files/mm/user and other save handlers. I don't mind creating new handlers too much, but I'm concerned for having multiple settings for each save handlers. (e.g. Memcached/MongoDB save handler have it own lock setting. It would be better to have single setting for any save handlers that support it.) Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c3675ee2a50d04eb28f10c--