Comet and CTHandler>>basicTerminate

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Comet and CTHandler>>basicTerminate

Lautaro Fernández
Hello,
I was wondering why each time a CTHandler is created the method basicTerminate is called.
I tried digging into some messages but without success.

Could someone (maybe Lukas) explain to me why does it need to do the following lines(*) when a cometRequest is "delivered"?

(*)CTHandler>>basicTerminate
    thisContext swapSender: nil.
    Processor activeProcess terminate


Thanks!
Lautaro Fernández.

--
Luke LAut SkyFernadezWalker

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Comet and CTHandler>>basicTerminate

Lukas Renggli
> Could someone (maybe Lukas) explain to me why does it need to do the
> following lines(*) when a cometRequest is "delivered"?
>
> (*)CTHandler>>basicTerminate
>     thisContext swapSender: nil.
>     Processor activeProcess terminate

This avoids that the stack to is unwound that that ensure blocks are executed.

If that would not be done, then Seaside would generate an (empty)
response and pass this response back to the web server. The web server
would serialize this response onto the socket and flush and close the
connection. These are all things that we don't want: we don't want a
response to be created yet and we want the connection to stay open so
that we can later stream contents to the other end. The above code
makes that possible.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Comet and CTHandler>>basicTerminate

Lautaro Fernández


2009/2/17 Lukas Renggli <[hidden email]>
> Could someone (maybe Lukas) explain to me why does it need to do the
> following lines(*) when a cometRequest is "delivered"?
>
> (*)CTHandler>>basicTerminate
>     thisContext swapSender: nil.
>     Processor activeProcess terminate

This avoids that the stack to is unwound that that ensure blocks are executed.

If that would not be done, then Seaside would generate an (empty)
response and pass this response back to the web server. The web server
would serialize this response onto the socket and flush and close the
connection. These are all things that we don't want: we don't want a
response to be created yet and we want the connection to stay open so
that we can later stream contents to the other end. The above code
makes that possible.


Thanks a lot Lukas. Now I understand it =D
Lautaro Fernández


Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



--
Luke LAut SkyFernadezWalker

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Comet and CTHandler>>basicTerminate

cedreek
In reply to this post by Lukas Renggli
sounds like a nice class comment for CTHandler ?

2009/2/17 Lukas Renggli <[hidden email]>
> Could someone (maybe Lukas) explain to me why does it need to do the
> following lines(*) when a cometRequest is "delivered"?
>
> (*)CTHandler>>basicTerminate
>     thisContext swapSender: nil.
>     Processor activeProcess terminate

This avoids that the stack to is unwound that that ensure blocks are executed.

If that would not be done, then Seaside would generate an (empty)
response and pass this response back to the web server. The web server
would serialize this response onto the socket and flush and close the
connection. These are all things that we don't want: we don't want a
response to be created yet and we want the connection to stay open so
that we can later stream contents to the other end. The above code
makes that possible.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



--
Cédrick

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Comet and CTHandler>>basicTerminate

Lautaro Fernández
In our implementation of Comet we put the following:
basicTerminate
    "This message is kind of a hack. It's goal is to escape from a 'block ensure' (more specifically, an 'error block ensure' ). This method will avoid to send a response into the browser and therefore we will have a live stream with the web browser.

    The method that this method hack, is Swazoo.HTTPConnection>>produceResponseFor: aSwazooTask, specifically to only do the following line (look <<):
Swazoo.HTTPConnection>>produceResponseFor: aSwazooTask
    {...}
    SpExceptionContext
        for:     [aSwazooTask response:
                    (self server answerTo: aSwazooTask request). << THIS line
            {..this code will not be executed...} ]
    on: Error
        do: [:ex | {..this code neither...}]
See this link for more information: http://www.nabble.com/Comet-and-CTHandler%3E%3EbasicTerminate-td22056942.html
"

I know this is hardcoded with Swazoo, but maybe is useful for somebody else.


2009/2/18 Cédrick Béler <[hidden email]>
sounds like a nice class comment for CTHandler ?

2009/2/17 Lukas Renggli <[hidden email]>
> Could someone (maybe Lukas) explain to me why does it need to do the

> following lines(*) when a cometRequest is "delivered"?
>
> (*)CTHandler>>basicTerminate
>     thisContext swapSender: nil.
>     Processor activeProcess terminate

This avoids that the stack to is unwound that that ensure blocks are executed.

If that would not be done, then Seaside would generate an (empty)
response and pass this response back to the web server. The web server
would serialize this response onto the socket and flush and close the
connection. These are all things that we don't want: we don't want a
response to be created yet and we want the connection to stay open so
that we can later stream contents to the other end. The above code
makes that possible.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



--
Cédrick

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside




--
Luke LAut SkyFernadezWalker

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside