[Ur] redirect breaks channels

Adam Chlipala adamc at csail.mit.edu
Fri Dec 27 13:12:12 EST 2013


On 12/26/2013 12:54 PM, Sergey Mironov wrote:
> Still, I think API should somehow highlight the fact
> that channel is not an autonomous object, but a reference to a
> client's slot. (according to the implementation, it is no more than a
> tuple (channel_id,client_id)) Maybe, changing names would be enough
> here. For me, recv associates with a function that could receive data
> from any socket, which is not the case here. Another idea - add some
> error-checking to the recv's code. It may raise an exception if user
> passes it a channel which has client_id /= current_client_id.
>    

I've added the error checking you suggested: an exception will be raised 
on trying to read another client's channel.  In the process, I also 
fixed some issues with proper association of page requests with clients, 
so that the error should occur less often.  For now, I'm not convinced 
that the API itself should change, considering the explanation in the 
manual.

>>> [1] Begin error: cannot start a transaction within a
>>> transaction<br/>Expunge blocked by error: Error running SQL BEGIN
>>>        
>>
>> Higher-order bits: I think this indicates an Ur/Web bug; it should not be
>> possible to write Ur/Web code that does anything explicit with transactions.
>> It's possible that something about the non-atomic transactions of SQLite
>> (which I warn about in the manual) is responsible somehow, but it doesn't
>> seem likely to me.
>>      

I managed to reproduce the problem, which only manifested for me after a 
fatal error in a page handler.  It was an issue related to a 
benchmark-inspired optimization I added recently, and not anything 
specific to a database system or anything that only shows up under high 
concurrency or weird disk configuration.  It should be fixed now; let me 
know if it recurs.

> Looks like latest urweb can't compile channel2.ur anymore. It says
>
> dev:[grwlf at greyblade:~/proj/urweb/tests]$ urweb -dbms sqlite channel2
> :0:0: (to 0:0) Function Channel2/monitor needed for both a link and a form
> Make sure that the signature of the containing module hides any form handlers.
> :0:0: (to 0:0) Function Channel2/put needed for both a link and a form
> Make sure that the signature of the containing module hides any form handlers.
>
> Channel2.ur doesn't use any forms so it is probably a regression, is it?
>    

I'm surprised if a previous Ur/Web version compiled this source code 
without complaint.  The behavior you're seeing is expected, for reasons 
explained in Section 10 of the manual.

Executive summary: any properly typed function exported from a program's 
main module is treated as accessible via GET requests.  However, RFCs 
say that GET requests shouldn't cause side effects.  One fix is to add a 
.urs file that only exposes the entry points you really intended.  (As a 
bonus, this should also enable you to remove [: transaction page] 
annotations in the .ur file!)



More information about the Ur mailing list