// callback is the Go callback trampoline that is called from the
// callbackGateway C function, which in turn gets called from libnl.
//
//export callback
486548
func callback(nlm *C.struct_nl_msg, nla unsafe.Pointer) C.int {
	cbID := uintptr(nla)
	callbacksLock.RLock()
	cbArg := callbacks[cbID]
	callbacksLock.RUnlock()

	if cbArg == nil {
		panic(fmt.Sprintf("No netlink callback with ID %d", cbID))
	}

	cbMsg := &Message{nlm: nlm}
	if err := cbArg.fn(cbMsg, cbArg.arg); err != nil {
		cbArg.err = err
		return C.NL_STOP
	}
	return C.NL_OK
}
1164301
func NewCallbackEventListener(em event.EventMachine) *CallbackEventListener {
	return &CallbackEventListener{em: em, ids: []uint64{}}
}
611567
func (builder *TsQueryCommandBuilder) WithCallback(callback func([][]TsCell) error) *TsQueryCommandBuilder {
	builder.callback = callback
	return builder
}
393275
func disconnectCallback(n *Node) em.DisconnectCallbackFunc {
	return func() {
		n.Online = false
		n.logger.Info("status", "down")

		if n.disconnectCh != nil {
			n.disconnectCh <- true
		}
	}
}
705009
func (cli *grpcClient) SetResponseCallback(resCb Callback) {
	cli.mtx.Lock()
	cli.resCb = resCb
	cli.mtx.Unlock()
}
207589
func logCallback(a *C.utp_callback_arguments) C.uint64 {
	Logger.Printf("libutp: %s", C.GoString((*C.char)(unsafe.Pointer(a.buf))))
	return 0
}
522849
func sendCallbackID(callbacks map[string]dnode.Path, ch chan<- uint64) {
	// TODO fix finding of responseCallback in dnode message when removing callback
	for id, path := range callbacks {
		if len(path) != 2 {
			continue
		}
		p0, ok := path[0].(string)
		if !ok {
			continue
		}
		p1, ok := path[1].(string)
		if !ok {
			continue
		}
		if p0 != "0" || p1 != "responseCallback" {
			continue
		}
		i, _ := strconv.ParseUint(id, 10, 64)
		ch <- i
		return
	}
	close(ch)
}
1179634
func (c *Client) removeCallbacks(callbacks map[string]dnode.Path) {
	for sid := range callbacks {
		// We don't check for error because we have created
		// the callbacks map in the send function above.
		// It does not come from remote, so cannot contain errors.
		id, _ := strconv.ParseUint(sid, 10, 64)
		c.scrubber.RemoveCallback(id)
	}
}
209396
func goHintCallback(_name, _oldValue, _newValue *C.char) {
	name := C.GoString(_name)
	oldValue := C.GoString(_oldValue)
	newValue := C.GoString(_newValue)
	if cb, ok := hintCallbacks[name]; ok {
		cb.callback(cb.data, name, oldValue, newValue)
	}
}
1119136
func (s *State) runCallbacks(ctx context.Context) {
	for _, cb := range s.Callbacks() {
		cb(ctx)
	}
}
1338556
func go_callback(id C.int, data *C.uchar, len C.int, queue_id C.int) {
	// TODO: check cast of id
	payload := &RawPacket{
		ID:   uint32(id),
		Data: C.GoBytes(unsafe.Pointer(data), len),
	}

	dispatch(uint16(queue_id), payload)
}
1255911
func (reqRes *ReqRes) SetCallback(cb func(res *types.Response)) {
	reqRes.mtx.Lock()

	if reqRes.done {
		reqRes.mtx.Unlock()
		cb(reqRes.Response)
		return
	}

	reqRes.cb = cb
	reqRes.mtx.Unlock()
}
83692
func (rd *Redirector) callback(w http.ResponseWriter, r *http.Request) (*auth.SSHLoginResponse, error) {
	if r.URL.Path != "/callback" {
		return nil, trace.NotFound("path not found")
	}

	// Decrypt ciphertext to get login response.
	plaintext, err := rd.key.Open([]byte(r.URL.Query().Get("response")))
	if err != nil {
		return nil, trace.BadParameter("failed to decrypt response: in %v, err: %v", r.URL.String(), err)
	}

	var re *auth.SSHLoginResponse
	err = json.Unmarshal(plaintext, &re)
	if err != nil {
		return nil, trace.BadParameter("failed to decrypt response: in %v, err: %v", r.URL.String(), err)
	}

	return re, nil
}
905793
func runCallbacks(xu *xgbutil.XUtil, event interface{}, evtype int,
	win xproto.Window) {

	// The callback slice for a particular (event type, window) tuple uses
	// copy on write. So just take a pointer to whatever is there and use that.
	// We can be sure that the slice won't change from underneathe us.
	xu.CallbacksLck.RLock()
	cbs := xu.Callbacks[evtype][win]
	xu.CallbacksLck.RUnlock()

	for _, cb := range cbs {
		cb.Run(xu, event)
	}
}
938572
func (s *State) RegisterCallbacks(f ...Callback) {
	s.mu.Lock()
	defer s.mu.Unlock()

	s.callbacks = append(s.callbacks, f...)
}
722040
func (b *Backend) handleRollback(ctx context.Context, req *logical.Request) (*logical.Response, error) {
	// Response is not expected from the periodic operation.
	if b.PeriodicFunc != nil {
		if err := b.PeriodicFunc(ctx, req); err != nil {
			return nil, err
		}
	}

	return b.handleWALRollback(ctx, req)
}
270057
func RegisterCallbackIn(ctx context.Context, f Callback) {
	GetState(ctx).RegisterCallbacks(f)
}