I ran into an out-of-external semaphores error when testing the Tropo API. It uses ZnEasy to post data to their api servers. I know I can raise the semaphore limit by running:

Smalltalk vm maxExternalSemaphoresSilently: 3000.

then saving.  But I wondered if changing ZnClient>>#close to this:

close
        "Close any HTTP network connection that I might have kept open."

        connection
                ifNotNil: [
                        connection close: self isOneShot.
                        connection := nil.
                        state := #closed ].
        lastUsed := nil

And then adding these two methods:

ZdcAbstractSocketStream>>#close:
close: andDestroy
        "Close the stream, flush if necessary"

        self flush.
        socket isNil
                ifTrue: [ ^ self ].
        self socketClose: andDestroy.
        socket := nil

ZdcAbstractSocketStream>>#socketClose: andDestroy
        andDestroy
                ifTrue: [ socket closeAndDestroy ]
                ifFalse: [ socket close ]


might enable ZnClient to clean up after it issues 'one shot' requests in a safe manner.

I can submit a change if so ( an a test! ).

Thanks
Paul

Reply via email to