From 18a51156ef686b73c0d954be0ed8f257c5ee159f Mon Sep 17 00:00:00 2001 From: enricovianello Date: Tue, 26 May 2015 15:00:35 +0000 Subject: [PATCH 01/12] fix for https://issues.infn.it/jira/browse/STOR-817 --- src/frontend/CopyRequest.cpp | 4 ++-- src/frontend/asynch.cpp | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/frontend/CopyRequest.cpp b/src/frontend/CopyRequest.cpp index 29d7144..3671f0c 100644 --- a/src/frontend/CopyRequest.cpp +++ b/src/frontend/CopyRequest.cpp @@ -153,8 +153,8 @@ ns1__srmCopyResponse* storm::CopyRequest::buildResponse() } catch (std::invalid_argument &exc) { throw storm::storm_error("Unable to allocate memory for a return status. invalid_argument Exception: " + std::string(exc.what())); } - fileStatus->status->statusCode = surl->getStatus(); - fileStatus->status->explanation = soap_strdup(m_soapRequest, surl->getExplanation().c_str()); + fileStatus->status->statusCode = SRM_USCORENOT_USCORESUPPORTED; + fileStatus->status->explanation = "srmCopy operation is not supported"; } if (m_requestToken.size() > 0) { m_builtResponse->requestToken = soap_strdup(m_soapRequest, m_requestToken.c_str()); diff --git a/src/frontend/asynch.cpp b/src/frontend/asynch.cpp index acb7220..beff860 100644 --- a/src/frontend/asynch.cpp +++ b/src/frontend/asynch.cpp @@ -310,15 +310,25 @@ int ns1__srmCopy(struct soap *soap, struct ns1__srmCopyRequest *req, srmlogit(STORM_LOG_DEBUG, funcName, "The user is not blacklisted\n"); } - int soap_status = __process_file_request (soap, *request, - funcName, req, &rep->srmCopyResponse); - storm::MonitoringHelper::registerOperation(start_time, soap_status, - storm::SRM_COPY_MONITOR_NAME, - rep->srmCopyResponse->returnStatus->statusCode); - srmLogResponseWithToken("CP", request->getRequestToken().c_str(), - request->getStatus()); + request->invalidateRequestToken(); + try + { + rep->srmCopyResponse = request->buildSpecificResponse(SRM_USCORENOT_USCORESUPPORTED, "srmCopy operation is not supported"); + } catch(storm::storm_error& exc) + { + srmlogit(STORM_LOG_ERROR, funcName, "Unable to build soap response. %s\n" , exc.what()); + delete request; + storm::MonitoringHelper::registerOperationError(start_time, + storm::SRM_COPY_MONITOR_NAME); + srmLogResponse("CP", SRM_USCOREFAILURE); + return soap_sender_fault(soap,exc.what(),0);; + } + storm::MonitoringHelper::registerOperation(start_time, + storm::SRM_COPY_MONITOR_NAME, + request->getStatus()); + srmLogResponse("CP", request->getStatus()); delete request; - return soap_status; + return(SOAP_OK); } int ns1__srmBringOnline(struct soap *soap, struct ns1__srmBringOnlineRequest *req, From 5cecad32077e1fa8d74d1929c3c7c74ec864f0a4 Mon Sep 17 00:00:00 2001 From: enricovianello Date: Tue, 26 May 2015 15:42:43 +0000 Subject: [PATCH 02/12] removed unused or useless code for srmCopy removed insertIntoDb removed check if user is blacklisted --- src/frontend/CopyRequest.cpp | 179 +---------------------------------- src/frontend/asynch.cpp | 86 +++-------------- 2 files changed, 14 insertions(+), 251 deletions(-) diff --git a/src/frontend/CopyRequest.cpp b/src/frontend/CopyRequest.cpp index 3671f0c..ee2a22b 100644 --- a/src/frontend/CopyRequest.cpp +++ b/src/frontend/CopyRequest.cpp @@ -166,186 +166,9 @@ ns1__srmCopyResponse* storm::CopyRequest::buildResponse() } void storm::CopyRequest::insertIntoDB(struct srm_dbfd *db) { - std::string nullcomma("NULL, "); - std::ostringstream query_s; - - std::string q("INSERT INTO request_queue (" - " config_FileStorageTypeID" - ", config_OverwriteID" - ", config_RequestTypeID" - ", client_dn" - ", u_token" - ", fileLifetime" - ", r_token" - ", s_token" - ", status" - ", nbreqfiles" - ", numOfCompleted" - ", numOfWaiting" - ", numOfFailed" - ", proxy" - ", timeStamp) values ("); - query_s << q; - if (m_fileStorageType == DB_FILE_TYPE_UNKNOWN) { - query_s << nullcomma; - } else { - query_s << sqlFormat(m_fileStorageType) << ", "; - } - - if (m_overwrite == DB_OVERWRITE_UNKNOWN) { - query_s << nullcomma; - } else { - query_s << sqlFormat(m_overwrite) << ", "; - } - - query_s << sqlFormat(m_requestType) << ", "; - query_s << sqlFormat(this->getClientDN()) << ", "; - - if (m_userToken.empty()) { - query_s << nullcomma; - } else { - query_s << sqlFormat(m_userToken) << ", "; - } - - if (m_fileLifetime == -1) { - query_s << nullcomma; - } else { - query_s << m_fileLifetime << ", "; - } - - if (m_requestToken.size() == 0) { - throw std::logic_error("Unable to store COPY request into the DB: request token empty"); - } else { - query_s << sqlFormat(m_requestToken) <<", "; - } - - if (m_spaceToken.size() == 0) { - query_s << nullcomma; - } else { - query_s << sqlFormat(m_spaceToken) <<", "; - } - - query_s << m_status << ", " << m_surls.size() << ", "; - query_s << "0, " << m_surls.size() << ", 0, "; - - // Temporary hack: using the proxy column to store FQANs - if (m_credentials.getFQANsOneString().empty()) { - query_s << nullcomma; - } else { - query_s << sqlFormat(m_credentials.getFQANsOneString()) << ", "; - } - - query_s << "current_timestamp() )"; - - storm_start_tr(0, db); - // Insert into request_queue - int request_id; - try { - request_id = storm_db::ID_exec_query(db, query_s.str()); - } catch(storm_db::mysql_exception& e) { - srmlogit(STORM_LOG_ERROR, "CopyRequest::insert()", - "Error writing the request on StoRM DB. mysql_exception : %s , errno = %d\n", e.what() , e.get_mysql_errno()); - storm_abort_tr(db); - failRequest("Error writing the request on StoRM DB"); - throw e; - } - int failedCount = 0; - // Insert into request_Copy using the requestID - std::vector::const_iterator const vectorEnd = m_surls.end(); - for (std::vector::const_iterator i = m_surls.begin(); i != vectorEnd; ++i) { - storm::CopySurl* surl = dynamic_cast (i->get()); - if(!surl) - { - throw std::logic_error("Unable to cast SurlPtr to CopySurl, cast failure"); - } - set_savepoint(db, "COPYFILE"); - int diroption_id; - if (surl->hasDirOption()) { - std::ostringstream query_d; - query_d << "INSERT INTO request_DirOption (isSourceADirectory, allLevelRecursive, numOfLevels) values ("; - query_d << sqlFormat(surl->isDirectory()) << ", " << sqlFormat(surl->isAllLevelRecursive()) << ", "; - if (surl->hasNumLevels()) { - query_s << surl->getNumLevels() << ")"; - } else { - query_s << "NULL)"; - } - try{ - diroption_id = storm_db::ID_exec_query(db, query_d.str()); - } catch(storm_db::mysql_exception& e) { - srmlogit(STORM_LOG_ERROR, "CopyRequest::insert()", - "Error %s inserting surl %s into request_DirOption. Errno = %d .Continuing\n", e.what(), - surl->getSurl().c_str() , e.get_mysql_errno()); - - surl->setStatus(SRM_USCOREFAILURE); - surl->setExplanation("Unable to store the request in StoRM DB"); - rollback_to_savepoint(db, "COPYFILE"); - ++failedCount; - continue; - } - } - - std::ostringstream query_s; - query_s << "INSERT INTO request_Copy (sourceSURL, targetSURL, request_queueID, request_DirOptionID) VALUES "; - query_s << "(" << sqlFormat(surl->getSourceSurl()) << ", " << sqlFormat(surl->getDestinationSurl()) << ", "; - query_s << request_id << ", "; - if (surl->hasDirOption()) - { - query_s << diroption_id<<")"; - } - else - { - query_s << "NULL )"; - } - int copy_id; - try{ - copy_id = storm_db::ID_exec_query(db, query_s.str()); - } catch(storm_db::mysql_exception& e) { - srmlogit(STORM_LOG_ERROR, "CopyRequest::insert()", - "Error %s inserting surl %s into request_Copy. Errno = %d .Continuing\n", e.what(), - surl->getSurl().c_str() , e.get_mysql_errno()); - - surl->setStatus(SRM_USCOREFAILURE); - surl->setExplanation("Unable to store the request in StoRM DB"); - rollback_to_savepoint(db, "COPYFILE"); - ++failedCount; - continue; - } - - std::ostringstream query2_s; - query2_s << "INSERT INTO status_Copy (request_CopyID, statusCode) values ("; - query2_s << copy_id << ", " << SRM_USCOREREQUEST_USCOREQUEUED <<")"; - try{ - storm_db::ID_exec_query(db, query2_s.str()); - } catch(storm_db::mysql_exception& e) { - srmlogit(STORM_LOG_ERROR, "CopyRequest::insert()", - "Error %s inserting surl %s into status_Copy. Errno = %d .Continuing\n", e.what(), - surl->getSurl().c_str() , e.get_mysql_errno()); - - surl->setStatus(SRM_USCOREFAILURE); - surl->setExplanation("Unable to store the request in StoRM DB"); - rollback_to_savepoint(db, "COPYFILE"); - ++failedCount; - continue; - } - } - if(failedCount == m_surls.size()) - { - srmlogit(STORM_LOG_ERROR, "CopyRequest::insert()", - "No SURLs inserted. Request failed\n"); - storm_abort_tr(db); - m_status = SRM_USCOREFAILURE; - m_explanation = "All files requests are failed"; - } - else - { - storm_end_tr(db); - } - - saveProxy(); - // insert into retention policy, clientNetworks, extrainfo, VOMS - // attribute using the requestID } + std::string storm::CopyRequest::getSurlsList() { std::string builtList; diff --git a/src/frontend/asynch.cpp b/src/frontend/asynch.cpp index beff860..768f88c 100644 --- a/src/frontend/asynch.cpp +++ b/src/frontend/asynch.cpp @@ -254,81 +254,21 @@ int ns1__srmCopy(struct soap *soap, struct ns1__srmCopyRequest *req, srmLogRequestWithSurls("CP", get_ip(soap).c_str(), request->getClientDN().c_str(), request->getSurlsList().c_str(), request->getSurlsNumber()); - bool blacklisted = false; - try - { - blacklisted = storm::authz::is_blacklisted(soap); - }catch(storm::authorization_error& e) - { - srmlogit(STORM_LOG_ERROR, funcName, "Unable to check user blacklisting. Error: %s\n" , e.what()); - request->invalidateRequestToken(); - try - { - rep->srmCopyResponse = request->buildSpecificResponse(SRM_USCOREFAILURE, "Unable to check user blacklisting"); - } catch(storm::storm_error& exc) - { - srmlogit(STORM_LOG_ERROR, funcName, "Unable to build soap response. %s\n" , exc.what()); - delete request; - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_COPY_MONITOR_NAME); - srmLogResponse("CP", SRM_USCOREFAILURE); - return soap_sender_fault(soap,e.what(),0);; - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_COPY_MONITOR_NAME, - request->getStatus()); - srmLogResponse("CP", request->getStatus()); - delete request; - return(SOAP_OK); - } - - if(blacklisted) - { - srmlogit(STORM_LOG_INFO, funcName, "The user is blacklisted\n"); - request->invalidateRequestToken(); - try - { - rep->srmCopyResponse = request->buildSpecificResponse(SRM_USCOREAUTHORIZATION_USCOREFAILURE, "User not authorized"); - } catch(storm::storm_error& exc) - { - srmlogit(STORM_LOG_ERROR, funcName, "Unable to build soap response. %s\n" , exc.what()); - delete request; - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_COPY_MONITOR_NAME); - srmLogResponse("CP", SRM_USCOREFAILURE); - return soap_sender_fault(soap,exc.what(),0);; - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_COPY_MONITOR_NAME, - request->getStatus()); - srmLogResponse("CP", request->getStatus()); - delete request; - return(SOAP_OK); - } - else - { - srmlogit(STORM_LOG_DEBUG, funcName, "The user is not blacklisted\n"); - } request->invalidateRequestToken(); - try - { - rep->srmCopyResponse = request->buildSpecificResponse(SRM_USCORENOT_USCORESUPPORTED, "srmCopy operation is not supported"); - } catch(storm::storm_error& exc) - { - srmlogit(STORM_LOG_ERROR, funcName, "Unable to build soap response. %s\n" , exc.what()); - delete request; - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_COPY_MONITOR_NAME); - srmLogResponse("CP", SRM_USCOREFAILURE); - return soap_sender_fault(soap,exc.what(),0);; - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_COPY_MONITOR_NAME, - request->getStatus()); - srmLogResponse("CP", request->getStatus()); - delete request; - return(SOAP_OK); + try { + rep->srmCopyResponse = request->buildSpecificResponse(SRM_USCORENOT_USCORESUPPORTED, "srmCopy operation is not supported"); + } catch (storm::storm_error& exc) { + srmlogit(STORM_LOG_ERROR, funcName,"Unable to build soap response. %s\n", exc.what()); + delete request; + storm::MonitoringHelper::registerOperationError(start_time, storm::SRM_COPY_MONITOR_NAME); + srmLogResponse("CP", SRM_USCOREFAILURE); + return soap_sender_fault(soap, exc.what(), 0);; + } + storm::MonitoringHelper::registerOperation(start_time, storm::SRM_COPY_MONITOR_NAME, request->getStatus()); + srmLogResponse("CP", request->getStatus()); + delete request; + return (SOAP_OK); } int ns1__srmBringOnline(struct soap *soap, struct ns1__srmBringOnlineRequest *req, From 95e65a2c7d592be392bd09bc8d0c1f0da96be227 Mon Sep 17 00:00:00 2001 From: enricovianello Date: Wed, 27 May 2015 09:59:19 +0000 Subject: [PATCH 03/12] srmStatusOfCopy changed to not supported --- src/frontend/CopyStatusRequest.cpp | 140 ++--------------------------- src/frontend/asynch_status.cpp | 64 +++---------- 2 files changed, 20 insertions(+), 184 deletions(-) diff --git a/src/frontend/CopyStatusRequest.cpp b/src/frontend/CopyStatusRequest.cpp index 2922a4f..e0584a3 100644 --- a/src/frontend/CopyStatusRequest.cpp +++ b/src/frontend/CopyStatusRequest.cpp @@ -45,119 +45,8 @@ void storm::CopyStatusRequest::load(ns1__srmStatusOfCopyRequestRequest* req) void storm::CopyStatusRequest::loadFromDB(struct srm_dbfd* db){ - srmlogit(STORM_LOG_DEBUG, "storm::CopyStatusRequest::loadFromDB", "R_token: %s\n", m_requestToken.c_str()); + srmlogit(STORM_LOG_DEBUG, "storm::CopyStatusRequest::loadFromDB", "disabled"); - std::string query(""); - if(m_surls.size() > 0) - { - query += "SELECT r.client_dn, r.status, r.errstring, r.remainingTotalTime, " - " c.sourceSURL, c.targetSURL , s.fileSize , s.estimatedWaitTime , " - " s.remainingFileTime , s.statusCode , s.explanation" - " FROM request_queue r JOIN (request_Copy c, status_Copy s) ON " - "(c.request_queueID=r.ID AND s.request_CopyID=c.ID) " - "WHERE r.r_token=" + sqlFormat(m_requestToken) + " and c.sourceSURL in ("; - bool first = true; - std::set::const_iterator const vectorEnd = m_surls.end(); - for (std::set::const_iterator i = m_surls.begin(); i != vectorEnd; ++i) { - Surl* current = i->get(); - if(first) - { - first = false; - } - else - { - query += " , "; - } - query += sqlFormat(current->getSurl()); - } - query += ")"; - if(m_allTargetSurlSpecified) - { - query += " and c.targetSURL in ("; - first = true; - std::set::const_iterator const vectorEnd = m_surls.end(); - for (std::set::const_iterator i = m_surls.begin(); i != vectorEnd; ++i) { - storm::CopySurl* current = dynamic_cast (i->get()); - if(!current) - { - throw std::logic_error("Unable to cast SurlPtr to CopySurl, cast failure"); - } - if(first) - { - first = false; - } - else - { - query += " , "; - } - query += sqlFormat(current->getDestinationSurl()); - } - query += ")"; - } - - } - else - { - query += "SELECT r.client_dn, r.status, r.errstring, r.remainingTotalTime, " - " c.sourceSURL, c.targetSURL , s.fileSize , s.estimatedWaitTime , " - " s.remainingFileTime , s.statusCode , s.explanation" - " FROM request_queue r JOIN (request_Copy c, status_Copy s) ON " - "(c.request_queueID=r.ID AND s.request_CopyID=c.ID) " - "WHERE r.r_token=" + sqlFormat(m_requestToken); - } - file_status_results_t results; - storm_db::vector_exec_query(db, query, results); - if (results.size() == 0) - { - if(m_surls.size() > 0) - { - srmlogit(STORM_LOG_INFO, "storm::CopyStatusRequest::loadFromDB()", - "No tokens found for token %s and the requested SURLs\n", m_requestToken.c_str()); - throw storm::token_not_found("No request found for token " + m_requestToken + " and the requested SURLs\n"); - } - else - { - srmlogit(STORM_LOG_INFO, "storm::CopyStatusRequest::loadFromDB()", - "No tokens found for token %s\n", m_requestToken.c_str()); - throw storm::token_not_found("No request found for token " + m_requestToken + "\n"); - } - - } - fillCommonFields(results); - - std::vector::const_iterator const vectorEnd = results.end(); - for (std::vector::const_iterator i = results.begin(); i != vectorEnd; ++i) { - file_status_result_t currentResutl = *i; - storm::Surl surl(currentResutl["sourceSURL"].c_str()); - sql_string destinationSURL(currentResutl["targetSURL"].c_str()); - CopyTurl* turl; - if(currentResutl["fileSize"].empty()) - { - turl = new CopyTurl(surl, destinationSURL); - } - else - { - turl = new CopyTurl(surl, destinationSURL, strtoull(currentResutl["fileSize"].c_str(),(char**)NULL,10)); - } - if(currentResutl["statusCode"].empty()) - { - srmlogit(STORM_LOG_ERROR, "storm::CopyStatusRequest::loadFromDB()", - "Error,status code for SURL %s is empty. Continuing without filling SURLs informations.\n", currentResutl["targetSURL"].c_str()); - delete turl; - continue; - } - turl->setStatus(static_cast(atoi(currentResutl["statusCode"].c_str()))); - turl->setExplanation(currentResutl["explanation"]); - if(!currentResutl["estimatedWaitTime"].empty()) - { - turl->setEstimatedWaitTime(atoi(currentResutl["estimatedWaitTime"].c_str())); - } - if(!currentResutl["remainingFileTime"].empty()) - { - turl->setRemainingFileLifetime(atoi(currentResutl["remainingFileTime"].c_str())); - } - m_turls.insert(TurlPtr(turl)); - } } ns1__srmStatusOfCopyRequestResponse* storm::CopyStatusRequest::buildResponse() @@ -177,14 +66,9 @@ ns1__srmStatusOfCopyRequestResponse* storm::CopyStatusRequest::buildResponse() + std::string(exc.what())); } - m_builtResponse->returnStatus->statusCode = m_status; - if (!m_explanation.empty()) { - m_builtResponse->returnStatus->explanation = soap_strdup(m_soapRequest, m_explanation.c_str()); - } - if (this->hasRemainingTotalRequestTime()) { - m_builtResponse->remainingTotalRequestTime = storm::soap_calloc(m_soapRequest); - *m_builtResponse->remainingTotalRequestTime = m_remainingTotalRequestTime; - } + m_builtResponse->returnStatus->statusCode = SRM_USCORENOT_USCORESUPPORTED; + m_builtResponse->returnStatus->explanation = "srmStatusCopy operation is not supported"; + // Fill status for each surl. int fileStatusArraySize = (m_surls.size() > m_turls.size() ? m_surls.size() : m_turls.size()); if(fileStatusArraySize > 0) @@ -223,20 +107,8 @@ ns1__srmStatusOfCopyRequestResponse* storm::CopyStatusRequest::buildResponse() } catch (std::invalid_argument& exc) { throw std::logic_error("Unable to allocate memory for a return status. invalid_argument Exception: " + std::string(exc.what())); } - if (turl->hasFileSize()) { - fileStatus->fileSize = storm::soap_calloc(m_soapRequest); - *fileStatus->fileSize = turl->getFileSize(); - } - if (turl->hasEstimatedWaitTime()) { - fileStatus->estimatedWaitTime = storm::soap_calloc(m_soapRequest); - *fileStatus->estimatedWaitTime = turl->getEstimatedWaitTime(); - } - if (turl->hasRemainingFileLifetime()) { - fileStatus->remainingFileLifetime= storm::soap_calloc(m_soapRequest); - *fileStatus->remainingFileLifetime = turl->hasRemainingFileLifetime(); - } - fileStatus->status->statusCode = turl->getStatus(); - fileStatus->status->explanation = soap_strdup(m_soapRequest, turl->getExplanation().c_str()); + fileStatus->status->statusCode = SRM_USCORENOT_USCORESUPPORTED; + fileStatus->status->explanation = "srmStatusCopy operation is not supported"; } if(this->hasMissingSurls()) { diff --git a/src/frontend/asynch_status.cpp b/src/frontend/asynch_status.cpp index e85a357..c335452 100644 --- a/src/frontend/asynch_status.cpp +++ b/src/frontend/asynch_status.cpp @@ -345,61 +345,25 @@ extern "C" int ns1__srmStatusOfCopyRequest(struct soap *soap, request->getRequestToken().c_str()); } - bool is_blacklisted; - try { - is_blacklisted = storm::authz::is_blacklisted(soap); - - } catch ( storm::authorization_error& e ){ - - storm::request::register_request_error( - __func__, SRM_USCOREAUTHORIZATION_USCOREFAILURE, start_time, - boost::str(boost::format("%s\n") % e.what())); - rep->srmStatusOfCopyRequestResponse = - storm::build_error_message_response< - ns1__srmStatusOfCopyRequestResponse>(soap, - SRM_USCOREAUTHORIZATION_USCOREFAILURE, - e.what()); - - return SOAP_OK; - } - - if ( is_blacklisted ) { - srmlogit(STORM_LOG_INFO, funcName, "The user is blacklisted\n"); - try { - rep->srmStatusOfCopyRequestResponse = - request->buildSpecificResponse( - SRM_USCOREAUTHORIZATION_USCOREFAILURE, - "User not authorized"); - } catch (std::runtime_error& exc) { - srmlogit(STORM_LOG_ERROR, funcName, - "Unable to build soap response. logic_error: %s\n", - exc.what()); - delete request; - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_STATUS_OF_COPY_REQUEST_MONITOR_NAME); - srmLogResponse("CP status", SRM_USCOREFAILURE); - return soap_sender_fault(soap, exc.what(), 0);; - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_STATUS_OF_COPY_REQUEST_MONITOR_NAME, - request->getStatus()); - srmLogResponse("CP status", request->getStatus()); + request->buildSpecificResponse( + SRM_USCORENOT_USSUPPORTED, + "srmStatusOfCopy operation is not supported"); + } catch (std::runtime_error& exc) { + srmlogit(STORM_LOG_ERROR, funcName, + "Unable to build soap response. logic_error: %s\n", + exc.what()); delete request; - return (SOAP_OK); - } else { - srmlogit(STORM_LOG_DEBUG, funcName, "The user is not blacklisted\n"); + storm::MonitoringHelper::registerOperationError(start_time, + storm::SRM_STATUS_OF_COPY_REQUEST_MONITOR_NAME); + srmLogResponse("CP status", SRM_USCOREFAILURE); + return soap_sender_fault(soap, exc.what(), 0);; } - - int soap_status = processRequestStatus(soap, funcName, *request, - &rep->srmStatusOfCopyRequestResponse); - storm::MonitoringHelper::registerOperation(start_time, soap_status, + storm::MonitoringHelper::registerOperation(start_time, storm::SRM_STATUS_OF_COPY_REQUEST_MONITOR_NAME, - rep->srmStatusOfCopyRequestResponse->returnStatus->statusCode); + request->getStatus()); srmLogResponse("CP status", request->getStatus()); delete request; - return soap_status; - + return (SOAP_OK); } From e510fe1b25f60b0dddc5d767d72837abfea04569 Mon Sep 17 00:00:00 2001 From: enricovianello Date: Wed, 27 May 2015 10:05:09 +0000 Subject: [PATCH 04/12] Fixed wrong SRM status --- src/frontend/asynch_status.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/asynch_status.cpp b/src/frontend/asynch_status.cpp index c335452..42428bc 100644 --- a/src/frontend/asynch_status.cpp +++ b/src/frontend/asynch_status.cpp @@ -348,7 +348,7 @@ extern "C" int ns1__srmStatusOfCopyRequest(struct soap *soap, try { rep->srmStatusOfCopyRequestResponse = request->buildSpecificResponse( - SRM_USCORENOT_USSUPPORTED, + SRM_USCORENOT_USCORESUPPORTED, "srmStatusOfCopy operation is not supported"); } catch (std::runtime_error& exc) { srmlogit(STORM_LOG_ERROR, funcName, From 5a2e7aad1a3324a0173c6544c2b60e6af5b221e0 Mon Sep 17 00:00:00 2001 From: enricovianello Date: Wed, 27 May 2015 13:29:54 +0000 Subject: [PATCH 05/12] Removed all the useless and unused code --- src/frontend/CopyRequest.cpp | 146 ++--------------------------- src/frontend/CopyStatusRequest.cpp | 122 +----------------------- src/frontend/asynch.cpp | 5 +- 3 files changed, 14 insertions(+), 259 deletions(-) diff --git a/src/frontend/CopyRequest.cpp b/src/frontend/CopyRequest.cpp index ee2a22b..2f50e22 100644 --- a/src/frontend/CopyRequest.cpp +++ b/src/frontend/CopyRequest.cpp @@ -34,74 +34,15 @@ void storm::CopyRequest::load(struct ns1__srmCopyRequest* req) if (NULL == req) { throw storm::invalid_request("Request is NULL"); } - if (NULL == req->arrayOfFileRequests) { - throw storm::invalid_request("SURLs array is NULL"); - } - if (0 == req->arrayOfFileRequests->__sizerequestArray) { - throw storm::invalid_request("SURLs array is empty"); - } - - if (getClientDN().size() == 0 && NULL != req->authorizationID) { - m_credentials.setDN(req->authorizationID); - } - - for (int i = 0; i < req->arrayOfFileRequests->__sizerequestArray; ++i) { - m_surls.push_back(SurlPtr( new storm::CopySurl( - req->arrayOfFileRequests->requestArray[i]->sourceSURL, - req->arrayOfFileRequests->requestArray[i]->targetSURL, - req->arrayOfFileRequests->requestArray[i]->dirOption))); - } - - if (NULL != req->userRequestDescription && m_userToken.size() == 0) { - storm::validate_request_description(std::string(req->userRequestDescription)); - m_userToken = sql_string(req->userRequestDescription); - } - if (NULL != req->targetFileStorageType) { - try - { - this->setFileStorageType(*req->targetFileStorageType); - } catch(storm::storm_error& e) - { - throw storm::invalid_request("Unable to load request file storage type. domain_error Exception: " + std::string(e.what())); - } - } - - if (NULL != req->targetSpaceToken) { - m_spaceToken = req->targetSpaceToken; - } - - if (NULL != req->overwriteOption) { - switch(*req->overwriteOption) { - case NEVER: - m_overwrite = DB_OVERWRITE_NEVER; - break; - case ALWAYS: - m_overwrite = DB_OVERWRITE_ALWAYS; - break; - case WHEN_USCOREFILES_USCOREARE_USCOREDIFFERENT: - m_overwrite = DB_OVERWRITE_IF_DIFFERENT; - break; - default: - throw storm::invalid_request("Unable to load Copy request. Invalid overwriteOption"); - } - } - - if (req->desiredTargetSURLLifeTime != NULL) { - m_fileLifetime = *req->desiredTargetSURLLifeTime; - } - - // Temporary hack: proxy saved as a file. TODO: insert the proxy into the DB. + srmlogit(STORM_LOG_DEBUG, "storm::CopyRequest::load", "empty cause srmCopy is not supported"); } ns1__srmCopyResponse* storm::CopyRequest::buildResponse() { + srmlogit(STORM_LOG_DEBUG, "storm::CopyRequest::buildResponse", "called"); - if(m_builtResponse != NULL) - { - return m_builtResponse; - } try { m_builtResponse = storm::soap_calloc(m_soapRequest); @@ -109,89 +50,20 @@ ns1__srmCopyResponse* storm::CopyRequest::buildResponse() } catch (std::invalid_argument& exc) { throw storm::storm_error("Unable to allocate memory for the response. invalid_argument Exception: " + std::string(exc.what())); } - m_builtResponse->returnStatus->statusCode = m_status; - - if (!m_explanation.empty()) { - m_builtResponse->returnStatus->explanation = soap_strdup(m_soapRequest, m_explanation.c_str()); - } - - // Fill per-surl info. - try - { - m_builtResponse->arrayOfFileStatuses = storm::soap_calloc(m_soapRequest); - m_builtResponse->arrayOfFileStatuses->statusArray = storm::soap_calloc( - m_soapRequest, m_surls.size()); - } catch (std::invalid_argument& exc) { - throw storm::storm_error("Unable to allocate memory for the file status array. invalid_argument Exception: " + std::string(exc.what())); - } - m_builtResponse->arrayOfFileStatuses->__sizestatusArray = m_surls.size(); - - int index=0; - std::vector::const_iterator const vectorEnd = m_surls.end(); - for (std::vector::const_iterator i = m_surls.begin(); i != vectorEnd; ++i, ++index) { - ns1__TCopyRequestFileStatus* fileStatus; - try - { - fileStatus = storm::soap_calloc(m_soapRequest); - } catch (std::invalid_argument &exc) { - throw storm::storm_error("Unable to allocate memory for a file status. invalid_argument Exception: " + std::string(exc.what())); - } - m_builtResponse->arrayOfFileStatuses->statusArray[index] = fileStatus; - storm::CopySurl* surl = dynamic_cast (i->get()); - if(!surl) - { - throw std::logic_error("Unable to cast SurlPtr to CopySurl, cast failure"); - } - fileStatus->sourceSURL = soap_strdup(m_soapRequest, surl->getSourceSurl().c_str()); - fileStatus->targetSURL = soap_strdup(m_soapRequest, surl->getDestinationSurl().c_str()); - fileStatus->fileSize = NULL; - fileStatus->estimatedWaitTime = NULL; //should be -1 --> unknown - fileStatus->remainingFileLifetime = NULL; - try - { - fileStatus->status = storm::soap_calloc(m_soapRequest); - } catch (std::invalid_argument &exc) { - throw storm::storm_error("Unable to allocate memory for a return status. invalid_argument Exception: " + std::string(exc.what())); - } - fileStatus->status->statusCode = SRM_USCORENOT_USCORESUPPORTED; - fileStatus->status->explanation = "srmCopy operation is not supported"; - } - if (m_requestToken.size() > 0) { - m_builtResponse->requestToken = soap_strdup(m_soapRequest, m_requestToken.c_str()); - } - - m_builtResponse->remainingTotalRequestTime = NULL; //should be -1 --> try at least once + m_builtResponse->returnStatus->statusCode = SRM_USCORENOT_USCORESUPPORTED; + m_builtResponse->returnStatus->explanation = "srmCopy operation is not supported"; return m_builtResponse; } -void storm::CopyRequest::insertIntoDB(struct srm_dbfd *db) { - +void storm::CopyRequest::insertIntoDB(struct srm_dbfd *db) +{ + srmlogit(STORM_LOG_DEBUG, "storm::CopyRequest::insertIntoDB", "empty cause srmCopy is not supported"); } std::string storm::CopyRequest::getSurlsList() { - std::string builtList; - std::vector::const_iterator const vectorEnd = m_surls.end(); - bool first = true; - for (std::vector::const_iterator i = m_surls.begin(); i != vectorEnd; ++i) { - storm::CopySurl* surl = dynamic_cast (i->get()); - if(!surl) - { - throw std::logic_error("Unable to cast SurlPtr to CopySurl, cast failure"); - } - if(first) - { - first = false; - } - else - { - builtList += ' '; - } - builtList += surl->getSourceSurl(); - builtList += " -> "; - builtList += surl->getDestinationSurl(); + srmlogit(STORM_LOG_DEBUG, "storm::CopyRequest::getSurlsList", "empty cause srmCopy is not supported"); - } - return builtList; + return ""; } diff --git a/src/frontend/CopyStatusRequest.cpp b/src/frontend/CopyStatusRequest.cpp index e0584a3..c489188 100644 --- a/src/frontend/CopyStatusRequest.cpp +++ b/src/frontend/CopyStatusRequest.cpp @@ -23,29 +23,13 @@ const std::string storm::CopyStatusRequest::MONITOR_NAME = storm::SRM_COPY_MONIT void storm::CopyStatusRequest::load(ns1__srmStatusOfCopyRequestRequest* req) { - if(req->arrayOfSourceSURLs == NULL) - { - return; - } - for (int i = 0; i < req->arrayOfSourceSURLs->__sizeurlArray; ++i) { - if(req->arrayOfTargetSURLs != NULL && req->arrayOfSourceSURLs->__sizeurlArray > i) - { - m_surls.insert(SurlPtr(new storm::CopySurl( - req->arrayOfSourceSURLs->urlArray[i], - req->arrayOfTargetSURLs->urlArray[i]))); - } - else - { - m_surls.insert(SurlPtr(new storm::CopySurl( - req->arrayOfSourceSURLs->urlArray[i]))); - m_allTargetSurlSpecified = false; - } - } + srmlogit(STORM_LOG_DEBUG, "storm::CopyStatusRequest::load", "empty cause srmStatusOfCopy is not supported"); + } void storm::CopyStatusRequest::loadFromDB(struct srm_dbfd* db){ - srmlogit(STORM_LOG_DEBUG, "storm::CopyStatusRequest::loadFromDB", "disabled"); + srmlogit(STORM_LOG_DEBUG, "storm::CopyStatusRequest::loadFromDB", "empty cause srmStatusOfCopy is not supported"); } @@ -53,10 +37,6 @@ ns1__srmStatusOfCopyRequestResponse* storm::CopyStatusRequest::buildResponse() { srmlogit(STORM_LOG_DEBUG, "storm::CopyStatusRequest::buildResponse()", "called.\n"); - if(m_builtResponse != NULL) - { - return m_builtResponse; - } try { m_builtResponse = storm::soap_calloc(m_soapRequest); @@ -69,104 +49,10 @@ ns1__srmStatusOfCopyRequestResponse* storm::CopyStatusRequest::buildResponse() m_builtResponse->returnStatus->statusCode = SRM_USCORENOT_USCORESUPPORTED; m_builtResponse->returnStatus->explanation = "srmStatusCopy operation is not supported"; - // Fill status for each surl. - int fileStatusArraySize = (m_surls.size() > m_turls.size() ? m_surls.size() : m_turls.size()); - if(fileStatusArraySize > 0) - { - try - { - m_builtResponse->arrayOfFileStatuses = storm::soap_calloc(m_soapRequest); - m_builtResponse->arrayOfFileStatuses->statusArray = storm::soap_calloc( - m_soapRequest, fileStatusArraySize); - } catch (std::invalid_argument& exc) { - throw std::logic_error("Unable to allocate memory for the file status array. invalid_argument Exception: " + std::string(exc.what())); - } - m_builtResponse->arrayOfFileStatuses->__sizestatusArray = fileStatusArraySize; - int index = 0; - std::set::const_iterator const vectorEnd = m_turls.end(); - for (std::set::const_iterator i = m_turls.begin(); i != vectorEnd; ++i, ++index) { - ns1__TCopyRequestFileStatus *fileStatus; - try - { - fileStatus = storm::soap_calloc(m_soapRequest); - } catch (std::invalid_argument& exc) { - throw std::logic_error("Unable to allocate memory for a file status. invalid_argument Exception: " + std::string(exc.what())); - } - m_builtResponse->arrayOfFileStatuses->statusArray[index] = fileStatus; - - storm::CopyTurl* turl = dynamic_cast (i->get()); - if(!turl) - { - throw std::logic_error("Unable to cast TurlPtr to CopyTurl, cast failure"); - } - fileStatus->sourceSURL = soap_strdup(m_soapRequest, turl->getSourceSurl().getSurl().c_str()); - fileStatus->targetSURL = soap_strdup(m_soapRequest, turl->getDestinationSurl().c_str()); - try - { - fileStatus->status = storm::soap_calloc(m_soapRequest); - } catch (std::invalid_argument& exc) { - throw std::logic_error("Unable to allocate memory for a return status. invalid_argument Exception: " + std::string(exc.what())); - } - fileStatus->status->statusCode = SRM_USCORENOT_USCORESUPPORTED; - fileStatus->status->explanation = "srmStatusCopy operation is not supported"; - } - if(this->hasMissingSurls()) - { - this->addMissingSurls(); - } - } return m_builtResponse; } void storm::CopyStatusRequest::addMissingSurls() { - int index = (m_turls.empty() ? 0 : m_turls.size() - 1); - - std::set::const_iterator const surlVectorEnd = m_surls.end(); - for (std::set::const_iterator i = m_surls.begin(); i != surlVectorEnd; ++i) { - - storm::CopySurl* current = dynamic_cast (i->get()); - if(!current) - { - throw std::logic_error("Unable to cast SurlPtr to CopySurl, cast failure"); - } - if(this->checkSurl(current->getSourceSurl())) - { - continue; - } - ns1__TCopyRequestFileStatus *fileStatus; - try - { - fileStatus = storm::soap_calloc(m_soapRequest); - } catch (std::invalid_argument& exc) { - throw std::logic_error("Unable to allocate memory for a file status. invalid_argument Exception: " + std::string(exc.what())); - } - if(index >= m_builtResponse->arrayOfFileStatuses->__sizestatusArray) - { - throw std::logic_error("Attempt to add more Put Request File Status than allocated!"); - } - m_builtResponse->arrayOfFileStatuses->statusArray[index] = fileStatus; - - fileStatus->fileSize = NULL; - fileStatus->remainingFileLifetime = NULL; - fileStatus->estimatedWaitTime = NULL; - fileStatus->sourceSURL = soap_strdup(m_soapRequest, current->getSourceSurl().c_str()); - if(current->hasDestinationSurl()) - { - fileStatus->targetSURL = soap_strdup(m_soapRequest, current->getDestinationSurl().c_str()); - } - else - { - fileStatus->targetSURL = NULL; - } - try - { - fileStatus->status = storm::soap_calloc(m_soapRequest); - } catch (std::invalid_argument& exc) { - throw std::logic_error("Unable to allocate memory for a return status. invalid_argument Exception: " + std::string(exc.what())); - } - fileStatus->status->statusCode = SRM_USCOREINVALID_USCOREPATH; - fileStatus->status->explanation = soap_strdup(m_soapRequest, "No information about this SURL"); - ++index; - } + srmlogit(STORM_LOG_DEBUG, "storm::CopyStatusRequest::addMissingSurls", "empty cause srmStatusOfCopy is not supported"); } diff --git a/src/frontend/asynch.cpp b/src/frontend/asynch.cpp index 768f88c..5380da1 100644 --- a/src/frontend/asynch.cpp +++ b/src/frontend/asynch.cpp @@ -251,13 +251,10 @@ int ns1__srmCopy(struct soap *soap, struct ns1__srmCopyRequest *req, return SOAP_OK; } - srmLogRequestWithSurls("CP", get_ip(soap).c_str(), - request->getClientDN().c_str(), request->getSurlsList().c_str(), - request->getSurlsNumber()); request->invalidateRequestToken(); try { - rep->srmCopyResponse = request->buildSpecificResponse(SRM_USCORENOT_USCORESUPPORTED, "srmCopy operation is not supported"); + rep->srmCopyResponse = request->buildResponse(); } catch (storm::storm_error& exc) { srmlogit(STORM_LOG_ERROR, funcName,"Unable to build soap response. %s\n", exc.what()); delete request; From 0590506e21a79622f54f4db50806020cd706fbb6 Mon Sep 17 00:00:00 2001 From: enricovianello Date: Thu, 28 May 2015 08:53:13 +0000 Subject: [PATCH 06/12] Removed useless token invalidation --- src/frontend/asynch.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/frontend/asynch.cpp b/src/frontend/asynch.cpp index 5380da1..25d3584 100644 --- a/src/frontend/asynch.cpp +++ b/src/frontend/asynch.cpp @@ -252,7 +252,6 @@ int ns1__srmCopy(struct soap *soap, struct ns1__srmCopyRequest *req, return SOAP_OK; } - request->invalidateRequestToken(); try { rep->srmCopyResponse = request->buildResponse(); } catch (storm::storm_error& exc) { From 22b9da18a467a46b403cd8e05313f890f1df6c8b Mon Sep 17 00:00:00 2001 From: enricovianello Date: Thu, 28 May 2015 09:34:51 +0000 Subject: [PATCH 07/12] Bumped version to 1.8.9 --- configure | 20 ++++++++++---------- configure.ac | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/configure b/configure index 1bd90fe..a4588c3 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.63 for storm frontend server 1.8.8. +# Generated by GNU Autoconf 2.63 for storm frontend server 1.8.9. # # Report bugs to . # @@ -749,8 +749,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='storm frontend server' PACKAGE_TARNAME='storm-frontend-server' -PACKAGE_VERSION='1.8.8' -PACKAGE_STRING='storm frontend server 1.8.8' +PACKAGE_VERSION='1.8.9' +PACKAGE_STRING='storm frontend server 1.8.9' PACKAGE_BUGREPORT='andrea.ceccanti@cnaf.infn.it' ac_unique_file="src/frontend/storm-frontend.cpp" @@ -1565,7 +1565,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures storm frontend server 1.8.8 to adapt to many kinds of systems. +\`configure' configures storm frontend server 1.8.9 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1636,7 +1636,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of storm frontend server 1.8.8:";; + short | recursive ) echo "Configuration of storm frontend server 1.8.9:";; esac cat <<\_ACEOF @@ -1795,7 +1795,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -storm frontend server configure 1.8.8 +storm frontend server configure 1.8.9 generated by GNU Autoconf 2.63 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1813,7 +1813,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by storm frontend server $as_me 1.8.8, which was +It was created by storm frontend server $as_me 1.8.9, which was generated by GNU Autoconf 2.63. Invocation command line was $ $0 $@ @@ -2666,7 +2666,7 @@ fi # Define the identity of the package. PACKAGE='storm-frontend-server' - VERSION='1.8.8' + VERSION='1.8.9' cat >>confdefs.h <<_ACEOF @@ -21395,7 +21395,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by storm frontend server $as_me 1.8.8, which was +This file was extended by storm frontend server $as_me 1.8.9, which was generated by GNU Autoconf 2.63. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21458,7 +21458,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -storm frontend server config.status 1.8.8 +storm frontend server config.status 1.8.9 configured by $0, generated by GNU Autoconf 2.63, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.ac b/configure.ac index a5b036f..1a51c06 100755 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,7 @@ # limitations under the License. AC_PREREQ([2.59]) -AC_INIT([storm frontend server], [1.8.8], andrea.ceccanti@cnaf.infn.it) +AC_INIT([storm frontend server], [1.8.9], andrea.ceccanti@cnaf.infn.it) AC_CONFIG_AUX_DIR([./aux]) AC_CONFIG_MACRO_DIR([m4]) From ec04243aa8a827bc4cd72799f378df6971409dfe Mon Sep 17 00:00:00 2001 From: Andrea Ceccanti Date: Wed, 3 Jun 2015 13:01:42 +0000 Subject: [PATCH 08/12] Reuse port and address --- src/frontend/storm-frontend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/storm-frontend.cpp b/src/frontend/storm-frontend.cpp index c882224..ac7b438 100644 --- a/src/frontend/storm-frontend.cpp +++ b/src/frontend/storm-frontend.cpp @@ -332,7 +332,7 @@ soap* initSoap() { soap_data->accept_timeout = 5; // supporting HTTP GET in order to reply the wsdl soap_data->fget = http_get; - // soap_data->bind_flags |= SO_REUSEADDR; + soap_data->bind_flags = SO_REUSEADDR; int flags = CGSI_OPT_DELEG_FLAG; // Renamed disable with enable and changed checks accordingly From a316e44a6580887ad9a53d0e663eadfd49e7c5b4 Mon Sep 17 00:00:00 2001 From: Andrea Ceccanti Date: Wed, 3 Jun 2015 13:02:01 +0000 Subject: [PATCH 09/12] Faster shutdown --- etc/init.d/storm-frontend-server.in | 6 ------ 1 file changed, 6 deletions(-) diff --git a/etc/init.d/storm-frontend-server.in b/etc/init.d/storm-frontend-server.in index 4c15266..4a4906b 100644 --- a/etc/init.d/storm-frontend-server.in +++ b/etc/init.d/storm-frontend-server.in @@ -153,12 +153,6 @@ case "$1" in echo -n "Stopping $prog.." kill -9 `cat $PIDFILE` >& /dev/null if [ $? -eq 0 ]; then - check_if_running - while [ $? -eq $TRUE ]; do - echo -n "." - sleep 1 - check_if_running - done rm -f $PIDFILE RETVAL=0 echo " ok" From c5298697b15d0971023b309e1b9bbe3f2511566e Mon Sep 17 00:00:00 2001 From: Andrea Ceccanti Date: Wed, 3 Jun 2015 13:30:10 +0000 Subject: [PATCH 10/12] avoid waiting for name resolution on netstat --- etc/init.d/storm-frontend-server.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/init.d/storm-frontend-server.in b/etc/init.d/storm-frontend-server.in index 4a4906b..e826996 100644 --- a/etc/init.d/storm-frontend-server.in +++ b/etc/init.d/storm-frontend-server.in @@ -65,7 +65,7 @@ check_if_running() { if [ $? -ne $SUCCESS ]; then return $FALSE # not running fi - IS_UP=`netstat -lp | grep $PID` + IS_UP=`netstat -lnp | grep $PID` if [ -z "$IS_UP" ]; then return $FALSE # not running fi From 04edb1e39d7b6c1331565c78abd897920ab0af2d Mon Sep 17 00:00:00 2001 From: Andrea Ceccanti Date: Wed, 3 Jun 2015 14:57:12 +0000 Subject: [PATCH 11/12] limit netstat call to tcp sockets --- etc/init.d/storm-frontend-server.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/init.d/storm-frontend-server.in b/etc/init.d/storm-frontend-server.in index e826996..1d9fc08 100644 --- a/etc/init.d/storm-frontend-server.in +++ b/etc/init.d/storm-frontend-server.in @@ -65,7 +65,7 @@ check_if_running() { if [ $? -ne $SUCCESS ]; then return $FALSE # not running fi - IS_UP=`netstat -lnp | grep $PID` + IS_UP=`netstat -tlnp | grep $PID` if [ -z "$IS_UP" ]; then return $FALSE # not running fi From 99f1d0faded37bfda2d0c66bbaf682bd9b8c4baa Mon Sep 17 00:00:00 2001 From: Andrea Ceccanti Date: Thu, 4 Jun 2015 08:37:24 +0000 Subject: [PATCH 12/12] check that socket is released but with shorter sleep time --- etc/init.d/storm-frontend-server.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etc/init.d/storm-frontend-server.in b/etc/init.d/storm-frontend-server.in index 1d9fc08..0e3ac3d 100644 --- a/etc/init.d/storm-frontend-server.in +++ b/etc/init.d/storm-frontend-server.in @@ -153,6 +153,12 @@ case "$1" in echo -n "Stopping $prog.." kill -9 `cat $PIDFILE` >& /dev/null if [ $? -eq 0 ]; then + check_if_running + while [ $? -eq $TRUE ]; do + echo -n "." + sleep .1 + check_if_running + done rm -f $PIDFILE RETVAL=0 echo " ok"