Time references changed

This commit is contained in:
Daniel A. Nagy 2015-02-13 00:11:48 +01:00
parent 6f90076d72
commit d4ff64bf44
2 changed files with 10 additions and 9 deletions

View file

@ -104,7 +104,7 @@ func (self *NetStore) Get(key Key) (chunk *Chunk, err error) {
id := generateId() id := generateId()
timeout := time.Now().Add(searchTimeout) timeout := time.Now().Add(searchTimeout)
if chunk.Data == nil { if chunk.Data == nil {
self.startSearch(chunk, id, timeout) self.startSearch(chunk, id, &timeout)
} else { } else {
return return
} }
@ -142,7 +142,8 @@ func (self *NetStore) addRetrieveRequest(req *retrieveRequestMsgData) {
defer self.lock.Unlock() defer self.lock.Unlock()
chunk := self.get(req.Key) chunk := self.get(req.Key)
req.timeout = time.Now().Add(10 * time.Second) t := time.Now().Add(10 * time.Second)
req.timeout = &t
send, timeout := self.strategyUpdateRequest(chunk.req, req) // may change req status send, timeout := self.strategyUpdateRequest(chunk.req, req) // may change req status
@ -150,9 +151,9 @@ func (self *NetStore) addRetrieveRequest(req *retrieveRequestMsgData) {
self.deliver(req, chunk) self.deliver(req, chunk)
} else { } else {
// we might need chunk.req to cache relevant peers response, or would it expire? // we might need chunk.req to cache relevant peers response, or would it expire?
self.peers(req, chunk, *timeout) self.peers(req, chunk, timeout)
if timeout != nil { if timeout != nil {
self.startSearch(chunk, int64(req.Id), *timeout) self.startSearch(chunk, int64(req.Id), timeout)
} }
} }
@ -273,8 +274,8 @@ func (self *NetStore) peers(req *retrieveRequestMsgData, chunk *Chunk, timeout *
func (self *NetStore) searchTimeout(rs *requestStatus, req *retrieveRequestMsgData) (timeout *time.Time) { func (self *NetStore) searchTimeout(rs *requestStatus, req *retrieveRequestMsgData) (timeout *time.Time) {
t := time.Now().Add(searchTimeout) t := time.Now().Add(searchTimeout)
if req.timeout.Before(t) { if req.timeout != nil && req.timeout.Before(t) {
return &req.timeout return req.timeout
} else { } else {
return &t return &t
} }

View file

@ -78,8 +78,8 @@ type storeRequestMsgData struct {
Data []byte // is this needed? Data []byte // is this needed?
// optional // optional
Id uint64 // Id uint64 //
RequestTimeout *time.Time // expiry for forwarding requestTimeout *time.Time // expiry for forwarding
StorageTimeout *time.Time // expiry of content storageTimeout *time.Time // expiry of content
Metadata metaData // Metadata metaData //
// //
peer peer peer peer
@ -119,7 +119,7 @@ It is unclear if PeersMsg with an empty Key has a special meaning or just mean t
*/ */
type peersMsgData struct { type peersMsgData struct {
Peers []*peerAddr // Peers []*peerAddr //
Timeout *time.Time // indicate whether responder is expected to deliver content timeout *time.Time // indicate whether responder is expected to deliver content
Key Key // if a response to a retrieval request Key Key // if a response to a retrieval request
Id uint64 // if a response to a retrieval request Id uint64 // if a response to a retrieval request
// //