VA80 - getHostBySockName: fails or SstActor problem ?

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

VA80 - getHostBySockName: fails or SstActor problem ?

Postby marten » Sun Jul 26, 2009 4:50 am

Here is a piece of code, which seems to fail every time I use it - within the Actor instance.

The code should return the name of a local SciSocketAddress. Lets say, that a method <A> is calling a
method <B>. The method <B> contains the following code:

Code: Select all
"this is wrong code - but see remark at end of posting"
self == Processor sstCurrentActor ifTrue: [^self sstActorSend].

result := (temp1 := SciSocketAddress fromString: '') isSciError
                  ifTrue: [ '?' ]
                    (temp2 := SciSocketManager default getHostBySockName: temp1) isSciError
                      ifTrue:[  temp2 ]
                      ifFalse:[ temp2 name ]
when: ExAll
do: [ :sig | sig exitWith: nil ].            

result inspect.

This code is called from a background user process and the execution ends up in a
uint8At: due to general protection fault (when not adding an exception handler like the one above).

The exception is thrown in getHostBySockName:

Code: Select all
getHostBySockName: aSocketAddress
   "Answer an instance of a SciHostEnt. Extract the address from
   the aSocketAddress and retrieve the host ent structure.

         An instance of SciSocketAddress with a valid address, port and

   | byteArray hostent hostdata result |

   hostent := OSHostEnt new.
   hostdata := OSPtr calloc: OSHostData fixedSize.
   byteArray := aSocketAddress socketAddrStruct byteArrayFromAddressNtoh32.
   self dispatcher execute: [ |pointer |
            result := (pointer := self dispatcher
                     callGetHostByAddrWith: byteArray
                     with: 4
                     with: AFINET
                     with: hostent
                     with: hostdata) isSciError
                  ifTrue: [pointer]
                  ifFalse: [SciHostEnt from: pointer].
            hostdata free].

where pointer always(!) points to address 114 (??????), which of course is a protected address ..... and "SciHostEnt from: " then throws the exception ...

The strange thing is, that I end up in the debugger and when I execute the first code ("SciSocketManager default getHostBySockName: temp1")
within the debugger I get the computer name (always) without any problems ....

I tried to include delays, but the problems remains ...

PS. 3:

I know, that the guarding command is wrong, but if I change it to

Code: Select all
self ~~ Processor sstCurrentActor ifTrue: [^self sstActorSend].

the method does NOT throw an exception, BUT returns an instance of SstExplicitFuture to the method <A>, which of course leads to an does not understand error in the calling method <A>. The debugger opens at once and shows this error - and much, much later - an inspector comes up, with the resolved name (!!!).

Is there an error, or do have missing knowledge about SstActor programming .....
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest