nextPut: bug fixes for SocketWriteStream and FileStream

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

nextPut: bug fixes for SocketWriteStream and FileStream

Frank Sergeant
I may have lost track of the timing and so these fixes may already
be on your list, but it looked like they had not yet made it into
Dolphin 4.01.3.  The bugs were reported in the newsgroup some
time ago by Bill and Ian, I believe, with the fixes given below.


SocketWriteStream>>nextPut: anInteger
        "Original version"
        "^self
                beDirty;
                primitiveNextPut: anInteger"

        "Fix from Ian"
        self
                primitiveNextPut: anInteger;
                beDirty.
        ^anInteger.

FileStream>>nextPut: anIntegerOrCharacter

        "fix the buffer+1 bug"

        "Original version"
        "flags := flags bitOr: DirtyBufferMask.
        ^self primitiveNextPut: anIntegerOrCharacter"

        "Fix from Ian, i.e. reverse the two lines".
        self primitiveNextPut: anIntegerOrCharacter.
        flags := flags bitOr: DirtyBufferMask.
        ^anIntegerOrCharacter.


-- Frank
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: nextPut: bug fixes for SocketWriteStream and FileStream

Bill Schwab-2
Frank,

Thanks for bringing this up!!  Knowing how long it took for the bug to
strike in a file setting, it stands to reason that it would be quite rare
(and just as mysterious) in sockets too.

Andy, are these confirmed bugs/fixes?

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: nextPut: bug fixes for SocketWriteStream and FileStream

Ian Bartholomew-4
Frank/Bill,

The problem was fixed in 4.012 (defect 178). When PL2 came out I tried the
example code that originally failed and it then worked as expected (not that
I thought it wouldn't Andy, honest!).

The actual fix was a change to #primitiveNextPut: (in both classes) where
the default code which is evaluated if the buffer overflows now resets (as
in re sets) the dirty flag.  This is more efficient that my original
suggestions as it only adds an overhead when the buffer fills, rather than
on each write.

Ian

Test code -

n := 8193.
fs := FileStream write: 'test.bin' text: false.
[1 to: n do: [:each | fs nextPut: each \\ 256]] ensure: [fs close].

fs := FileStream read: 'test.bin' text: false.
[self assert: [fs contents size = n]] ensure: [fs close].


Reply | Threaded
Open this post in threaded view
|

Re: nextPut: bug fixes for SocketWriteStream and FileStream

Frank Sergeant
Ian Bartholomew <[hidden email]> wrote:

> The problem was fixed in 4.012 (defect 178). When PL2 came out I tried the
> example code that originally failed and it then worked as expected (not that
> I thought it wouldn't Andy, honest!).

Thanks so much for the update and explanation.  Sorry for the false alarm.


-- Frank