Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for blocking reva because buffered channel is not filled up on error #5006

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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