Esempio n. 1
0
func milterGetSession(ctx uintptr, keep bool, returnNil bool) *milterSession {
	var u [16]byte
	res := m.GetPriv(ctx, &u)
	if res != 0 {
		// We purposefully do not act on errors. For some reason, the FreeBSD build always
		// returns an error. Also, in practice it never fails. Famous last words...
		//  panic("Could not get data from libmilter")
	}
	if keep {
		res := m.SetPriv(ctx, u)
		if res != 0 {
			panic(fmt.Sprintf("Session %d could not be stored in milterDataIndex", u))
		}
	}

	MilterDataIndex.mu.Lock()
	defer MilterDataIndex.mu.Unlock()

	out := MilterDataIndex.sessions[u]
	if out == nil && !returnNil {
		panic(fmt.Sprintf("Session %d could not be found in milterDataIndex", u))
	}

	return out
}
Esempio n. 2
0
func milterGetSession(ctx uintptr, keep bool, returnNil bool) *milterSession {
	var u uint64
	m.GetPriv(ctx, &u)
	if keep {
		m.SetPriv(ctx, u)
	}

	MilterDataIndex.mu.Lock()
	defer MilterDataIndex.mu.Unlock()

	out := MilterDataIndex.sessions[u]
	if out == nil && !returnNil {
		panic(fmt.Sprintf("Session %d could not be found in milterDataIndex", u))
	}

	return out
}