read more
This commit is contained in:
		
							parent
							
								
									fee531f9c1
								
							
						
					
					
						commit
						cd1bd72a80
					
				@ -108,9 +108,13 @@ func (a *agent) Work() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Internal read
 | 
					// Internal read
 | 
				
			||||||
func (a *agent) read() (data []byte, err error) {
 | 
					func (a *agent) read() (data []byte, err error) {
 | 
				
			||||||
    if len(a.in) > 0 {
 | 
					BEGIN:
 | 
				
			||||||
 | 
					    inlen := len(a.in)
 | 
				
			||||||
 | 
					    if inlen > 0 {
 | 
				
			||||||
        // in queue is not empty
 | 
					        // in queue is not empty
 | 
				
			||||||
        data = <-a.in
 | 
					        for i := 0; i < inlen; i ++ {
 | 
				
			||||||
 | 
					            data = append(data, <-a.in...)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        for {
 | 
					        for {
 | 
				
			||||||
            buf := make([]byte, common.BUFFER_SIZE)
 | 
					            buf := make([]byte, common.BUFFER_SIZE)
 | 
				
			||||||
@ -137,7 +141,7 @@ func (a *agent) read() (data []byte, err error) {
 | 
				
			|||||||
    for i := 0; i < tl; i++ {
 | 
					    for i := 0; i < tl; i++ {
 | 
				
			||||||
        if string(data[start:start+4]) == common.RES_STR {
 | 
					        if string(data[start:start+4]) == common.RES_STR {
 | 
				
			||||||
            l := int(common.BytesToUint32([4]byte{data[start+8],
 | 
					            l := int(common.BytesToUint32([4]byte{data[start+8],
 | 
				
			||||||
                data[start+9], data[start+10], data[start+11]}))
 | 
					            data[start+9], data[start+10], data[start+11]}))
 | 
				
			||||||
            total := l + 12
 | 
					            total := l + 12
 | 
				
			||||||
            if total == tl { // data is what we want
 | 
					            if total == tl { // data is what we want
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
@ -145,8 +149,8 @@ func (a *agent) read() (data []byte, err error) {
 | 
				
			|||||||
                a.in <- data[total:]
 | 
					                a.in <- data[total:]
 | 
				
			||||||
                data = data[:total]
 | 
					                data = data[:total]
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
            } else { // ops! 
 | 
					            } else { // ops! It won't be possible.
 | 
				
			||||||
                break
 | 
					                goto BEGIN
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            start++
 | 
					            start++
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user