Put the 1 char peek back in. With TLS byte awaiting aren’t valid, however they are valid with non-tis.
This commit is contained in:
parent
c7b6a4a000
commit
2233e08ca1
|
@ -55,6 +55,13 @@ func (w *WedgeConn) Buffered() int {
|
|||
//PeekAll --
|
||||
// - get all the chars available
|
||||
// - pass then back
|
||||
func (w *WedgeConn) PeekAll() ([]byte, error) {
|
||||
return w.Peek(w.Buffered())
|
||||
func (w *WedgeConn) PeekAll() (buf []byte, err error) {
|
||||
|
||||
_, err = w.Peek(1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
buf, err = w.Peek(w.Buffered())
|
||||
return
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package genericlistener
|
||||
|
||||
import "sync"
|
||||
|
||||
type adminReqType string
|
||||
|
||||
const (
|
||||
adminStatus adminReqType = "admin_status"
|
||||
adminDomain adminReqType = "admin_domain"
|
||||
adminDomains adminReqType = "admin_domains"
|
||||
adminServer adminReqType = "admin_server"
|
||||
adminServers adminReqType = "admin_servers"
|
||||
)
|
||||
|
||||
//AdminReqType --
|
||||
type AdminReqType struct {
|
||||
mutex *sync.Mutex
|
||||
RequestType map[adminReqType]int64
|
||||
}
|
||||
|
||||
//NewAdminReqType -- Constructor
|
||||
func NewAdminReqType() (p *AdminReqType) {
|
||||
p = new(AdminReqType)
|
||||
p.mutex = &sync.Mutex{}
|
||||
p.RequestType = make(map[adminReqType]int64)
|
||||
return
|
||||
}
|
||||
|
||||
func (p *AdminReqType) add(reqType adminReqType) {
|
||||
p.mutex.Lock()
|
||||
|
||||
defer p.mutex.Unlock()
|
||||
|
||||
if _, ok := p.RequestType[reqType]; ok {
|
||||
p.RequestType[reqType]++
|
||||
} else {
|
||||
p.RequestType[reqType] = int64(1)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *AdminReqType) get(reqType adminReqType) (total int64) {
|
||||
p.mutex.Lock()
|
||||
|
||||
defer p.mutex.Unlock()
|
||||
|
||||
if _, ok := p.RequestType[reqType]; ok {
|
||||
total = p.RequestType[reqType]
|
||||
} else {
|
||||
total = 0
|
||||
}
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue