package main

import "sync"

type CloseReason struct {
	ip     string
	closer string
	err    string
	sync.Mutex
}

func (cr *CloseReason) String() string {
	cr.Lock()
	defer cr.Unlock()
	return cr.closer + "(" + cr.ip + ")(" + cr.err + ")"
}

func (cr *CloseReason) SetValue(ip, closer, err string) {
	cr.Lock()
	defer cr.Unlock()
	if cr.ip != "" {
		return
	}
	cr.ip = ip
	cr.closer = closer
	cr.err = err
}
