[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squirrelmail-devel
Subject:    [SM-DEVEL] [Fwd: PROBLEM SOLVED: Bug Report SM 1.4.6]]
From:       "Tomas Kuliavas" <tokul () users ! sourceforge ! net>
Date:       2005-12-30 19:25:09
Message-ID: 33108.85.206.41.195.1135970709.squirrel () internet ! eik ! lt
[Download RAW message or body]

Forwarding message with solution to devel list.

---------------------------- Original Message ----------------------------
Subject: P R O B L E M   S O L V E D:  Bug Report SM 1.4.6]
From:    "Adam B. Dombi" <postmaster@adenet.ch>
Date:    Fri, December 30, 2005 21:14
To:      "Tomas Kuliavas" <tokul@users.sourceforge.net>
--------------------------------------------------------------------------

Hi Tomas,

the problem is solved:

Ther was two combined problems:

1. With filemon i saw really a propagation delay between NTFS and PHP.
    I added a retry loop to fix this problem. clearstatcache() seems to
    work fine here. (i stays below 4 regularly). Login-Errors and
    'file not found' disappered - regardless of the servers load state.

2. PHP documentation explicitly recomends to flush the cookie file
    when working with frames - otherwise a lock issue may arise.
    I added session_commit(); before session_start() - and also the
    permission-issue seems to be fixed now.

After application of these fixes in global.php of SM, I did not longer
encounter
any script errors in SM.

Here is the complete modified code from global.php:

function sqsession_is_active() {
 // Modified by A. Dombi 12/30/05, www.ADEnet.ch
 $sessid = session_id();

 for( $i=0; $i < 10 && $sessid == ""; $i++ ) {
  // Solves file state cache propagation delay issue IIS 6.0 with Win2003
(cookie file not found)
  clearstatcache();
  usleep( 21000 );    // 5msec should be enough, 21msec should be safe -
even the server stays under heavy load
  $sessid = session_id();
 }

 if ( $sessid == "" ) {
  /* Solves permission denied issue - documented
  on http://de3.php.net/manual/de/function.session-write-close.php */
  session_commit();
  session_start();
 }

}











----- Original Message -----
From: "Tomas Kuliavas" <tokul@users.sourceforge.net>
To: "Adam B. Dombi" <postmaster@adenet.ch>
Cc: <squirrelmail-users@lists.sourceforge.net>
Sent: Friday, December 30, 2005 6:27 PM
Subject: Re: [SM-USERS] [Fwd: Urgent: Bug Report SM 1.4.6]


> Hi,
>
> session_id() does not start session. '$sessid = session_id(); if
> (empty($sessid))' code only makes sure that session is not started before
> calling session_start(). PHP session_start(); function call opens session
> file and sends session cookie. "open(C:\PHP\sess....b, O_RDWR) failed:
> Permission denied (13) in C:\Inetpub\webmail\functions\global.php on line
> 334". Error comes from line 334, not from 332. Recheck line numbers in PHP
> warnings.
>
> php_gettext.dll does not speedup file i/o. It only improves speed of
> SquirrelMail translations.
>
> Try eliminating file system locking issues and store session information
> in database. See http://www.squirrelmail.org/wiki/SessionsInDatabase.
> Preloaded session overrides work transparently in standard SquirrelMail
> setups. Only session.auto_start = 1 and some plugins that mess with
> functions/strings.php file before loading functions/global.php break
> preloaded sessions.
>
> Or disable display of php errors and you won't get 'headers already sent
> by' error.
>
> sleep call between session_id() and session_start() should not change
> anything. You are trying to fix PHP interpreter's issues with your OS or
> your setup by applying hacks to PHP scripts. If PHP breaks on your system
> - fix PHP.
>
> Please keep SquirrelMail support questions on mailing list. If you keep
> conversation in private, I'll automatically forward all my replies to
> public mailing list in order to show progress to others.
>
> --
> Tomas
>
> > Hi Tomas
> >
> >
> > thank you for your quick reply.
> >
> > I will start answering your main question: The error appears in 80% of
> > cases immediatly after login and appears in about 60% of cases in the
left
> > frame and in about 40% in the main window of SM - where normally the mail
> > list will be desplayed. No cleanup will be performed. Sometimes, the
error
> > appears after 2...5 automatic refreshes. (Instead of mails, the errors
are
> > displayed). No third party plugins are used. The only known lock issue
> > with Windows Server 2003 was solved in PHP 4.1.
> >
> > I searched the Internet and found (among similar others) the following
> > statement:
> >
> >
> >
> >> Entry
> >> Warning: Cannot send session cookie - headers already sent by (output
> >> started at /home/fishing/publi Feb 5th, 2002 07:12
> >> Henrik Hansen, robert prescott,
> >> http://www.php.net/manual/en/function.setcookie.php
> >>
> >
> >> quote from the amnual page for setcookie():
> >
> >> setcookie() defines a cookie to be sent along with the rest of the
> >> header information. Cookies must be sent before any other headers are
> >> sent (this is a restriction of cookies, not PHP). This requires you to
> >> place calls to this function before any <html> or <head> tags.
> >
> >
> > So tried to set in PHP.INI
> > session.auto_start = 1
> >
> > and extension=php_gettext.dll ; included for faster File-I/O processing
> >
> >
> > The posted error chain disappeard with this settings  - but other errors
> > comes up, like not found cookie-files, cookie-files with zero-length and
> > others, when I try to open the [Printable version] window - or several
> > login retrys are neccessary now.
> >
> > As I have understood PHP yet, your program logic lacks of recursion:
> > (Please tell me, if I am wrong here!)
> >
> >
> > Having a look on the error causing part of ./functions/global.php in SM:
> >
> >
> > 330: function sqsession_is_active() {
> > 331:
> > 332:    $sessid = session_id();   <--------- This function seems to try
> > placing a session cookie - returns "" if it was not set before
> > 333:    if ( empty( $sessid ) ) {
> > 334:        session_start();      <---------- Here you set the cookie
> > explicitly (again!!!)
> > 335:    }
> > 336: }
> >
> >
> > Due to an intrinsic propagation delay between PHP-$VARIABLE-values and
> > Operating System
> > file handle results - that are asynchronous in Windows - the desired
> > programmatic effect may or may not succeed. If session_id() does not set
> > the cookie, before session_start() is called, the function sucessds.
> > Otherwise it fails. So the probability of success increases with the
> > server load. That may explain the randomness of the error.
> >
> >
> > Since File I/O seems not to be atomic in Windows PHP (!?!) I suggest to
> > use a following logic: (Written in C-like pseudo-code - since Im not
> > familiar with PHP-syntax:)
> >
> > try {
> >
> > $sessid = session_id();
> > usleep( 100000);    // 100msec non busy delay
> > if ( empty( $sessid ) ) {
> > session_start(); }
> >
> >
> > } catch( exception ) {
> >
> >
> > if( indexOf( "already").exception.value > -1) { $sessid = session_id();
> > } else {
> > printf( "Please login again due to error: %s", exception.value );
> exit(1); }
> >  }
> >
> >
> >
> > Best Regards
> >
> >
> > Adam
> >
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "Tomas Kuliavas" <tokul@users.sourceforge.net>
> > To: <squirrelmail-users@lists.sourceforge.net>
> > Cc: <postmaster@adenet.ch>
> > Sent: Thursday, December 29, 2005 9:56 PM
> > Subject: Re: [SM-USERS] [Fwd: Urgent: Bug Report SM 1.4.6]
> >
> >
> >
> >>> ---------------------------- Original Message
> >>> ----------------------------
> >>> Subject: Urgent: Bug Report SM 1.4.6
> >>> From:    "Adam B. Dombi" <postmaster@adenet.ch>
> >>> Date:    Wed, December 28, 2005 6:39 pm
> >>> ----------------------------------------------------------------------
> >>> ----
> >>>
> >>>
> >>>
> >>> Dear Sir or Madam,
> >>>
> >>>
> >>>
> >>> I've tried to set up 3 (three!!) SquirrelMail 1.4.6 Installations,
> >>> that resides on different Windows 2003 Machines - each with full
> >>> Cygwin
> >>> Installation (required for Exim/UW-Mail-Servers and SSHD).
> >>> PHP is 5.1.1 and seems to running fine.
> >>>
> >>>
> >>>
> >>> Unfortunately, SqirrelMail works, but produces (not always, but
> >>> sometimes!!!) the following error-chain. Further, neither the
> >>> operation that triggers the error, nor the time seems both to be
> >>> deterministic. (!!!) (Sometimes after Login, other times after
> >>> clicking a button, another time after third or fourth Refresh, a.o.)
> >>>
> >>> The Error-Output pattern looks always the same:
> >>>
> >>>
> >>>
> >>> Warning: session_start() [function.session-start]:
> >>> open(C:\PHP\sessiondata\sess_e6134f15c778dc92b4ca18c070690a2b, O_RDWR)
> >>>  failed: Permission denied (13) in
> >>> C:\Inetpub\webmail\functions\global.php on line 334
> >>>
> >>>
> >>>
> >>> Warning: session_start() [function.session-start]: Cannot send
> >>> session cookie - headers already sent by (output started at
> >>> C:\Inetpub\webmail\functions\global.php:334) in
> >>> C:\Inetpub\webmail\functions\global.php on line 334
> >>>
> >> ...
> >>
> >>> What I have checked yet:
> >>>
> >>>
> >>>
> >>> - Windows, Cygwin and the Mailservers works fine.
> >>> - PHP.INI seems to be Ok. The error frequency can be slightly reduced
> >>> with setting global_registred = On (See
> >>> http://www.adenet.biz/central-pc.php,
> >>> the file that contains the phpinfo();-Directive) - All right settings
> >>> for all directories and files are Ok - including C:/PHP/sessiondata is
> >>> global accessible. (Everyone can RWC, setuid() a.o.) - The
> >>> session-cookie-error appears with all MSIE-browsers and OS (Win9X,
> >>> XinXP, Win2003)
> >>> - I do not see any difference, wheather I connect via HTTP or HTTPS
> >>> (No
> >>> effect) - I tried with and without german localization (de_DE) (No
> >>> effect) - I tried diffrent settings with conf.pl. (No effect)
> >>>
> >>>
> >>>
> >>> In my opinion, there may be a timing issue, that the PHP-variables
> >>> are not updated within the IIS-processing runtime. I'am not
> >>> specialized in PHP, but perhaps a small delay (normally called a
> >>> terrible hack) or a kind of flush()-directive may solve the problem.
> >>>
> >>> Thank you for looking into the problem.
> >>>
> >>
> >> Error is not in session cookie. Session cookie error happens because
> >> script outputs warning about file open failure.
> >>
> >> open(C:\PHP\sessiondata\sess_e6134f15c778dc92b4ca18c070690a2b, O_RDWR)
> >> failed: Permission denied
> >>
> >>
> >> Issue is specific to some restriction on win2k3 or session file locking
> >>  problems. I think issue is not related to SquirrelMail. Any PHP
> >> session is affected. It might be SquirrelMail issue only if you use some
> >> third party plugins that corrupt session information.
> >>
> >> When does it happen? Does it happen after some cleanup in
> >> c:\php\sessiondata? Or after session timeouts in 24 minutes?
> >>
> >>
> >> Please don't confuse 1.4.6 and 1.4.6rc1 versions. 1.4.6 version is not
> >> released yet.
> >>
> >>
> >> --
> >> Tomas
> >>
> >
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
--
squirrelmail-devel mailing list
Posting Guidelines: http://www.squirrelmail.org/wiki/MailingListPostingGuidelines
List Address: squirrelmail-devel@lists.sourceforge.net
List Archives: http://news.gmane.org/thread.php?group=gmane.mail.squirrelmail.devel
List Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=7139
List Info: https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic