Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0007446 [Squeak] Network minor always 01-13-10 19:47 04-18-10 21:57
Reporter sig View Status public  
Assigned To laza
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version trunk Product Version trunk
  Product Build
Summary 0007446: [BUG][FIX] SocketStream>>peek
Description Peek should answer a next item to read , but do not advance the stream position.
Therefore a following test should yield true:

a := anyStream peek.
b := anyStream next.

self assert: (a = b).

In a SocketStream, however , #next, first advances the lastRead ivar,
then reads a next char
answering inBuffer at: pos+1 ( where pos is the lastRead value
before sending #next )

SocketStream>>next
       "Return next byte, if inBuffer is empty
       we recieve some more data and try again."

       self atEnd ifTrue: [^nil].
       self isInBufferEmpty ifTrue:
               [self receiveData.
               self atEnd ifTrue: [^nil]].
       lastRead := lastRead + 1.
       ^inBuffer at: lastRead

But peek, answering a char from inBuffer at: pos !!!

peek
       "Return next byte, if inBuffer is empty
       we recieve some more data and try again.
       Do not consume the byte."

       self atEnd ifTrue: [^nil].
       self isInBufferEmpty ifTrue:
               [self receiveData.
               self atEnd ifTrue: [^nil]].
       ^inBuffer at: lastRead

The fix is:

--- ^inBuffer at: lastRead
+++ ^inBuffer at: lastRead+1
Steps To Reproduce
Additional Information
Attached Files  socketstream-peek.1.cs [^] (435 bytes) 01-13-10 19:47

- Relationships

- Notes
(0013473 - 85 - 129 - 129 - 129 - 129 - 129)
sig
01-13-10 19:54

"fix begin"

Installer mantis bug: 7446 fix: 'socketstream-peek.1.cs'.

"fix end"
 
(0013474 - 77 - 83 - 83 - 83 - 83 - 83)
nicolas cellier
01-13-10 22:28

#peekFor: is a bit sick. Need cure too.
#peekForAll: curiously feels better.
 
(0013537 - 23 - 23 - 23 - 23 - 23 - 23)
laza
03-09-10 20:19

Patch is in trunk image
 

- Issue History
Date Modified Username Field Change
01-13-10 19:47 sig New Issue
01-13-10 19:47 sig File Added: socketstream-peek.1.cs
01-13-10 19:54 sig Note Added: 0013473
01-13-10 22:28 nicolas cellier Note Added: 0013474
01-14-10 02:15 lewis Issue Monitored: lewis
03-09-10 20:19 laza Status new => resolved
03-09-10 20:19 laza Fixed in Version  => trunk
03-09-10 20:19 laza Resolution open => fixed
03-09-10 20:19 laza Assigned To  => laza
03-09-10 20:19 laza Note Added: 0013537
04-18-10 21:57 andreas Status resolved => closed


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
52 total queries executed.
38 unique queries executed.
Powered by Mantis Bugtracker