summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostyantyn Ovechko <fastinetserver@gmail.com>2010-07-26 14:26:14 +0300
committerKostyantyn Ovechko <fastinetserver@gmail.com>2010-07-26 14:26:14 +0300
commit32145bcd99eee1306597f4e355db21437fe12891 (patch)
treeed81bc6c2ccba269ed7b6156212905b94c5194eb /segget/proxyfetcher.cpp
parentAdd request tool. (diff)
downloadidfetch-32145bcd99eee1306597f4e355db21437fe12891.tar.gz
idfetch-32145bcd99eee1306597f4e355db21437fe12891.tar.bz2
idfetch-32145bcd99eee1306597f4e355db21437fe12891.zip
Implement checks for both (proxy_fetcher and request_server) queues.
There're 2 queues: proxy_fetcher queue and request_server queue. Note: Segget processes request_server queue first and if no segment was chosen switches to proxy_fetcher queue. Before adding a distifile to any of the queues it's necessary to check both queues, since distfile may already be in one of them.
Diffstat (limited to 'segget/proxyfetcher.cpp')
-rw-r--r--segget/proxyfetcher.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/segget/proxyfetcher.cpp b/segget/proxyfetcher.cpp
index 31e9547..0895729 100644
--- a/segget/proxyfetcher.cpp
+++ b/segget/proxyfetcher.cpp
@@ -104,7 +104,32 @@ void *run_proxy_fetcher_server(void * ){
error_log("Received a msg from the client:"+recv_msg);
string send_response;
// char send_buffer[10]="";
- send_response=toString(proxy_fetcher_pkg.try_adding_distfile_to_proxy_fetchers_queue(json_tokener_parse(buffer)));
+
+ json_object* json_obj_distfile=json_tokener_parse(buffer);
+ string distfile_name=json_object_get_string(json_object_object_get(json_obj_distfile,"name"));
+ int result=request_server_pkg.find_distfile(distfile_name);
+ switch (result){
+ case R_PF_NOT_REQUESTED_YET:
+ case R_PF_ERROR_ADDING_TO_PROXY_QUEUE: // if error - try with proxy_fetcher
+ {
+ result=proxy_fetcher_pkg.find_distfile(distfile_name);
+ switch (result){
+ case R_PF_NOT_REQUESTED_YET:{
+ if (is_symlink_restricted(distfile_name)!=-1){
+ debug("PROXY_FETCHER: distfile: "+distfile_name+" restricted (name matches restriting pattern");
+ result=R_PF_REJECTED;
+ }else{
+ result=proxy_fetcher_pkg.push_back_distfile(json_obj_distfile);
+ break;
+ }
+ }
+ default: break;
+ }
+ break;
+ }
+ default: break;
+ }
+ send_response=toString(result);
// if (write(sockfd, send_buffer, strlen(send_buffer))!=(int)msg.length()){
if (write(fd, send_response.c_str(), send_response.length())!=(int)send_response.length()){
error_log("Error in proxyfetcher.cpp: run_proxy_fetcher_server(): response msg size and sent data size are different.");