Commit ee959cf5 authored by Yakubov, Sergey's avatar Yakubov, Sergey
Browse files

fix rdb write to channel exit error

parent 0e1e638a
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ stages:
variables:
  GIT_STRATEGY: clone
  CONTAINER_RDM_URL: "${CI_REGISTRY_IMAGE}/remote-data-broker"
  TAG: 0.2.0
  TAG: 0.2.1

# This import is for the func_rse_docker_* functions
before_script:
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ SET(CPACK_RPM_PACKAGE_MAINTAINER "ORNL")

set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "2")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_VERSION_PATCH "1")

INCLUDE(CPack)

+15 −5
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ package http_server
import (
	"encoding/json"
	"errors"
	"fmt"
	"github.com/google/uuid"
	"github.com/gorilla/mux"
	"io"
@@ -37,19 +36,30 @@ func routeFileUpload(w http.ResponseWriter, r *http.Request) {
		return
	}
	buffer := make([]byte, chunkSize)
	timeout := time.Second * time.Duration(common.Settings.Http.Timeout)
	timer := time.NewTimer(timeout)

	for {
		bytesRead, err := r.Body.Read(buffer)
		if bytesRead > 0 {
			select {
			case ch <- buffer[:bytesRead]:
			default:
				log.Error("no message sent")
				timer.Reset(timeout)
			case <-timer.C:
				log.WithFields(map[string]interface{}{
					"name": id,
					"mode": "as user, from remote",
				}).Error("Receiving file from RMQ client timeout")
				utils.WriteServerError(w, errors.New("request timeout"), http.StatusInternalServerError)
				return
			}
		}
		if err != nil {
			if err != io.EOF {
				fmt.Println(err)
				log.WithFields(map[string]interface{}{
					"name":  id,
					"error": err,
				}).Error("Error receiving file from RMQ client")
			}
			break
		}
@@ -60,7 +70,7 @@ func routeFileUpload(w http.ResponseWriter, r *http.Request) {
var channels = make(map[string]chan []byte, 0)

func downloadFromRemote(w http.ResponseWriter, downloadRequest fileDownloadRequest, remoteQueue string) {
	channel := make(chan []byte)
	channel := make(chan []byte, 32000)
	id := uuid.New().String()
	channels[id] = channel