Skip to content

Commit

Permalink
fix for blocking reva because buffered channel is not filled up on error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Geens authored and glpatcern committed Dec 17, 2024
1 parent 3c82216 commit 2578d59
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-block-on-sharedwithme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: blocking reva on listSharedWithMe

`listSharesWithMe` blocked a reva thread in the case that one of the shares was not resolvable. This has now been fixed

https://github.com/cs3org/reva/pull/5006
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,8 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) {
workers := 50
input := make(chan *collaboration.ReceivedShare, len(lrsRes.GetShares()))
output := make(chan *conversions.ShareData, len(lrsRes.GetShares()))
timeoutContext, cancel := context.WithTimeout(ctx, time.Duration(time.Millisecond*20000))
defer cancel()

for i := 0; i < workers; i++ {
wg.Add(1)
Expand All @@ -917,20 +919,23 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) {
info, status, err = h.getResourceInfoByID(ctx, client, rs.Share.ResourceId)
if err != nil || status.Code != rpc.Code_CODE_OK {
h.logProblems(status, err, "could not stat, skipping", log)
output <- nil
return
}
}

data, err := conversions.CS3Share2ShareData(r.Context(), rs.Share)
if err != nil {
log.Debug().Interface("share", rs.Share.Id).Err(err).Msg("CS3Share2ShareData call failes, skipping")
output <- nil
return
}

data.State = mapState(rs.GetState())

if err := h.addFileInfo(ctx, data, info); err != nil {
log.Debug().Interface("received_share", rs.Share.Id).Err(err).Msg("could not add file info, skipping")
output <- nil
return
}
h.mapUserIds(r.Context(), client, data)
Expand Down Expand Up @@ -977,7 +982,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) {
log.Debug().Msgf("share: %+v", data)
output <- data
}
}(ctx, client, input, output, &wg)
}(timeoutContext, client, input, output, &wg)
}

for _, share := range lrsRes.GetShares() {
Expand All @@ -988,7 +993,9 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) {
close(output)

for s := range output {
shares = append(shares, s)
if s != nil {
shares = append(shares, s)
}
}

if h.listOCMShares {
Expand Down

0 comments on commit 2578d59

Please sign in to comment.