|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-10-21 03:56 UTC] sander@php.net
[2002-11-10 18:23 UTC] sniper@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 16:00:01 2025 UTC |
I use Apache 1.3.26 and postgresql 7.2.2 I wished to test ignore_user_abort() and connection_aborted(). I can not use correctly this 2 fonctions. The result is always the same. The application is the famous example of the bank accounts and the money transfers. I consider a table named "DEAL" where each transaction is saved. Each tuple has an id number as key. My script php follows this steps : ignore_user_abort(0|1) Compute the key -> v BEGIN WORK UPDATE the first bank account with v (credit) sleep(300) UPDATE the second bank account with v+1 (debit) COMMIT WORK While the sleep, the client uses the STOP button on his browser and stops the connection. For these tests, I follow two steps : 1/ the client execute the first request but stops the connection while the sleep instruction. 2/ with pgaccess, I read the content of DEAL after a while -------------------- TEST 1 -------------------- ignore_user_abort(0) Compute the key -> v BEGIN WORK UPDATE the first bank account with v as key (credit) sleep(300) ------> INTERRUPT !!!! UPDATE the second bank account with v+1 as key (debit) COMMIT WORK Result : after a while (timeout ?), the request is executed. Therefore the script is executed totally. Otherwise, this timeout is also a problem because if the client make again his request, it fails beacause the found key is the same as the previous and one update fails (but this problem comes from the first problem) ! -------------------- TEST 2 -------------------- The same by removing BEGIN and COMMIT. The result is the same, even if the "timeout" is more important. -------------------- TEST 3 and 4 -------------------- The tests 3 and 4 reproduce the test 1 and 2 by using ignore_user_abort(1). The results are absolutely the same ! -------------------- TEST 5 and 6 -------------------- The tests 5 and 6 reproduce the test 1 and 2 by using ROLLBACK if ( connection_aborted() ) { ROLLBACK WORK; exit } is added after the sleep. The results are absolutely the same again ! It seem connection_aborted does not return correct result.