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

fix race condition

parent 38abc8ab
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.1
  TAG: 0.2.2

# 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 "1")
set(CPACK_PACKAGE_VERSION_PATCH "2")

INCLUDE(CPack)

+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ import (
var version string

func init() {
	version = "0.2.1"
	version = "0.2.2"
	rdbApiVersion = "v0.1"
}

+2 −2
Original line number Diff line number Diff line
@@ -35,11 +35,11 @@ func routeFileUpload(w http.ResponseWriter, r *http.Request) {
		utils.WriteServerError(w, errors.New("no channel to redirect request found"), http.StatusBadRequest)
		return
	}
	buffer := make([]byte, chunkSize)
	timeout := time.Second * time.Duration(common.Settings.Http.Timeout)
	timer := time.NewTimer(timeout)

	for {
		buffer := make([]byte, chunkSize) // need to have buffer inside the for loop, otherwise we get race condition
		bytesRead, err := r.Body.Read(buffer)
		if bytesRead > 0 {
			select {
@@ -70,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, 32000)
	channel := make(chan []byte)
	id := uuid.New().String()
	channels[id] = channel