space monkey internal commit export

[katamari commit: ce73f75cb74ddc288a859ad3413c9a1a15380763]
This commit is contained in:
JT Olds 2014-01-18 12:34:53 -07:00
parent f3fa51fc61
commit e216ea8e48
2 changed files with 9 additions and 1 deletions

6
bio.go
View File

@ -249,12 +249,18 @@ func (b *readBio) ReadFromOnce(r io.Reader) (n int, err error) {
b.buf = new_buf
}
dst := b.buf[len(b.buf):cap(b.buf)]
dst_slice := b.buf
b.data_mtx.Unlock()
n, err = r.Read(dst)
b.data_mtx.Lock()
defer b.data_mtx.Unlock()
if n > 0 {
if len(dst_slice) != len(b.buf) {
// someone shrunk the buffer, so we read in to far ahead and we
// need to slide backwards
copy(b.buf[len(b.buf):len(b.buf)+n], dst)
}
b.buf = b.buf[:len(b.buf)+n]
}
return n, err

4
ctx.go
View File

@ -136,7 +136,9 @@ func (c *Ctx) SetSessionId(session_id []byte) error {
func (c *Ctx) SetCipherList(list string) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if int(C.SSL_CTX_set_cipher_list(c.ctx, C.CString(list))) == 0 {
clist := C.CString(list)
defer C.free(unsafe.Pointer(clist))
if int(C.SSL_CTX_set_cipher_list(c.ctx, clist)) == 0 {
return errorFromErrorQueue()
}
return nil