[822] | 1 | /* |
---|
| 2 | * Author : Gérald FENOY |
---|
| 3 | * |
---|
[839] | 4 | * Copyright (c) 2017 GeoLabs SARL |
---|
[822] | 5 | * |
---|
[839] | 6 | * This work was supported by public funds received in the framework of GEOSUD, |
---|
| 7 | * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed |
---|
| 8 | * by the French National Research Agency |
---|
| 9 | * |
---|
[822] | 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
| 11 | * of this software and associated documentation files (the "Software"), to deal |
---|
| 12 | * in the Software without restriction, including without limitation the rights |
---|
| 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
| 14 | * copies of the Software, and to permit persons to whom the Software is |
---|
| 15 | * furnished to do so, subject to the following conditions: |
---|
| 16 | * |
---|
| 17 | * The above copyright notice and this permission notice shall be included in |
---|
| 18 | * all copies or substantial portions of the Software. |
---|
| 19 | * |
---|
| 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
| 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
| 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
| 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
| 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
| 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
| 26 | * THE SOFTWARE. |
---|
| 27 | * |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | #include "service_internal_hpc.h" |
---|
| 31 | #include "response_print.h" |
---|
| 32 | #include "server_internal.h" |
---|
[839] | 33 | #include "service_callback.h" |
---|
| 34 | #include "mimetypes.h" |
---|
[822] | 35 | #include <sys/un.h> |
---|
| 36 | |
---|
[839] | 37 | typedef struct { |
---|
| 38 | maps* conf; |
---|
| 39 | char* local_file; |
---|
| 40 | char* target_file; |
---|
| 41 | } local_params; |
---|
| 42 | |
---|
[846] | 43 | /** |
---|
| 44 | * Add nested outputs to every outputs that is geographic format |
---|
| 45 | * @see isGeographic |
---|
| 46 | * @param s the service current definition |
---|
| 47 | */ |
---|
[839] | 48 | void addNestedOutputs(service** s){ |
---|
| 49 | if((*s)==NULL){ |
---|
| 50 | return; |
---|
| 51 | } |
---|
[877] | 52 | if(*s==NULL || (*s)->outputs==NULL || (*s)->content==NULL){ |
---|
[839] | 53 | return; |
---|
[822] | 54 | } |
---|
[839] | 55 | elements *out=(*s)->outputs; |
---|
| 56 | elements* cur=out; |
---|
| 57 | map* serviceType=getMap((*s)->content,"ServiceType"); |
---|
| 58 | if(strncmp(serviceType->value,"HPC",3)!=0) |
---|
| 59 | return; |
---|
| 60 | while(cur!=NULL && cur->defaults!=NULL){ |
---|
| 61 | map* mimeType=getMap(cur->defaults->content,"mimeType"); |
---|
[862] | 62 | map* useMS=getMap(cur->defaults->content,"useMapserver"); |
---|
| 63 | if(mimeType!=NULL && useMS!=NULL && strncasecmp(useMS->value,"true",4)==0){ |
---|
[839] | 64 | int geo=isGeographic(mimeType->value); |
---|
| 65 | if(geo>0){ |
---|
| 66 | elements *tmp[3]={ |
---|
| 67 | dupElements(cur), |
---|
| 68 | dupElements(cur), |
---|
| 69 | dupElements(cur) |
---|
| 70 | }; |
---|
| 71 | char *geoLink="wcs_link"; |
---|
| 72 | if(geo==2){ |
---|
| 73 | geoLink="wfs_link"; |
---|
| 74 | } |
---|
| 75 | int i=0; |
---|
| 76 | for(;i<3;i++){ |
---|
| 77 | if(tmp[i]->next!=NULL){ |
---|
| 78 | freeElements(&tmp[i]->next); |
---|
| 79 | free(tmp[i]->next); |
---|
| 80 | tmp[i]->next=NULL; |
---|
| 81 | } |
---|
| 82 | free(tmp[i]->name); |
---|
[850] | 83 | if(tmp[i]->format!=NULL) |
---|
| 84 | free(tmp[i]->format); |
---|
[839] | 85 | tmp[i]->format=zStrdup("ComplexData"); |
---|
| 86 | freeMap(&tmp[i]->content); |
---|
| 87 | free(tmp[i]->content); |
---|
| 88 | tmp[i]->content=NULL; |
---|
| 89 | switch(i){ |
---|
| 90 | case 0: |
---|
| 91 | tmp[i]->name=zStrdup("download_link"); |
---|
| 92 | tmp[i]->content=createMap("Title",_("Download link")); |
---|
| 93 | addToMap(tmp[i]->content,"Abstract",_("The download link")); |
---|
| 94 | addToMap(tmp[i]->defaults->content,"useMapserver","false"); |
---|
| 95 | if(tmp[i]->supported!=NULL){ |
---|
| 96 | freeIOType(&tmp[i]->supported); |
---|
| 97 | free(tmp[i]->supported); |
---|
| 98 | tmp[i]->supported=NULL; |
---|
| 99 | } |
---|
| 100 | break; |
---|
| 101 | case 1: |
---|
| 102 | tmp[i]->name=zStrdup("wms_link"); |
---|
| 103 | tmp[i]->content=createMap("Title",_("WMS link")); |
---|
| 104 | addToMap(tmp[i]->content,"Abstract",_("The WMS link")); |
---|
| 105 | if(tmp[i]->supported!=NULL && tmp[i]->supported->next!=NULL){ |
---|
| 106 | freeIOType(&tmp[i]->supported->next); |
---|
| 107 | free(tmp[i]->supported->next); |
---|
| 108 | tmp[i]->supported->next=NULL; |
---|
| 109 | }else{ |
---|
| 110 | if(tmp[i]->supported!=NULL) |
---|
| 111 | addToMap(tmp[i]->supported->content,"useMapserver","true"); |
---|
| 112 | addToMap(tmp[i]->defaults->content,"useMapserver","true"); |
---|
| 113 | } |
---|
| 114 | break; |
---|
| 115 | case 2: |
---|
| 116 | if(geo==2){ |
---|
| 117 | tmp[i]->name=zStrdup("wfs_link"); |
---|
| 118 | tmp[i]->content=createMap("Title",_("WFS link")); |
---|
| 119 | addToMap(tmp[i]->content,"Abstract",_("The WFS link")); |
---|
| 120 | }else{ |
---|
| 121 | tmp[i]->name=zStrdup("wcs_link"); |
---|
| 122 | tmp[i]->content=createMap("Title",_("WCS link")); |
---|
| 123 | addToMap(tmp[i]->content,"Abstract",_("The WCS link")); |
---|
| 124 | } |
---|
| 125 | if(tmp[i]->supported!=NULL && tmp[i]->supported->next!=NULL && |
---|
| 126 | tmp[i]->supported->next->content!=NULL){ |
---|
| 127 | freeIOType(&tmp[i]->supported); |
---|
| 128 | free(tmp[i]->supported); |
---|
| 129 | tmp[i]->supported=NULL; |
---|
| 130 | tmp[i]->supported=createIoType(); |
---|
| 131 | iotype* cnext=cur->supported->next; |
---|
| 132 | tmp[i]->supported->content=createMap(cnext->content->name,cnext->content->value); |
---|
| 133 | addMapToMap(&tmp[i]->supported->content,cnext->content->next); |
---|
| 134 | addToMap(tmp[i]->supported->content,"useMapserver","true"); |
---|
| 135 | }else |
---|
| 136 | addToMap(tmp[i]->defaults->content,"useMapserver","true"); |
---|
| 137 | break; |
---|
| 138 | } |
---|
| 139 | } |
---|
| 140 | addToElements(&cur->child,tmp[0]); |
---|
| 141 | addToElements(&cur->child,tmp[1]); |
---|
| 142 | addToElements(&cur->child,tmp[2]); |
---|
| 143 | free(cur->format); |
---|
| 144 | cur->format=NULL; |
---|
| 145 | if(cur->defaults!=NULL){ |
---|
| 146 | freeIOType(&cur->defaults); |
---|
[854] | 147 | free(cur->defaults); |
---|
[839] | 148 | cur->defaults=NULL; |
---|
| 149 | } |
---|
| 150 | if(cur->supported!=NULL){ |
---|
| 151 | freeIOType(&cur->supported); |
---|
[854] | 152 | free(cur->supported); |
---|
[839] | 153 | cur->supported=NULL; |
---|
| 154 | } |
---|
| 155 | freeElements(&tmp[2]); |
---|
| 156 | free(tmp[2]); |
---|
| 157 | freeElements(&tmp[1]); |
---|
| 158 | free(tmp[1]); |
---|
| 159 | freeElements(&tmp[0]); |
---|
| 160 | free(tmp[0]); |
---|
| 161 | //addToMap(cur->content,"internal","true"); |
---|
[862] | 162 | } |
---|
[839] | 163 | } |
---|
| 164 | cur=cur->next; |
---|
| 165 | } |
---|
[850] | 166 | //dumpElements((*s)->outputs); |
---|
[822] | 167 | } |
---|
| 168 | |
---|
| 169 | /** |
---|
[854] | 170 | * Acquire a read lock on every files used as input for executing a service. |
---|
| 171 | * @param conf the main configuration file map |
---|
| 172 | * @return 0 if every file can be locked, -1 if one lock has failed. |
---|
| 173 | */ |
---|
| 174 | int addReadLocks(maps** conf){ |
---|
| 175 | map* queueLengthMap=getMapFromMaps(*conf,"uploadQueue","length"); |
---|
| 176 | maps* queueMaps=getMaps(*conf,"uploadQueue"); |
---|
| 177 | if(queueLengthMap!=NULL){ |
---|
| 178 | int cnt=atoi(queueLengthMap->value); |
---|
| 179 | int i=0; |
---|
| 180 | for(i=0;i<cnt;i++){ |
---|
| 181 | map* argv[2]={ |
---|
| 182 | getMapArray(queueMaps->content,"input",i), |
---|
| 183 | getMapArray(queueMaps->content,"localPath",i) |
---|
| 184 | }; |
---|
| 185 | zooLock* lck; |
---|
| 186 | if((lck=lockFile(*conf,argv[1]->value,'r'))==NULL){ |
---|
| 187 | char* templateStr=_("Unable to lock the file for %s in read mode."); |
---|
| 188 | char *tmpMessage=(char*)malloc((strlen(templateStr)+strlen(argv[0]->value)+1)*sizeof(char)); |
---|
| 189 | sprintf(tmpMessage,templateStr,argv[0]->value); |
---|
| 190 | setMapInMaps(*conf,"lenv","message",tmpMessage); |
---|
| 191 | free(tmpMessage); |
---|
| 192 | return -1; |
---|
| 193 | }else{ |
---|
| 194 | if(zoo_file_locks_cnt==0){ |
---|
| 195 | zoo_file_locks=(zooLock**)malloc(sizeof(zooLock*)); |
---|
| 196 | } |
---|
| 197 | else{ |
---|
| 198 | zoo_file_locks=(zooLock**)realloc(zoo_file_locks,(zoo_file_locks_cnt+1)*sizeof(zooLock*)); |
---|
| 199 | } |
---|
| 200 | zoo_file_locks[zoo_file_locks_cnt]=lck; |
---|
| 201 | zoo_file_locks_cnt++; |
---|
| 202 | } |
---|
| 203 | } |
---|
| 204 | } |
---|
| 205 | return 0; |
---|
| 206 | } |
---|
| 207 | |
---|
| 208 | /** |
---|
| 209 | * Remove all read locks set for files used as input for executing the service. |
---|
| 210 | * @param conf the main configuration maps pointer |
---|
| 211 | * @return 0 in case of success, -1 if any error occured. In case of error, one |
---|
| 212 | * can refer to the message map array from the lenv section. |
---|
| 213 | */ |
---|
| 214 | int removeReadLocks(maps** conf){ |
---|
| 215 | int res=0; |
---|
| 216 | int nberr=0; |
---|
| 217 | map* queueLengthMap=getMapFromMaps(*conf,"uploadQueue","length"); |
---|
| 218 | maps* queueMaps=getMaps(*conf,"uploadQueue"); |
---|
| 219 | if(queueLengthMap!=NULL){ |
---|
| 220 | int cnt=atoi(queueLengthMap->value); |
---|
| 221 | int i=0; |
---|
| 222 | for(i=0;i<cnt;i++){ |
---|
| 223 | if(unlockFile(*conf,zoo_file_locks[i])<1){ |
---|
| 224 | map* argv=getMapArray(queueMaps->content,"input",i); |
---|
| 225 | char* templateStr=_("Unable to unlock the file for %s after execution."); |
---|
| 226 | char *tmpMessage=(char*)malloc((strlen(templateStr)+strlen(argv->value)+1)*sizeof(char)); |
---|
| 227 | sprintf(tmpMessage,templateStr,argv->value); |
---|
| 228 | maps* lenv=getMaps(*conf,"lenv"); |
---|
| 229 | setMapArray(lenv->content,"message",nberr,tmpMessage); |
---|
| 230 | free(tmpMessage); |
---|
| 231 | res=-1; |
---|
| 232 | nberr++; |
---|
| 233 | } |
---|
| 234 | } |
---|
| 235 | } |
---|
| 236 | free(zoo_file_locks); |
---|
| 237 | return res; |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | /** |
---|
| 241 | * Get the section name depending on number of features and/or pixels of each |
---|
| 242 | * inputs and the threshold defined in a section. |
---|
| 243 | * It supposes that your inputs has been published using MapServer support, |
---|
| 244 | * implying that the number of features (nb_features), respectively pixels |
---|
| 245 | * (nb_pixels), are defined. The section, identified by confId, should contain |
---|
| 246 | * preview_max_features and preview_max_pixels defining the threshold values. |
---|
| 247 | * @param conf the main configuration file maps pointer |
---|
| 248 | * @param inputs the inputs maps pointer |
---|
| 249 | * @param confId the section identifier |
---|
| 250 | * @return "preview_conf" in case the numbers are lower than the threshold, |
---|
| 251 | * "fullres_conf" in other cases. |
---|
| 252 | */ |
---|
| 253 | char* getConfiguration(maps** conf,maps** inputs,const char* confId){ |
---|
| 254 | maps* input=*inputs; |
---|
| 255 | map* max_pixels=getMapFromMaps(*conf,confId,"preview_max_pixels"); |
---|
| 256 | map* max_features=getMapFromMaps(*conf,confId,"preview_max_features"); |
---|
| 257 | int i_max_pixels=atoi(max_pixels->value); |
---|
| 258 | int i_max_features=atoi(max_features->value); |
---|
| 259 | while(input!=NULL && input->content!=NULL){ |
---|
| 260 | map* tmpMap=getMap(input->content,"geodatatype"); |
---|
| 261 | if(tmpMap!=NULL){ |
---|
| 262 | map* currentNb; |
---|
| 263 | if(strcasecmp(tmpMap->value,"raster")==0 ){ |
---|
| 264 | currentNb=getMap(input->content,"nb_pixels"); |
---|
| 265 | if(atoi(currentNb->value)>i_max_pixels) |
---|
| 266 | return "fullres_conf"; |
---|
| 267 | }else{ |
---|
| 268 | if(strcasecmp(tmpMap->value,"vector")==0 ){ |
---|
| 269 | currentNb=getMap(input->content,"nb_features"); |
---|
| 270 | if(atoi(currentNb->value)>i_max_features) |
---|
| 271 | return "fullres_conf"; |
---|
| 272 | } |
---|
| 273 | } |
---|
| 274 | } |
---|
| 275 | input=input->next; |
---|
| 276 | } |
---|
| 277 | return "preview_conf"; |
---|
| 278 | } |
---|
| 279 | |
---|
| 280 | /** |
---|
[822] | 281 | * Load and run a HPC Application corresponding to the service. |
---|
| 282 | * |
---|
| 283 | * @param main_conf the conf maps containing the main.cfg settings |
---|
| 284 | * @param request the map containing the HTTP request |
---|
| 285 | * @param s the service structure |
---|
| 286 | * @param real_inputs the maps containing the inputs |
---|
| 287 | * @param real_outputs the maps containing the outputs |
---|
[860] | 288 | * @return SERVICE_SUCCEEDED in case of success, -1 or SERVICE_FAILED when failing. |
---|
[822] | 289 | */ |
---|
| 290 | int zoo_hpc_support(maps** main_conf,map* request,service* s,maps **real_inputs,maps **real_outputs){ |
---|
| 291 | maps* m=*main_conf; |
---|
| 292 | maps* inputs=*real_inputs; |
---|
| 293 | maps* outputs=*real_outputs; |
---|
| 294 | map* tmp0=getMapFromMaps(*main_conf,"lenv","cwd"); |
---|
| 295 | char *ntmp=tmp0->value; |
---|
| 296 | map* tmp=NULL; |
---|
| 297 | int res=-1; |
---|
[854] | 298 | // Get the configuration id depending on service type and defined thresholds |
---|
| 299 | // then, set the configId key in the lenv section |
---|
[839] | 300 | char *serviceType; |
---|
[886] | 301 | map* mServiceType=getMap(s->content,"confId"); |
---|
[839] | 302 | if(mServiceType!=NULL) |
---|
| 303 | serviceType=mServiceType->value; |
---|
| 304 | else |
---|
| 305 | serviceType="HPC"; |
---|
[822] | 306 | map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath"); |
---|
| 307 | map* uuid=getMapFromMaps(*main_conf,"lenv","usid"); |
---|
[854] | 308 | map* confMap=getMapFromMaps(*main_conf,serviceType,getConfiguration(main_conf,real_inputs,serviceType)); |
---|
| 309 | char * configurationId=confMap->value; |
---|
| 310 | setMapInMaps(*main_conf,"lenv","configId",configurationId); |
---|
| 311 | // Dump lenv maps again after having set the configId ... |
---|
| 312 | char *flenv = |
---|
| 313 | (char *) |
---|
| 314 | malloc ((strlen (tmpPath->value) + |
---|
| 315 | strlen (uuid->value) + 12) * sizeof (char)); |
---|
| 316 | sprintf (flenv, "%s/%s_lenv.cfg", tmpPath->value, uuid->value); |
---|
| 317 | maps* lenvMaps=getMaps(m,"lenv"); |
---|
| 318 | dumpMapsToFile(lenvMaps,flenv,0); |
---|
| 319 | free(flenv); |
---|
| 320 | |
---|
| 321 | map* targetPathMap=getMapFromMaps(*main_conf,configurationId,"remote_data_path"); |
---|
[888] | 322 | map* targetPersistentPathMap=getMapFromMaps(*main_conf,configurationId,"remote_persistent_data_path"); |
---|
[854] | 323 | |
---|
[839] | 324 | pthread_t threads_pool[50]; |
---|
| 325 | // Force the HPC services to be called asynchronously |
---|
| 326 | map* isAsync=getMapFromMaps(*main_conf,"lenv","async"); |
---|
| 327 | if(isAsync==NULL){ |
---|
| 328 | errorException(*main_conf,_("The synchronous mode is not supported by this type of service"),"NoSuchMode",s->name); |
---|
| 329 | return -1; |
---|
| 330 | } |
---|
[822] | 331 | |
---|
| 332 | maps* input=*real_inputs; |
---|
| 333 | char **parameters=NULL; |
---|
| 334 | int parameters_cnt=0; |
---|
[839] | 335 | while(input!=NULL && input->content!=NULL){ |
---|
[862] | 336 | map* isInRequest=getMap(input->content,"inRequest"); |
---|
[886] | 337 | map* minNb=getMap(input->content,"minOccurs"); |
---|
[862] | 338 | if(getMaps(*real_outputs,input->name)==NULL && |
---|
| 339 | ( (isInRequest!=NULL && strncasecmp(isInRequest->value,"true",4)==0) |
---|
| 340 | || (minNb!=NULL && atoi(minNb->value)>0) ) ){ |
---|
[839] | 341 | parameters_cnt+=1; |
---|
| 342 | if(parameters_cnt==1) |
---|
| 343 | parameters=(char**)malloc(parameters_cnt*sizeof(char*)); |
---|
| 344 | else |
---|
| 345 | parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*)); |
---|
| 346 | if(getMap(input->content,"mimeType")!=NULL){ |
---|
| 347 | // Input is ComplexData |
---|
| 348 | if(getMap(input->content,"cache_file")==NULL){ |
---|
| 349 | // Input data has been passed by value |
---|
| 350 | // TODO: publish input through MapServer / use output publication |
---|
| 351 | dumpMapsValuesToFiles(main_conf,&input); |
---|
| 352 | addToMap(input->content,"toPublish","true"); |
---|
[862] | 353 | //addToMap(input->content,"useMapserver","true"); |
---|
[839] | 354 | } |
---|
| 355 | if(getMap(input->content,"cache_file")!=NULL){ |
---|
| 356 | map* length=getMap(input->content,"length"); |
---|
| 357 | if(length==NULL){ |
---|
| 358 | addToMap(input->content,"length","1"); |
---|
| 359 | length=getMap(input->content,"length"); |
---|
| 360 | } |
---|
| 361 | int len=atoi(length->value); |
---|
| 362 | int i=0; |
---|
| 363 | for(i=0;i<len;i++){ |
---|
| 364 | map* tmp=getMapArray(input->content,"cache_file",i); |
---|
[888] | 365 | map* origin=getMapArray(input->content,"origin",i); |
---|
[839] | 366 | char* targetName=strrchr(tmp->value,'/'); |
---|
[888] | 367 | char *targetPath; |
---|
| 368 | if(origin!=NULL && strcasecmp(origin->value,"SHARED")==0 && targetPersistentPathMap!=NULL){ |
---|
| 369 | targetPath=(char*)malloc((strlen(targetPersistentPathMap->value)+strlen(targetName)+2)*sizeof(char)); |
---|
| 370 | sprintf(targetPath,"%s/%s",targetPersistentPathMap->value,targetName); |
---|
| 371 | } |
---|
| 372 | else{ |
---|
| 373 | targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); |
---|
| 374 | sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); |
---|
| 375 | } |
---|
[839] | 376 | setMapArray(input->content,"targetPath",i,targetPath); |
---|
| 377 | setMapArray(input->content,"localPath",i,tmp->value); |
---|
[862] | 378 | map* tmp1=getMapArray(input->content,"value",i); |
---|
| 379 | if(tmp1!=NULL){ |
---|
| 380 | free(tmp1->value); |
---|
| 381 | tmp1->value=strdup("empty"); |
---|
| 382 | } |
---|
[839] | 383 | if(i==0){ |
---|
| 384 | parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char)); |
---|
| 385 | sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath); |
---|
| 386 | }else{ |
---|
[862] | 387 | fprintf(stderr,"%s %d\n",__FILE__,__LINE__); |
---|
| 388 | fflush(stderr); |
---|
[839] | 389 | char *tmpStr=zStrdup(parameters[parameters_cnt-1]); |
---|
| 390 | parameters[parameters_cnt-1]=(char*)realloc(parameters[parameters_cnt-1],(strlen(tmpStr)+strlen(targetPath)+2)*sizeof(char)); |
---|
| 391 | sprintf(parameters[parameters_cnt-1],"%s %s",tmpStr,targetPath); |
---|
| 392 | free(tmpStr); |
---|
[862] | 393 | fprintf(stderr,"%s %d\n",__FILE__,__LINE__); |
---|
| 394 | fflush(stderr); |
---|
[839] | 395 | } |
---|
| 396 | free(targetPath); |
---|
| 397 | } |
---|
[862] | 398 | addToUploadQueue(main_conf,input); |
---|
[839] | 399 | }else{ |
---|
| 400 | // ??? |
---|
| 401 | fprintf(stderr,"%s %d\n",__FILE__,__LINE__); |
---|
| 402 | fflush(stderr); |
---|
| 403 | } |
---|
[822] | 404 | }else{ |
---|
[839] | 405 | // LitteralData and BboxData |
---|
| 406 | if(getMap(input->content,"dataType")!=NULL){ |
---|
| 407 | // For LitteralData, simply pass the value |
---|
[886] | 408 | map* length=getMap(input->content,"length"); |
---|
| 409 | if(length!=NULL){ |
---|
| 410 | char* value=NULL; |
---|
| 411 | int len=atoi(length->value); |
---|
| 412 | int i=0; |
---|
| 413 | for(i=0;i<len;i++){ |
---|
| 414 | map* val=getMapArray(input->content,"value",i); |
---|
| 415 | if(val!=NULL){ |
---|
| 416 | if(value==NULL){ |
---|
| 417 | value=(char*)malloc((strlen(val->value)+3)*sizeof(char)); |
---|
| 418 | sprintf(value,"\"%s\"",val->value); |
---|
| 419 | } |
---|
| 420 | else{ |
---|
| 421 | value=(char*)realloc(value,(strlen(value)+strlen(val->value)+4)*sizeof(char)); |
---|
| 422 | sprintf(value,"%s \"%s\"",value,val->value); |
---|
| 423 | } |
---|
| 424 | } |
---|
| 425 | } |
---|
| 426 | if(value!=NULL){ |
---|
| 427 | parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(value)+3)*sizeof(char)); |
---|
| 428 | sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,value); |
---|
| 429 | } |
---|
| 430 | }else{ |
---|
| 431 | map* val=getMap(input->content,"value"); |
---|
| 432 | parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(val->value)+5)*sizeof(char)); |
---|
| 433 | sprintf(parameters[parameters_cnt-1],"-%s \"%s\"",input->name,val->value); |
---|
| 434 | } |
---|
[839] | 435 | } |
---|
[822] | 436 | } |
---|
| 437 | } |
---|
| 438 | input=input->next; |
---|
| 439 | } |
---|
| 440 | |
---|
[860] | 441 | #ifdef HPC_DEBUG |
---|
[839] | 442 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
[860] | 443 | #endif |
---|
| 444 | invokeCallback(m,inputs,NULL,1,1); |
---|
[862] | 445 | invokeCallback(m,inputs,NULL,2,0); |
---|
[854] | 446 | if(getMapFromMaps(m,"lenv","mapError")!=NULL){ |
---|
[862] | 447 | invokeCallback(*main_conf,inputs,NULL,7,0); |
---|
[854] | 448 | return -1; |
---|
| 449 | } |
---|
[860] | 450 | #ifdef HPC_DEBUG |
---|
| 451 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 452 | dumpMaps(inputs); |
---|
| 453 | #endif |
---|
[839] | 454 | |
---|
| 455 | // Upload data on HPC |
---|
[854] | 456 | if(runUpload(main_conf)==false){ |
---|
[862] | 457 | errorException (*main_conf, _("Unable to lock the file for upload!"), |
---|
[854] | 458 | "InternalError", NULL); |
---|
[860] | 459 | #ifdef HPC_DEBUG |
---|
[854] | 460 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
[860] | 461 | #endif |
---|
[862] | 462 | invokeCallback(*main_conf,inputs,NULL,7,0); |
---|
[860] | 463 | #ifdef HPC_DEBUG |
---|
[854] | 464 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
[860] | 465 | #endif |
---|
[854] | 466 | return -1; |
---|
| 467 | } |
---|
[860] | 468 | #ifdef HPC_DEBUG |
---|
[839] | 469 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
[860] | 470 | #endif |
---|
[839] | 471 | invokeCallback(m,inputs,NULL,2,1); |
---|
[860] | 472 | #ifdef HPC_DEBUG |
---|
[839] | 473 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
[860] | 474 | #endif |
---|
[839] | 475 | |
---|
[854] | 476 | // Add the filename to generate for every output to parameters |
---|
[822] | 477 | input=*real_outputs; |
---|
[860] | 478 | #ifdef HPC_DEBUG |
---|
[854] | 479 | dumpMaps(input); |
---|
[860] | 480 | #endif |
---|
[822] | 481 | while(input!=NULL){ |
---|
[862] | 482 | // Parse all outputs including inner outputs if required. |
---|
[822] | 483 | if(input->child==NULL){ |
---|
| 484 | // Name every files that should be produced by the service execution |
---|
[839] | 485 | map* mime=getMap(input->content,"mimeType"); |
---|
| 486 | char* targetName; |
---|
| 487 | if(mime!=NULL){ |
---|
| 488 | bool hasExt=false; |
---|
| 489 | map* fileExt=getFileExtensionMap(mime->value,&hasExt); |
---|
| 490 | targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+strlen(fileExt->value)+11)*sizeof(char)); |
---|
| 491 | sprintf(targetName,"output_%s_%s_%s.%s",s->name,input->name,uuid->value,fileExt->value); |
---|
| 492 | freeMap(&fileExt); |
---|
| 493 | free(fileExt); |
---|
| 494 | }else{ |
---|
| 495 | targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+14)*sizeof(char)); |
---|
| 496 | sprintf(targetName,"output_%s_%s_%s.tif",s->name,input->name,uuid->value); |
---|
| 497 | } |
---|
[822] | 498 | char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); |
---|
| 499 | sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); |
---|
[862] | 500 | map *tmpUrl=getMapFromMaps(*main_conf,"main","tmpUrl"); |
---|
| 501 | char *targetUrl=(char*)malloc((strlen(tmpUrl->value)+strlen(targetName)+2)*sizeof(char)); |
---|
| 502 | sprintf(targetUrl,"%s/%s",tmpUrl->value,targetName); |
---|
[851] | 503 | free(targetName); |
---|
[822] | 504 | setMapInMaps(*real_outputs,input->name,"generated_file",targetPath); |
---|
[862] | 505 | addToMap(input->content,"generated_url",targetUrl); |
---|
| 506 | free(targetUrl); |
---|
| 507 | { |
---|
[854] | 508 | parameters_cnt+=1; |
---|
| 509 | if(parameters_cnt==1) |
---|
| 510 | parameters=(char**)malloc(parameters_cnt*sizeof(char*)); |
---|
| 511 | else |
---|
| 512 | parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*)); |
---|
| 513 | // We should verify if any optional tag for output is required |
---|
| 514 | // (i.e. -out output.tiff *int8*), meaning that we should search |
---|
| 515 | // for a corresponding inputs name. |
---|
| 516 | map* inValue=getMapFromMaps(*real_inputs,input->name,"value"); |
---|
| 517 | if(inValue!=NULL){ |
---|
| 518 | parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+strlen(inValue->value)+4)*sizeof(char)); |
---|
| 519 | sprintf(parameters[parameters_cnt-1],"-%s %s %s",input->name,targetPath,inValue->value); |
---|
| 520 | }else{ |
---|
| 521 | parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char)); |
---|
| 522 | sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath); |
---|
| 523 | } |
---|
[839] | 524 | } |
---|
| 525 | free(targetPath); |
---|
| 526 | }// In other case it means we need to return the cache_file as generated_file |
---|
| 527 | else{ |
---|
| 528 | // Name every files that should be produced by the service execution |
---|
| 529 | map* mime=getMap(input->child->content,"mimeType"); |
---|
| 530 | char* targetName; |
---|
| 531 | if(mime!=NULL){ |
---|
| 532 | bool hasExt=false; |
---|
| 533 | map* fileExt=getFileExtensionMap(mime->value,&hasExt); |
---|
| 534 | targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+strlen(fileExt->value)+11)*sizeof(char)); |
---|
| 535 | sprintf(targetName,"output_%s_%s_%s.%s",s->name,input->name,uuid->value,fileExt->value); |
---|
| 536 | freeMap(&fileExt); |
---|
| 537 | free(fileExt); |
---|
| 538 | }else{ |
---|
| 539 | targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+14)*sizeof(char)); |
---|
| 540 | sprintf(targetName,"output_%s_%s_%s.tif",s->name,input->name,uuid->value); |
---|
| 541 | } |
---|
| 542 | char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); |
---|
| 543 | sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); |
---|
[862] | 544 | map *tmpUrl=getMapFromMaps(*main_conf,"main","tmpUrl"); |
---|
| 545 | char *targetUrl=(char*)malloc((strlen(tmpUrl->value)+strlen(targetName)+2)*sizeof(char)); |
---|
| 546 | sprintf(targetUrl,"%s/%s",tmpUrl->value,targetName); |
---|
[851] | 547 | free(targetName); |
---|
[839] | 548 | addToMap(input->content,"generated_file",targetPath); |
---|
[854] | 549 | addToMap(input->content,"storage",targetPath); |
---|
[862] | 550 | addToMap(input->content,"generated_url",targetUrl); |
---|
| 551 | free(targetUrl); |
---|
[854] | 552 | if(strcasecmp(input->name,"wms_link")!=0&& |
---|
| 553 | strcasecmp(input->name,"wcs_link")!=0 && |
---|
| 554 | strcasecmp(input->name,"wfs_link")!=0){ |
---|
| 555 | parameters_cnt+=1; |
---|
| 556 | if(parameters_cnt==1) |
---|
| 557 | parameters=(char**)malloc(parameters_cnt*sizeof(char*)); |
---|
| 558 | else |
---|
| 559 | parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*)); |
---|
| 560 | // We should verify if any optional tag for output is required |
---|
| 561 | // (i.e. -out output.tiff *int8*), meaning that we should search |
---|
| 562 | // for a corresponding inputs name. |
---|
| 563 | map* inValue=getMapFromMaps(*real_inputs,input->name,"value"); |
---|
| 564 | if(inValue!=NULL){ |
---|
| 565 | parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+strlen(inValue->value)+4)*sizeof(char)); |
---|
| 566 | sprintf(parameters[parameters_cnt-1],"-%s %s %s",input->name,targetPath,inValue->value); |
---|
| 567 | }else{ |
---|
| 568 | parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char)); |
---|
| 569 | sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath); |
---|
| 570 | } |
---|
[839] | 571 | } |
---|
| 572 | free(targetPath); |
---|
[822] | 573 | } |
---|
| 574 | input=input->next; |
---|
| 575 | } |
---|
| 576 | // Produce the SBATCH File locally |
---|
[839] | 577 | char *scriptPath=(char*)malloc((strlen(s->name)+strlen(tmpPath->value)+strlen(uuid->value)+10)*sizeof(char)); |
---|
[822] | 578 | sprintf(scriptPath,"%s/zoo_%s_%s.sh",tmpPath->value,s->name,uuid->value); |
---|
[839] | 579 | setMapInMaps(*main_conf,"lenv","local_script",scriptPath); |
---|
[860] | 580 | #ifdef HPC_DEBUG |
---|
[839] | 581 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 582 | fflush(stderr); |
---|
[860] | 583 | #endif |
---|
[839] | 584 | invokeCallback(m,inputs,NULL,3,0); |
---|
[860] | 585 | #ifdef HPC_DEBUG |
---|
[839] | 586 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 587 | fflush(stderr); |
---|
[860] | 588 | #endif |
---|
[822] | 589 | FILE* scriptFile=fopen(scriptPath,"w+"); |
---|
[854] | 590 | map* headerMap=getMapFromMaps(*main_conf,configurationId,"jobscript_header"); |
---|
[822] | 591 | if(headerMap!=NULL){ |
---|
| 592 | // Use the header file if defined in the HPC section of the main.cfg file |
---|
| 593 | struct stat f_status; |
---|
| 594 | int s=stat(headerMap->value, &f_status); |
---|
| 595 | if(s==0){ |
---|
| 596 | char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); |
---|
| 597 | FILE* f=fopen(headerMap->value,"rb"); |
---|
| 598 | fread(fcontent,f_status.st_size,1,f); |
---|
| 599 | int fsize=f_status.st_size; |
---|
| 600 | fcontent[fsize]=0; |
---|
| 601 | fclose(f); |
---|
[839] | 602 | fprintf(scriptFile,"%s\n### --- ZOO-Service HEADER end --- ###\n\n",fcontent); |
---|
[822] | 603 | free(fcontent); |
---|
| 604 | }else |
---|
| 605 | fprintf(scriptFile,"#!/bin/bash\n\n### *** Default ZOO-Service HEADER (no header found) *** ###\n\n"); |
---|
| 606 | }else |
---|
| 607 | fprintf(scriptFile,"#!/bin/bash\n\n### *** Default ZOO-Service HEADER *** ###\n\n"); |
---|
[854] | 608 | maps* hpc_opts=getMaps(*main_conf,configurationId); |
---|
[839] | 609 | if(hpc_opts!=NULL){ |
---|
| 610 | map* hpc_opts_content=hpc_opts->content; |
---|
| 611 | while(hpc_opts_content!=NULL){ |
---|
[854] | 612 | if(strncasecmp(hpc_opts_content->name,"sbatch_options_",15)==0) |
---|
| 613 | fprintf(scriptFile,"#SBATCH --%s=%s\n",strstr(hpc_opts_content->name,"sbatch_options_")+15,hpc_opts_content->value); |
---|
[839] | 614 | hpc_opts_content=hpc_opts_content->next; |
---|
| 615 | } |
---|
[822] | 616 | } |
---|
| 617 | fprintf(scriptFile,"#SBATCH --job-name=ZOO-Project_%s_%s\n\n",uuid->value,s->name); |
---|
| 618 | map* mods=getMap(s->content,"hpcModules"); |
---|
| 619 | if(mods!=NULL) |
---|
| 620 | fprintf(scriptFile,"#SBATCH --export=MODULES=%s\n",mods->value); |
---|
[839] | 621 | |
---|
[854] | 622 | map* bodyMap=getMapFromMaps(*main_conf,configurationId,"jobscript_body"); |
---|
[839] | 623 | if(bodyMap!=NULL){ |
---|
| 624 | // Use the header file if defined in the HPC section of the main.cfg file |
---|
| 625 | struct stat f_status; |
---|
| 626 | int s=stat(bodyMap->value, &f_status); |
---|
| 627 | if(s==0){ |
---|
| 628 | char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); |
---|
| 629 | FILE* f=fopen(bodyMap->value,"rb"); |
---|
| 630 | fread(fcontent,f_status.st_size,1,f); |
---|
| 631 | int fsize=f_status.st_size; |
---|
| 632 | fcontent[fsize]=0; |
---|
| 633 | fclose(f); |
---|
| 634 | fprintf(scriptFile,"%s\n### --- ZOO-Service BODY end --- ###\n\n",fcontent); |
---|
| 635 | free(fcontent); |
---|
| 636 | }else |
---|
[860] | 637 | fprintf(scriptFile,"\n### *** Default ZOO-Service BODY (no body found) *** ###\n\n"); |
---|
[839] | 638 | }else |
---|
[860] | 639 | fprintf(scriptFile,"\n### *** Default ZOO-Service BODY *** ###\n\n"); |
---|
[839] | 640 | |
---|
[822] | 641 | map* sp=getMap(s->content,"serviceProvider"); |
---|
[839] | 642 | |
---|
[822] | 643 | // Require to produce the command line to be executed |
---|
| 644 | fprintf(scriptFile,"\n\necho \"Job started at: $(date)\"\n"); |
---|
| 645 | fprintf(scriptFile,"echo \"Running service: [%s]\"\n",sp->value); |
---|
| 646 | fprintf(scriptFile,"%s ",sp->value); |
---|
| 647 | for(int i=0;i<parameters_cnt;i++){ |
---|
| 648 | fprintf(scriptFile," %s",parameters[i]); |
---|
| 649 | } |
---|
[839] | 650 | for(int i=parameters_cnt-1;i>=0;i--){ |
---|
| 651 | free(parameters[i]); |
---|
| 652 | } |
---|
[822] | 653 | free(parameters); |
---|
| 654 | fprintf(scriptFile,"\n"); |
---|
| 655 | fprintf(scriptFile,"echo \"Job finished at: $(date)\"\n"); |
---|
[877] | 656 | map* footerMap=getMapFromMaps(*main_conf,configurationId,"jobscript_footer"); |
---|
| 657 | if(footerMap!=NULL){ |
---|
| 658 | // Use the footer file if defined in the HPC section of the main.cfg file |
---|
| 659 | struct stat f_status; |
---|
| 660 | int s=stat(footerMap->value, &f_status); |
---|
| 661 | if(s==0){ |
---|
| 662 | char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); |
---|
| 663 | FILE* f=fopen(footerMap->value,"rb"); |
---|
| 664 | fread(fcontent,f_status.st_size,1,f); |
---|
| 665 | int fsize=f_status.st_size; |
---|
| 666 | fcontent[fsize]=0; |
---|
| 667 | fclose(f); |
---|
| 668 | char* ffcontent=(char*)malloc((strlen(fcontent)+(3*strlen(uuid->value))+1)*sizeof(char)); |
---|
| 669 | sprintf(ffcontent,fcontent,uuid->value,uuid->value,uuid->value); |
---|
| 670 | fprintf(scriptFile,"%s\n### --- ZOO-Service FOOTER end --- ###\n\n",ffcontent); |
---|
| 671 | free(fcontent); |
---|
| 672 | }else |
---|
| 673 | fprintf(scriptFile,"### *** Default ZOO-Service FOOTER (footer file failed to load) *** ###\n\n"); |
---|
| 674 | }else |
---|
| 675 | fprintf(scriptFile,"### *** Default ZOO-Service FOOTER (no footer found) *** ###\n\n"); |
---|
[822] | 676 | fflush(scriptFile); |
---|
| 677 | fclose(scriptFile); |
---|
[860] | 678 | #ifdef HPC_DEBUG |
---|
[839] | 679 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
[860] | 680 | #endif |
---|
[839] | 681 | invokeCallback(m,inputs,NULL,3,1); |
---|
[860] | 682 | #ifdef HPC_DEBUG |
---|
[839] | 683 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
[860] | 684 | #endif |
---|
[822] | 685 | |
---|
| 686 | // Upload the SBATCH File to the remote host |
---|
[860] | 687 | #ifdef HPC_DEBUG |
---|
[839] | 688 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
[860] | 689 | #endif |
---|
[839] | 690 | invokeCallback(m,inputs,NULL,4,0); |
---|
[860] | 691 | #ifdef HPC_DEBUG |
---|
[839] | 692 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
[860] | 693 | #endif |
---|
[854] | 694 | targetPathMap=getMapFromMaps(*main_conf,configurationId,"remote_work_path"); |
---|
[822] | 695 | if(targetPathMap==NULL){ |
---|
[854] | 696 | setMapInMaps(*main_conf,"lenv","message",_("There is no remote_work_path defined in your section!")); |
---|
| 697 | setMapInMaps(*main_conf,"lenv","status","failed"); |
---|
[862] | 698 | errorException (*main_conf, _("There is no remote_work_path defined in your section!"), |
---|
[854] | 699 | "InternalError", NULL); |
---|
[860] | 700 | #ifdef HPC_DEBUG |
---|
[854] | 701 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 702 | fflush(stderr); |
---|
[860] | 703 | #endif |
---|
[862] | 704 | invokeCallback(*main_conf,NULL,NULL,7,0); |
---|
[860] | 705 | #ifdef HPC_DEBUG |
---|
[854] | 706 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 707 | fflush(stderr); |
---|
[860] | 708 | #endif |
---|
[822] | 709 | return SERVICE_FAILED; |
---|
| 710 | } |
---|
| 711 | char* targetName=strrchr(scriptPath,'/'); |
---|
| 712 | char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); |
---|
| 713 | sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); |
---|
[839] | 714 | setMapInMaps(*main_conf,"lenv","remote_script",targetPath); |
---|
[822] | 715 | SSHCON *test=ssh_connect(*main_conf); |
---|
[860] | 716 | int copy0=ssh_copy(*main_conf,scriptPath,targetPath,ssh_get_cnt(*main_conf)); |
---|
[854] | 717 | unlink(scriptPath); |
---|
| 718 | free(scriptPath); |
---|
[860] | 719 | if(copy0!=true){ |
---|
[862] | 720 | setMapInMaps(*main_conf,"lenv","message",_("Unable to upload the script")); |
---|
| 721 | invokeCallback(*main_conf,NULL,NULL,7,0); |
---|
| 722 | errorException(*main_conf,_("Unable to upload the script"),"NoApplicableCode",NULL); |
---|
[860] | 723 | return -1; |
---|
| 724 | } |
---|
[822] | 725 | // Execute the SBATCH script remotely |
---|
[854] | 726 | addReadLocks(main_conf); |
---|
| 727 | map* subStr=getMapFromMaps(*main_conf,configurationId,"sbatch_substr"); |
---|
[822] | 728 | char *command=(char*)malloc((strlen(targetPath)+strlen(targetPathMap->value)+strlen(subStr->value)+strlen(uuid->value)+137)*sizeof(char)); |
---|
| 729 | sprintf(command,"sbatch %s 2> %s/error_%s.log | sed \"s:%s::g\"",targetPath,targetPathMap->value,uuid->value,subStr->value); |
---|
[860] | 730 | if(ssh_exec(*main_conf,command,ssh_get_cnt(m))<=0){ |
---|
[822] | 731 | // The sbatch command has failed! |
---|
| 732 | // Download the error log file from the HPC server |
---|
| 733 | char tmpS[1024]; |
---|
| 734 | free(command); |
---|
[839] | 735 | command=(char*)malloc((strlen(targetPathMap->value)+strlen(uuid->value)+11)*sizeof(char)); |
---|
[822] | 736 | sprintf(command,"%s/error_%s.log",targetPathMap->value,uuid->value); |
---|
| 737 | targetName=strrchr(command,'/'); |
---|
| 738 | free(targetPath); |
---|
| 739 | targetPath=(char*)malloc((strlen(tmpPath->value)+strlen(targetName)+2)*sizeof(char)); |
---|
| 740 | sprintf(targetPath,"%s/%s",tmpPath->value,targetName); |
---|
[839] | 741 | if(ssh_fetch(*main_conf,targetPath,command,ssh_get_cnt(m))==0){ |
---|
[822] | 742 | struct stat f_status; |
---|
| 743 | int ts=stat(targetPath, &f_status); |
---|
| 744 | if(ts==0) { |
---|
| 745 | char* fcontent = NULL; |
---|
| 746 | fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); |
---|
| 747 | FILE* f=fopen(targetPath,"rb"); |
---|
| 748 | fread(fcontent,f_status.st_size,1,f); |
---|
| 749 | int fsize=f_status.st_size; |
---|
| 750 | fcontent[fsize]=0; |
---|
| 751 | fclose(f); |
---|
| 752 | setMapInMaps(*main_conf,"lenv","message",fcontent); |
---|
| 753 | free(fcontent); |
---|
| 754 | }else |
---|
| 755 | setMapInMaps(*main_conf,"lenv","message",_("No message provided")); |
---|
| 756 | }else |
---|
| 757 | setMapInMaps(*main_conf,"lenv","message",_("Unable to fetch the remote error log file")); |
---|
[860] | 758 | tmpPath=getMapFromMaps(m,"lenv","message"); |
---|
| 759 | #ifdef HPC_DEBUG |
---|
[850] | 760 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 761 | fflush(stderr); |
---|
[860] | 762 | #endif |
---|
[862] | 763 | invokeCallback(*main_conf,NULL,NULL,7,0); |
---|
[860] | 764 | #ifdef HPC_DEBUG |
---|
[850] | 765 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 766 | fflush(stderr); |
---|
[860] | 767 | #endif |
---|
| 768 | sprintf(tmpS, "Cannot execute the HPC ZOO-Service %s using %s: %s", s->name, configurationId, tmpPath->value); |
---|
[862] | 769 | errorException(*main_conf,tmpS,"NoApplicableCode",NULL); |
---|
[822] | 770 | free(command); |
---|
| 771 | free(targetPath); |
---|
| 772 | ssh_close(*main_conf); |
---|
[860] | 773 | removeReadLocks(main_conf); |
---|
[822] | 774 | return -1; |
---|
| 775 | } |
---|
[851] | 776 | free(targetPath); |
---|
[860] | 777 | #ifdef HPC_DEBUG |
---|
[839] | 778 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 779 | fflush(stderr); |
---|
[860] | 780 | #endif |
---|
[839] | 781 | invokeCallback(m,NULL,NULL,4,1); |
---|
[860] | 782 | #ifdef HPC_DEBUG |
---|
[839] | 783 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 784 | fflush(stderr); |
---|
[860] | 785 | #endif |
---|
[839] | 786 | free(command); |
---|
[860] | 787 | #ifdef HPC_DEBUG |
---|
[854] | 788 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 789 | fflush(stderr); |
---|
[860] | 790 | #endif |
---|
[822] | 791 | |
---|
| 792 | struct sockaddr_un addr; |
---|
| 793 | memset(&addr, 0, sizeof(addr)); |
---|
| 794 | addr.sun_family = AF_UNIX; |
---|
| 795 | int rc, cl, fd = socket(AF_UNIX, SOCK_STREAM, 0); |
---|
[839] | 796 | char *sname=(char*)malloc((strlen(tmpPath->value)+strlen(uuid->value)+20)); |
---|
[822] | 797 | sprintf(sname,"%s/.wait_socket_%s.sock",tmpPath->value,uuid->value); |
---|
| 798 | strncpy(addr.sun_path, sname, sizeof(addr.sun_path)-1); |
---|
[839] | 799 | |
---|
[822] | 800 | if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) { |
---|
| 801 | perror("bind error"); |
---|
[862] | 802 | setMapInMaps(*main_conf,"lenv","message",_("Unable to bind socket!")); |
---|
| 803 | errorException (*main_conf, _("Unable to bind socket!"), |
---|
[854] | 804 | "InternalError", NULL); |
---|
[860] | 805 | #ifdef HPC_DEBUG |
---|
[854] | 806 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 807 | fflush(stderr); |
---|
[860] | 808 | #endif |
---|
[862] | 809 | invokeCallback(*main_conf,NULL,NULL,7,0); |
---|
[860] | 810 | removeReadLocks(main_conf); |
---|
| 811 | #ifdef HPC_DEBUG |
---|
[854] | 812 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 813 | fflush(stderr); |
---|
[860] | 814 | #endif |
---|
[822] | 815 | return -1; |
---|
| 816 | } |
---|
[860] | 817 | #ifdef HPC_DEBUG |
---|
[854] | 818 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 819 | fflush(stderr); |
---|
[860] | 820 | #endif |
---|
[822] | 821 | if (listen(fd, 5) == -1) { |
---|
[839] | 822 | setMapInMaps(*main_conf,"lenv","message",_("Listen error")); |
---|
[862] | 823 | errorException (*main_conf, _("Listen error"), |
---|
[854] | 824 | "InternalError", NULL); |
---|
[860] | 825 | #ifdef HPC_DEBUG |
---|
[854] | 826 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 827 | fflush(stderr); |
---|
[860] | 828 | #endif |
---|
[862] | 829 | invokeCallback(*main_conf,NULL,NULL,7,0); |
---|
[860] | 830 | removeReadLocks(main_conf); |
---|
| 831 | #ifdef HPC_DEBUG |
---|
[854] | 832 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 833 | fflush(stderr); |
---|
[860] | 834 | #endif |
---|
[822] | 835 | return -1; |
---|
| 836 | } |
---|
[839] | 837 | if ( (cl = accept(fd, NULL, NULL)) == -1) { |
---|
| 838 | setMapInMaps(*main_conf,"lenv","message",_("Accept error")); |
---|
[862] | 839 | errorException (*main_conf, _("Accept error"), |
---|
[854] | 840 | "InternalError", NULL); |
---|
[860] | 841 | #ifdef HPC_DEBUG |
---|
[854] | 842 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 843 | fflush(stderr); |
---|
[860] | 844 | #endif |
---|
[862] | 845 | invokeCallback(*main_conf,NULL,NULL,7,0); |
---|
[860] | 846 | removeReadLocks(main_conf); |
---|
| 847 | #ifdef HPC_DEBUG |
---|
[854] | 848 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 849 | fflush(stderr); |
---|
[860] | 850 | #endif |
---|
[822] | 851 | return -1; |
---|
[839] | 852 | }else{ |
---|
[860] | 853 | #ifdef HPC_DEBUG |
---|
[854] | 854 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 855 | fflush(stderr); |
---|
[860] | 856 | #endif |
---|
[839] | 857 | int hasPassed=-1; |
---|
| 858 | char buf[11]; |
---|
| 859 | memset(&buf,0,11); |
---|
| 860 | while ( (rc=read(cl,buf,10)) ) { |
---|
| 861 | if(rc==0){ |
---|
| 862 | setMapInMaps(*main_conf,"lenv","message",_("Read closed")); |
---|
[862] | 863 | errorException (*main_conf, _("Read closed"), |
---|
[854] | 864 | "InternalError", NULL); |
---|
[860] | 865 | #ifdef HPC_DEBUG |
---|
[854] | 866 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 867 | fflush(stderr); |
---|
[860] | 868 | #endif |
---|
[862] | 869 | invokeCallback(*main_conf,NULL,NULL,7,0); |
---|
[860] | 870 | removeReadLocks(main_conf); |
---|
| 871 | #ifdef HPC_DEBUG |
---|
[854] | 872 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 873 | fflush(stderr); |
---|
[860] | 874 | #endif |
---|
[822] | 875 | return -1; |
---|
[839] | 876 | }else{ |
---|
| 877 | if(rc<0){ |
---|
| 878 | setMapInMaps(*main_conf,"lenv","message",_("Read error")); |
---|
[862] | 879 | errorException (*main_conf, _("Read error"), |
---|
[854] | 880 | "InternalError", NULL); |
---|
[860] | 881 | #ifdef HPC_DEBUG |
---|
[854] | 882 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 883 | fflush(stderr); |
---|
[860] | 884 | #endif |
---|
[862] | 885 | invokeCallback(*main_conf,NULL,NULL,7,0); |
---|
[860] | 886 | removeReadLocks(main_conf); |
---|
| 887 | #ifdef HPC_DEBUG |
---|
[854] | 888 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 889 | fflush(stderr); |
---|
[860] | 890 | #endif |
---|
[822] | 891 | return -1; |
---|
| 892 | } |
---|
[839] | 893 | } |
---|
| 894 | hasPassed=1; |
---|
| 895 | res=atoi(buf); |
---|
| 896 | unlink(sname); |
---|
[854] | 897 | free(sname); |
---|
| 898 | removeReadLocks(main_conf); |
---|
| 899 | |
---|
[839] | 900 | if(res==3){ |
---|
[860] | 901 | #ifdef HPC_DEBUG |
---|
[839] | 902 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 903 | fflush(stderr); |
---|
[860] | 904 | #endif |
---|
[839] | 905 | invokeCallback(m,NULL,outputs,5,0); |
---|
[860] | 906 | #ifdef HPC_DEBUG |
---|
[839] | 907 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 908 | fflush(stderr); |
---|
[860] | 909 | #endif |
---|
| 910 | |
---|
| 911 | // Read informations provided by FinalizeHPC as a configuration file |
---|
| 912 | // then, remove the file. |
---|
| 913 | map* jobid=getMapFromMaps(*main_conf,"lenv","usid"); |
---|
| 914 | map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath"); |
---|
| 915 | char *filePath=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+15)*sizeof(char)); |
---|
| 916 | sprintf(filePath,"%s/exec_status_%s",tmpPath->value,jobid->value); |
---|
[887] | 917 | maps* lm = (maps *) malloc (MAPS_SIZE); |
---|
| 918 | lm->child=NULL; |
---|
| 919 | lm->next=NULL; |
---|
[860] | 920 | int saved_stdout = dup (fileno (stdout)); |
---|
| 921 | dup2 (fileno (stderr), fileno (stdout)); |
---|
[887] | 922 | conf_read(filePath,lm); |
---|
[886] | 923 | //dumpMaps(m); |
---|
[860] | 924 | fflush(stdout); |
---|
| 925 | dup2 (saved_stdout, fileno (stdout)); |
---|
| 926 | close(saved_stdout); |
---|
| 927 | unlink(filePath); |
---|
| 928 | free(filePath); |
---|
[887] | 929 | addMapsToMaps(main_conf,lm); |
---|
| 930 | freeMaps(&lm); |
---|
| 931 | free(lm); |
---|
[860] | 932 | |
---|
[839] | 933 | input=*real_outputs; |
---|
| 934 | while(input!=NULL){ |
---|
| 935 | if(input->child==NULL){ |
---|
| 936 | map* generatedFile=getMap(input->content,"generated_file"); |
---|
| 937 | if(generatedFile!=NULL){ |
---|
| 938 | char* filename=strrchr(generatedFile->value,'/'); |
---|
| 939 | char* targetPath=(char*)malloc((strlen(tmpPath->value)+strlen(filename)+2)*sizeof(char)); |
---|
| 940 | sprintf(targetPath,"%s/%s",tmpPath->value,filename); |
---|
| 941 | test=ssh_connect(*main_conf); |
---|
| 942 | if(ssh_fetch(*main_conf,targetPath,generatedFile->value,ssh_get_cnt(m))==0){ |
---|
| 943 | setMapInMaps(*real_outputs,input->name,"generated_file",targetPath); |
---|
| 944 | free(targetPath); |
---|
| 945 | }else{ |
---|
[886] | 946 | map* hpcStdErr=getMapFromMaps(*main_conf,"henv","StdErr"); |
---|
| 947 | // Added for using sacct in place of scontrol |
---|
| 948 | char *sourcePath=NULL; |
---|
| 949 | if(hpcStdErr!=NULL){ |
---|
| 950 | sourcePath=(char*)malloc((strlen(targetPathMap->value)+strlen(hpcStdErr->value)+2)*sizeof(char)); |
---|
| 951 | sprintf(sourcePath,"%s/%s",targetPathMap->value,hpcStdErr->value); |
---|
| 952 | } |
---|
| 953 | if(hpcStdErr!=NULL && sourcePath!=NULL && ssh_fetch(*main_conf,targetPath,sourcePath,ssh_get_cnt(m))==0){ |
---|
| 954 | free(sourcePath); |
---|
[862] | 955 | struct stat f_status; |
---|
| 956 | int ts=stat(targetPath, &f_status); |
---|
| 957 | if(ts==0) { |
---|
| 958 | char* fcontent = NULL; |
---|
| 959 | fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); |
---|
| 960 | FILE* f=fopen(targetPath,"rb"); |
---|
| 961 | fread(fcontent,f_status.st_size,1,f); |
---|
| 962 | int fsize=f_status.st_size; |
---|
| 963 | fcontent[fsize]=0; |
---|
| 964 | fclose(f); |
---|
| 965 | setMapInMaps(*main_conf,"lenv","message",fcontent); |
---|
| 966 | free(fcontent); |
---|
| 967 | }else{ |
---|
[886] | 968 | char *tmpStr=(char*)malloc((strlen(targetPath)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); |
---|
| 969 | sprintf(tmpStr,_("Unable to fetch the remote file for %s"),targetPath); |
---|
[862] | 970 | setMapInMaps(*main_conf,"lenv","message",tmpStr); |
---|
| 971 | free(tmpStr); |
---|
| 972 | } |
---|
| 973 | }else{ |
---|
| 974 | char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); |
---|
| 975 | sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename); |
---|
| 976 | setMapInMaps(*main_conf,"lenv","message",tmpStr); |
---|
| 977 | free(tmpStr); |
---|
| 978 | } |
---|
| 979 | invokeCallback(*main_conf,NULL,NULL,7,0); |
---|
[839] | 980 | return SERVICE_FAILED; |
---|
[822] | 981 | } |
---|
[886] | 982 | } |
---|
[839] | 983 | }else{ |
---|
| 984 | map* generatedFile=getMap(input->content,"generated_file"); |
---|
[862] | 985 | map* generatedUrl=getMap(input->content,"generated_url"); |
---|
[839] | 986 | if(generatedFile!=NULL){ |
---|
| 987 | char* filename=strrchr(generatedFile->value,'/'); |
---|
| 988 | char* targetPath=(char*)malloc((strlen(tmpPath->value)+strlen(filename)+2)*sizeof(char)); |
---|
| 989 | sprintf(targetPath,"%s/%s",tmpPath->value,filename); |
---|
| 990 | test=ssh_connect(*main_conf); |
---|
| 991 | if(ssh_fetch(*main_conf,targetPath,generatedFile->value,ssh_get_cnt(m))==0){ |
---|
| 992 | maps* tmp=getMaps(*real_outputs,input->name); |
---|
[854] | 993 | char serviceName[9]; |
---|
[839] | 994 | freeMap(&tmp->content); |
---|
| 995 | free(tmp->content); |
---|
| 996 | tmp->content=NULL; |
---|
| 997 | maps* output=getMaps(*real_outputs,input->name); |
---|
| 998 | setMapInMaps(output->child,"download_link","generated_file",targetPath); |
---|
[862] | 999 | setMapInMaps(output->child,"download_link","generated_url",generatedUrl->value); |
---|
[854] | 1000 | setMapInMaps(output->child,"download_link","storage",targetPath); |
---|
[839] | 1001 | setMapInMaps(output->child,"download_link","useMapserver","false"); |
---|
[854] | 1002 | setMapInMaps(output->child,"download_link","replicateStorageNext","true"); |
---|
| 1003 | setMapInMaps(output->child,"download_link","asReference","true"); |
---|
| 1004 | setMapInMaps(output->child,"download_link","inRequest","true"); |
---|
[851] | 1005 | setMapInMaps(output->child,"wms_link","generated_file",targetPath); |
---|
[854] | 1006 | setMapInMaps(output->child,"wms_link","storage",targetPath); |
---|
[851] | 1007 | setMapInMaps(output->child,"wms_link","useMapserver","true"); |
---|
| 1008 | setMapInMaps(output->child,"wms_link","msOgc","WMS"); |
---|
| 1009 | setMapInMaps(output->child,"wms_link","requestedMimeType","image/png"); |
---|
[854] | 1010 | setMapInMaps(output->child,"wms_link","asReference","true"); |
---|
| 1011 | if(getMaps(output->child,"wcs_link")!=NULL){ |
---|
| 1012 | sprintf(serviceName,"wcs_link"); |
---|
[862] | 1013 | setMapInMaps(output->child,"wcs_link","msOgc","WCS"); |
---|
| 1014 | }else{ |
---|
[854] | 1015 | sprintf(serviceName,"wfs_link"); |
---|
[862] | 1016 | setMapInMaps(output->child,"wfs_link","msOgc","WFS"); |
---|
| 1017 | } |
---|
[854] | 1018 | setMapInMaps(output->child,serviceName,"storage",targetPath); |
---|
| 1019 | setMapInMaps(output->child,serviceName,"generated_file",targetPath); |
---|
| 1020 | setMapInMaps(output->child,serviceName,"useMapserver","true"); |
---|
| 1021 | setMapInMaps(output->child,serviceName,"asReference","true"); |
---|
| 1022 | }else{ |
---|
[860] | 1023 | map* hpcStdErr=getMapFromMaps(*main_conf,"henv","StdErr"); |
---|
[886] | 1024 | char *sourcePath=NULL; |
---|
| 1025 | if(hpcStdErr!=NULL){ |
---|
| 1026 | dumpMap(hpcStdErr); |
---|
| 1027 | sourcePath=(char*)malloc((strlen(targetPathMap->value)+strlen(hpcStdErr->value)+2)*sizeof(char)); |
---|
| 1028 | sprintf(sourcePath,"%s/%s",targetPathMap->value,hpcStdErr->value); |
---|
| 1029 | } |
---|
| 1030 | if(hpcStdErr!=NULL && sourcePath!=NULL && ssh_fetch(*main_conf,targetPath,sourcePath,ssh_get_cnt(m))==0){ |
---|
| 1031 | free(sourcePath); |
---|
[860] | 1032 | struct stat f_status; |
---|
| 1033 | int ts=stat(targetPath, &f_status); |
---|
| 1034 | if(ts==0) { |
---|
| 1035 | char* fcontent = NULL; |
---|
| 1036 | fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); |
---|
| 1037 | FILE* f=fopen(targetPath,"rb"); |
---|
| 1038 | fread(fcontent,f_status.st_size,1,f); |
---|
| 1039 | int fsize=f_status.st_size; |
---|
| 1040 | fcontent[fsize]=0; |
---|
| 1041 | fclose(f); |
---|
| 1042 | setMapInMaps(*main_conf,"lenv","message",fcontent); |
---|
| 1043 | free(fcontent); |
---|
| 1044 | }else{ |
---|
[886] | 1045 | char *tmpStr=(char*)malloc((strlen(targetPath)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); |
---|
| 1046 | sprintf(tmpStr,_("Unable to fetch the remote file for %s"),targetPath); |
---|
[860] | 1047 | setMapInMaps(*main_conf,"lenv","message",tmpStr); |
---|
| 1048 | free(tmpStr); |
---|
| 1049 | } |
---|
| 1050 | }else{ |
---|
[886] | 1051 | char *tmpStr=(char*)malloc((strlen(sourcePath)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); |
---|
| 1052 | sprintf(tmpStr,_("Unable to fetch the remote file for %s"),sourcePath); |
---|
[860] | 1053 | setMapInMaps(*main_conf,"lenv","message",tmpStr); |
---|
| 1054 | free(tmpStr); |
---|
| 1055 | } |
---|
| 1056 | invokeCallback(*main_conf,NULL,NULL,7,0); |
---|
[854] | 1057 | return SERVICE_FAILED; |
---|
[839] | 1058 | } |
---|
[851] | 1059 | free(targetPath); |
---|
[839] | 1060 | } |
---|
[822] | 1061 | } |
---|
[839] | 1062 | input=input->next; |
---|
[822] | 1063 | } |
---|
[854] | 1064 | |
---|
| 1065 | }else{ |
---|
| 1066 | // Try to access remotely to the log file and return a more relevant error message |
---|
[862] | 1067 | setMapInMaps(*main_conf,"lenv","message",_("HPC Execution failed!")); |
---|
| 1068 | errorException (*main_conf, _("HPC Execution failed!"), |
---|
[854] | 1069 | "InternalError", NULL); |
---|
[860] | 1070 | #ifdef HPC_DEBUG |
---|
[854] | 1071 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 1072 | fflush(stderr); |
---|
[860] | 1073 | #endif |
---|
[862] | 1074 | invokeCallback(*main_conf,NULL,NULL,7,0); |
---|
[860] | 1075 | #ifdef HPC_DEBUG |
---|
[854] | 1076 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 1077 | fflush(stderr); |
---|
[860] | 1078 | #endif |
---|
[822] | 1079 | } |
---|
| 1080 | } |
---|
[839] | 1081 | if(hasPassed<0){ |
---|
| 1082 | perror("Failed to read"); |
---|
| 1083 | setMapInMaps(*main_conf,"lenv","message",_("Unable to parse the value returned by remote execution")); |
---|
[862] | 1084 | errorException (*main_conf, _("Unable to parse the value returned by remote execution"), |
---|
[854] | 1085 | "InternalError", NULL); |
---|
[860] | 1086 | #ifdef HPC_DEBUG |
---|
[854] | 1087 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 1088 | fflush(stderr); |
---|
[860] | 1089 | #endif |
---|
[862] | 1090 | invokeCallback(*main_conf,NULL,NULL,7,0); |
---|
[860] | 1091 | #ifdef HPC_DEBUG |
---|
[854] | 1092 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 1093 | fflush(stderr); |
---|
[860] | 1094 | #endif |
---|
[839] | 1095 | return SERVICE_FAILED; |
---|
| 1096 | } |
---|
| 1097 | } |
---|
[860] | 1098 | #ifdef HPC_DEBUG |
---|
[850] | 1099 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 1100 | fflush(stderr); |
---|
[860] | 1101 | #endif |
---|
[822] | 1102 | ssh_close(*main_conf); |
---|
[860] | 1103 | #ifdef HPC_DEBUG |
---|
[850] | 1104 | fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); |
---|
| 1105 | fflush(stderr); |
---|
[860] | 1106 | #endif |
---|
[822] | 1107 | return res; |
---|
| 1108 | } |
---|