The Trunk: Monticello-ul.701.mcz

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

The Trunk: Monticello-ul.701.mcz

commits-2
Levente Uzonyi uploaded a new version of Monticello to project The Trunk:
http://source.squeak.org/trunk/Monticello-ul.701.mcz

==================== Summary ====================

Name: Monticello-ul.701
Author: ul
Time: 20 September 2019, 1:49:22.872448 am
UUID: 6200146e-6bc8-483d-b784-34aeccaaa967
Ancestors: Monticello-pre.700

- assume that WebClient is always present in the image when Monticello is. This makes the Monticello package depend on the WebClient-Core package.
- when using the shared WebClient instance during downloads, check if the client is still connected. If the client is not connected, e.g. the image was restarted, force the recreation of its stream by sending #close to the client.
- use the same code instead of the HTTPSocket fallback in MCHttpRepository>>httpGet:arguments: when the #useSharedWebClientInstance preference is disabled

=============== Diff against Monticello-pre.700 ===============

Item was changed:
  ----- Method: MCHttpRepository class>>useSharedWebClientInstance (in category 'preferences') -----
  useSharedWebClientInstance
 
  <preference: 'Use shared WebClient instance'
  category: 'Monticello'
  description: 'When true, use a shared WebClient instance to speed up downloads from MCHttpRepositories. Requires WebClient to be present.'
  type: #Boolean>
+ ^UseSharedWebClientInstance ifNil: [ true ]!
- ^UseSharedWebClientInstance ifNil: [ Smalltalk hasClassNamed: #WebClient ]!

Item was changed:
  ----- Method: MCHttpRepository>>httpGet:arguments: (in category 'private') -----
  httpGet: url arguments: arguments
 
  | progress urlString client  response result |
- self class useSharedWebClientInstance ifFalse: [
- ^HTTPSocket httpGet: url args: arguments user: self user passwd: self password ].
  progress := [ :total :amount |
  HTTPProgress new
  total: total;
  amount: amount;
  signal: 'Downloading...' ].
  urlString := arguments
  ifNil: [ url ]
  ifNotNil: [
  | queryString |
+ queryString := WebUtils encodeUrlEncodedForm: arguments.
- queryString := (Smalltalk classNamed: #WebUtils) encodeUrlEncodedForm: arguments.
  (url includes: $?)
  ifTrue: [ url, '&', queryString ]
  ifFalse: [ url, '?', queryString ] ].
+ self class useSharedWebClientInstance ifTrue: [
+ "Acquire webClient by atomically storing it in the client variable and setting its value to nil."
+ client := webClient.
+ webClient := nil ].
+ client
+ ifNil: [ client := WebClient new ]
+ ifNotNil: [
+ "Attempt to avoid an error on windows by recreating the underlying stream."
+ client isConnected ifFalse: [ client close ] ].
- "Acquire webClient by atomically storing it in the client variable and setting its value to nil."
- client := webClient.
- webClient := nil.
- client ifNil: [ client := (Smalltalk classNamed: #WebClient) new ].
  response := client
  username: self user;
  password: self password;
  httpGet: urlString do: [ :request |
  request
  headerAt: 'Authorization' put: 'Basic ', (self user, ':', self password) base64Encoded;
  headerAt: 'Connection' put: 'Keep-Alive';
  headerAt: 'Accept' put: '*/*' ].
  result := (response code between: 200 and: 299)
  ifFalse: [
  response content. "Make sure content is read."
  nil ]
  ifTrue: [ (RWBinaryOrTextStream with: (response contentWithProgress: progress)) reset ].
+ self class useSharedWebClientInstance
+ ifTrue: [
+ "Save the WebClient instance for reuse, but only if there is no client cached."
+ webClient  
+ ifNil: [ webClient := client ]
+ ifNotNil: [ client close ] ]
+ ifFalse: [ client close ].
+ result ifNil: [ NetworkError signal: 'Could not access ', location ].
+ ^result!
- "Save the WebClient instance for reuse, but only if there is no client cached."
- webClient  
- ifNil: [ webClient := client ]
- ifNotNil: [ client close ].
- ^result ifNil: [
- NetworkError signal: 'Could not access ', location.
- nil ]!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Monticello-ul.701.mcz

Jakob Reschke
Should Monticello really be responsible to deal with this? Or should it rather be the WebClient itself?

    client isConnected ifFalse: [ client close ]

<[hidden email]> schrieb am Fr., 20. Sep. 2019, 01:51:
Levente Uzonyi uploaded a new version of Monticello to project The Trunk:
http://source.squeak.org/trunk/Monticello-ul.701.mcz

==================== Summary ====================

Name: Monticello-ul.701
Author: ul
Time: 20 September 2019, 1:49:22.872448 am
UUID: 6200146e-6bc8-483d-b784-34aeccaaa967
Ancestors: Monticello-pre.700

- assume that WebClient is always present in the image when Monticello is. This makes the Monticello package depend on the WebClient-Core package.
- when using the shared WebClient instance during downloads, check if the client is still connected. If the client is not connected, e.g. the image was restarted, force the recreation of its stream by sending #close to the client.
- use the same code instead of the HTTPSocket fallback in MCHttpRepository>>httpGet:arguments: when the #useSharedWebClientInstance preference is disabled

=============== Diff against Monticello-pre.700 ===============

Item was changed:
  ----- Method: MCHttpRepository class>>useSharedWebClientInstance (in category 'preferences') -----
  useSharedWebClientInstance

        <preference: 'Use shared WebClient instance'
                category: 'Monticello'
                description: 'When true, use a shared WebClient instance to speed up downloads from MCHttpRepositories. Requires WebClient to be present.'
                type: #Boolean>
+       ^UseSharedWebClientInstance ifNil: [ true ]!
-       ^UseSharedWebClientInstance ifNil: [ Smalltalk hasClassNamed: #WebClient ]!

Item was changed:
  ----- Method: MCHttpRepository>>httpGet:arguments: (in category 'private') -----
  httpGet: url arguments: arguments

        | progress urlString client  response result |
-       self class useSharedWebClientInstance ifFalse: [
-               ^HTTPSocket httpGet: url args: arguments user: self user passwd: self password ].
        progress := [ :total :amount |
                HTTPProgress new
                        total: total;
                        amount: amount;
                        signal: 'Downloading...' ].
        urlString := arguments
                ifNil: [ url ]
                ifNotNil: [
                        | queryString |
+                       queryString := WebUtils encodeUrlEncodedForm: arguments.
-                       queryString := (Smalltalk classNamed: #WebUtils) encodeUrlEncodedForm: arguments.
                        (url includes: $?)
                                ifTrue: [ url, '&', queryString ]
                                ifFalse: [ url, '?', queryString ] ].
+       self class useSharedWebClientInstance ifTrue: [
+               "Acquire webClient by atomically storing it in the client variable and setting its value to nil."
+               client := webClient.
+               webClient := nil ].
+       client
+               ifNil: [ client := WebClient new ]
+               ifNotNil: [
+                       "Attempt to avoid an error on windows by recreating the underlying stream."
+                       client isConnected ifFalse: [ client close ] ].
-       "Acquire webClient by atomically storing it in the client variable and setting its value to nil."
-       client := webClient.
-       webClient := nil.
-       client ifNil: [ client := (Smalltalk classNamed: #WebClient) new ].
        response := client
                username: self user;
                password: self password;
                httpGet: urlString do: [ :request |
                        request
                                headerAt: 'Authorization' put: 'Basic ', (self user, ':', self password) base64Encoded;
                                headerAt: 'Connection' put: 'Keep-Alive';
                                headerAt: 'Accept' put: '*/*' ].
        result := (response code between: 200 and: 299)
                ifFalse: [
                        response content. "Make sure content is read."
                        nil ]
                ifTrue: [ (RWBinaryOrTextStream with: (response contentWithProgress: progress)) reset ].
+       self class useSharedWebClientInstance
+               ifTrue: [
+                       "Save the WebClient instance for reuse, but only if there is no client cached."
+                       webClient 
+                               ifNil: [ webClient := client ]
+                               ifNotNil: [ client close ] ]
+               ifFalse: [ client close ].
+       result ifNil: [ NetworkError signal: 'Could not access ', location ].
+       ^result!
-       "Save the WebClient instance for reuse, but only if there is no client cached."
-       webClient 
-               ifNil: [ webClient := client ]
-               ifNotNil: [ client close ].
-       ^result ifNil: [
-               NetworkError signal: 'Could not access ', location.
-               nil ]!




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Monticello-ul.701.mcz

Levente Uzonyi
Since I can't reproduce the problem, and I don't know what state the
client has when the error happens, I can only guess what may help solving
the issue.
If it only happens with https connections, it's probably related to the
differences of SqueakSSL on various platforms. If not, then it may be
related to the differences of SocketPlugin.

Levente

On Fri, 20 Sep 2019, Jakob Reschke wrote:

> Should Monticello really be responsible to deal with this? Or should it rather be the WebClient itself?
>     client isConnected ifFalse: [ client close ]
>
> <[hidden email]> schrieb am Fr., 20. Sep. 2019, 01:51:
>       Levente Uzonyi uploaded a new version of Monticello to project The Trunk:
>       http://source.squeak.org/trunk/Monticello-ul.701.mcz
>
>       ==================== Summary ====================
>
>       Name: Monticello-ul.701
>       Author: ul
>       Time: 20 September 2019, 1:49:22.872448 am
>       UUID: 6200146e-6bc8-483d-b784-34aeccaaa967
>       Ancestors: Monticello-pre.700
>
>       - assume that WebClient is always present in the image when Monticello is. This makes the Monticello package depend on the WebClient-Core package.
>       - when using the shared WebClient instance during downloads, check if the client is still connected. If the client is not connected, e.g. the image was restarted, force the recreation of its stream by sending
>       #close to the client.
>       - use the same code instead of the HTTPSocket fallback in MCHttpRepository>>httpGet:arguments: when the #useSharedWebClientInstance preference is disabled
>
>       =============== Diff against Monticello-pre.700 ===============
>
>       Item was changed:
>         ----- Method: MCHttpRepository class>>useSharedWebClientInstance (in category 'preferences') -----
>         useSharedWebClientInstance
>
>               <preference: 'Use shared WebClient instance'
>                       category: 'Monticello'
>                       description: 'When true, use a shared WebClient instance to speed up downloads from MCHttpRepositories. Requires WebClient to be present.'
>                       type: #Boolean>
>       +       ^UseSharedWebClientInstance ifNil: [ true ]!
>       -       ^UseSharedWebClientInstance ifNil: [ Smalltalk hasClassNamed: #WebClient ]!
>
>       Item was changed:
>         ----- Method: MCHttpRepository>>httpGet:arguments: (in category 'private') -----
>         httpGet: url arguments: arguments
>
>               | progress urlString client  response result |
>       -       self class useSharedWebClientInstance ifFalse: [
>       -               ^HTTPSocket httpGet: url args: arguments user: self user passwd: self password ].
>               progress := [ :total :amount |
>                       HTTPProgress new
>                               total: total;
>                               amount: amount;
>                               signal: 'Downloading...' ].
>               urlString := arguments
>                       ifNil: [ url ]
>                       ifNotNil: [
>                               | queryString |
>       +                       queryString := WebUtils encodeUrlEncodedForm: arguments.
>       -                       queryString := (Smalltalk classNamed: #WebUtils) encodeUrlEncodedForm: arguments.
>                               (url includes: $?)
>                                       ifTrue: [ url, '&', queryString ]
>                                       ifFalse: [ url, '?', queryString ] ].
>       +       self class useSharedWebClientInstance ifTrue: [
>       +               "Acquire webClient by atomically storing it in the client variable and setting its value to nil."
>       +               client := webClient.
>       +               webClient := nil ].
>       +       client
>       +               ifNil: [ client := WebClient new ]
>       +               ifNotNil: [
>       +                       "Attempt to avoid an error on windows by recreating the underlying stream."
>       +                       client isConnected ifFalse: [ client close ] ].
>       -       "Acquire webClient by atomically storing it in the client variable and setting its value to nil."
>       -       client := webClient.
>       -       webClient := nil.
>       -       client ifNil: [ client := (Smalltalk classNamed: #WebClient) new ].
>               response := client
>                       username: self user;
>                       password: self password;
>                       httpGet: urlString do: [ :request |
>                               request
>                                       headerAt: 'Authorization' put: 'Basic ', (self user, ':', self password) base64Encoded;
>                                       headerAt: 'Connection' put: 'Keep-Alive';
>                                       headerAt: 'Accept' put: '*/*' ].
>               result := (response code between: 200 and: 299)
>                       ifFalse: [
>                               response content. "Make sure content is read."
>                               nil ]
>                       ifTrue: [ (RWBinaryOrTextStream with: (response contentWithProgress: progress)) reset ].
>       +       self class useSharedWebClientInstance
>       +               ifTrue: [
>       +                       "Save the WebClient instance for reuse, but only if there is no client cached."
>       +                       webClient 
>       +                               ifNil: [ webClient := client ]
>       +                               ifNotNil: [ client close ] ]
>       +               ifFalse: [ client close ].
>       +       result ifNil: [ NetworkError signal: 'Could not access ', location ].
>       +       ^result!
>       -       "Save the WebClient instance for reuse, but only if there is no client cached."
>       -       webClient 
>       -               ifNil: [ webClient := client ]
>       -               ifNotNil: [ client close ].
>       -       ^result ifNil: [
>       -               NetworkError signal: 'Could not access ', location.
>       -               nil ]!
>
>
>
>